Use Applescript In  Xcode To Make Timer In Window

Hi Everyone, I Making An Applescript and cocoa App In Xcode, and i need a Timer that is embedded in a interface builder window how do i do this?

One way would be to create a countdown handler using performSelector:withObject:afterDelay: to repeatedly count down, putting the current value into your text field.  For example, using countdownText as your text field and countdownTime as the value to count down:
on countdown()
  set countdownTime to countdownTime - 1
  if countdownTime is less than 0 then -- clear timer and reset
  parent's cancelPreviousPerformRequestsWithTarget_selector_object_(me, "countdown", missing value)
  countdownText's setStringValue_("") -- clear the countdown text
  -- reset countdownTime value and do whatever when countdown ends
  else -- do it again
  countdownText's setStringValue_(countdownTime) -- update the countdown text
  performSelector_withObject_afterDelay_("countdown", missing value, 1.0)
  end if
end countdown

Similar Messages

  • AppleScript or Xcode?

    Hi,
    I have a rather unusual project and don't know if I should use AppleScript or Xcode. I'm a bit used to applescript but don't know Xcode at all.
    *Here is the main idea and goal :*
    I have a mac mini which has a mediaplayer which runs video and such for digital signage.
    That mac mini is connected to a USB Internet key (Roger's RocketStick). Everything works fine but I need to click on connect each time for it to connect on the internet and I must disconnect each night for the mac to shut down. Plus, I need to start the player and shut it off too. This is really a pain in the......
    *Current setup* (+works okay but has alot of bugs that I can't put my finger on+)
    I'm working with a script I did using automator and AppleScript, LogIn items for the startup script and iCal for shutdown times which then activates the shutdown script.
    I thought I was pretty clever doing it this way, but sometimes for reasons unknown, the mac gets confused and loads both shutdown and startup scripts on bootup and hangs.
    Guess on what type of code to use? Or do you have a better solution than what I'm doing.

    kpott wrote:
    Anyway, the piece of software Roger's gave with their Internet USB key can't connect by itself, you must click on the connect button when their software boots or else it just finds the signal and waits for your command. I guess this was done intentionally by their part to save on bandwidth use.
    You need to click a button. AppleScript can do this & is done all the time.
    See the script below.
    Get the scripting setup right then
    Might be simple as:
    keystroke return
    The problem I'm getting is that I usually get the "Finder canceled "Shutdown"...." error message when the mac mini boots. "Shutdown" is the name of my script. This only happens sometimes, which is my biggest frustration. The method I'm using isn't stable.
    Rename your script. The name is confusing. Something like myShutdown.
    This is why I'm trying to look into a better way to work this out. I'm using Energy Saver to schedule the power on process and login items to start the script. The reason why I'm using iCal is to shutdown the computer using a script. I couldn't get the mac to start a script while Shutdown was initialized using the Energy Saver feature. PLUS, only to make things worst, on sundays, the mac must shutdown earlier in the day.
    Interesting...
       Remember you need to enable assistive devices.
       This lets applications software access screen elements.
       blue apple > system perferences > universal access > enable assistive devices
    -- Write a message into the event log.
       Run this program from the Script Editor.  Click on the Event Log tab at the
       bottom of the screen.
    log "  --- Starting on " & ((current date) as string) & " --- "
    set the_item_ref to choose file with prompt "Select an html, text, or some other file Safari will display."
    -- Activate
    activate application "Safari"
    -- Open the URL 
    tell application "Safari"
       open the_item_ref
       -- print
       -- System Events interacts with the current active applications.
       tell application "System Events"
          tell process "Safari"
             -- Your simulating typing on the keyboard.  You need to allow time
             -- for the application to run. It's always a guess about delay in seconds.
             delay 3
             -- Be sure your printer is up & running before printing.
             keystroke "p" using command down
             delay 3
             keystroke return
             delay 10
             keystroke "w" using command down
          end tell
       end tell
    end tell -- of Safari

  • Can I find the current tab in Terminal using applescript?

    Running a script from the shell by prepending
    #! /usr/bin/osascript
    as part of my .profile, can I find the "current" tab using Applescript. Most of the time, the "current" tab will not be visible, as the shell is being initialised, or re-initialised.
    I want to set the dircolors for my shell by determining the background color of the tab in which the shell is executing.

    Under the Window menu you can activate any of the palettes that you want. In your case the Field tab is under the Object palette

  • I bought my iPad mini two weeks ago and used my apple ID to make it synch with my iPhone. But so far I have not been able to activate iMessage and face time. It only gives me the option of signing i

    I bought my iPad mini two weeks ago and used my apple ID to make it sync with my iPhone. But so far I have not been able to activate iMessage and face time. It only gives me the option of signing in and when I do that I get an error message telling me that either my user name or password for my email is incorrect; even though I have been using my correct my apple ID in the password entry area. My apple ID works for every thing else. Please, can you help in this case?

    Have a look here...
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    SHARING iTunes MUSIC
    http://macmost.com/five-ways-to-share-music-in-itunes.html
    Also... Create your Own Apple ID for Your iPhone...
    It should be Noted that anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID
    Apple ID FAQs  >  http://support.apple.com/kb/HT5622
    And... Have a read here...
    https://discussions.apple.com/message/18409815?ac_cid=ha
    See Here for  >  How to Use Multiple iDevices with One Computer
    Have a read here...
    https://discussions.apple.com/message/18409815?ac_cid=ha

  • How to use time stamps en how to make time stamps in Adobe Reader

    How to use time stamps en how to make time stamps in Adobe Reader

    Did you find a solution? I am having the same problem.
    PDF compatibility level is too high. Supported PDF versions are PDF 1.3 and PDF 1.4 (Acrobat 4, 5 and 6). If you are using Acrobat 7 or higher you will need to save your file at a lower PDF compatibility level.

  • How to fetch current system time in milliseconds using AppleScript?

    I need to write the actual systemtime hh:mm:ss.msc into a field of FileMaker by using AppleScript (as FileMaker does still not support TimeStamps down to milli seconds) - now, how to realize that?
    Any help is welcome - Thanx

    Hi Mathur,
    kindly help me in mapping a field in which I have to map current system time.
    I think there is no standard function for time like the date so do i write a UDF for the same or any other way an in case a UDF than please help in that.
    Mathur no need to write UDF for that..
    Use standard function Current date-------> In that (Target Format) u have to specify the time i.e: HHmmss
    Thats it..... Noe use this function as u like...
    Satya Kumar

  • I need to make a stop start animation using iMovie. I need the time factor to be 0.03. Every time I make an adjustment it goes to 0.1s which is too slow. Does anyone have a suggestions?

    I need to make a stop start animation using iMovie. I need the time factor to be 0.03. Every time I make an adjustment it goes to 0.1s which is too slow. Does anyone have a suggestions?

    First, for Stop Motion Animation, there are better tools. These include iStopMotion and QuickTIme Pro Version 7.
    If you want to do it in iMovie, it is possible, but slow.
    First, go into iMovie Preferences, and make sure you check "Display Time as hh:mm:ss:frames". This will let you edit to the frame lever rather than to the nearest 10th of a second.
    Second, see this Tutorial by Jon Walker on how to edit down to a single frame in a still image sequence.
    You can modify his technique to get 2 or three frames.

  • How can I make Time Machine use the ethernet cable to Time Capsule instead of the wireless connection? Wireless is too slow; has been taking 40 hours to create an initial 142 GB backup.

    How can I make Time Machine use the ethernet cable to Time Capsule instead of the wireless connection? Wireless is too slow; has been taking 40 hours to create an initial 142 GB backup.

    Plug in ethernet .. in the computer.. turn off wireless.

  • How can I change the font size of an outgoing instant message using Applescript?

    Text copied into Messages.app from a web page is often too small to read. Is there a quick way to boost the font size using Applescript?

    HI,
    I have spent some time looking at the Mix Message Case.scpt in Hard Drive/Library/Scripts/Messages and also Crazy Message Text.scpt in the same Scripts Folder but then the Mail one.
    Both are Apple versions.
    The Mix Case one is set in Messages > Preferences > Alerts
    Set the top drop down to Sent Message
    Enable the Applescript items and chose the Mix Case item.
    It will look something like this in the current Font and size you have set.
    ThEn aGaIn
    Obviously you don't want all the bit to make the font change between upper an lower case but it does have the option to use it with the Sent Message and it also uses the entry in the text field as a String.
    The Mail Crazy Message one  opens a dialogue box when run.
    it has a default phase and some Upper and lower limits to the size that will be used.
    the Dialogue allows you to change the phrase and also "Set Prefs" to altert the font sizes.
    The result is a text palce in a new Mail items and the font and size changes to look like this:-
    Picture
    It will look different everytime and the Font for each character  and the size of each is randomised.
    Although I have tried sticking in a line to change the size to anything other then my set font in the Mixed Case one I can't get it to work.
    In some cases I get an Script error in Messages  (It seems to think I am setting a Font called "10")
    At other times it just says it can't set it buit still does the Mixed Case bit.
    My hope was to change the size and then reduce the requirement for the "intercaps" routine.
    I have other emails about new posts so I will anwser them and then spend some more time on this.
    9:01 PM      Thursday; June 13, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.4)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Adding all day events using applescript to ical

    Hey all. I am new to using applescript. Thanks to some top users i have been able to get excel events file transfered into ical.
    I need help with the applescript for changing these events from time duration to all day.
    tried
    set the start time to 00:00 and end time to 24:00 and
    set all-day to true
    any help would be greatly appreciated!!
    thanks.

    I have the exact same problem. I have entered birthdays for people I know starting with the year of their birth and never ending, an all-day event. They now don't show in 2007, but there is a detached event on January 1, 2000. When I delete that event and all subsequent versions of it, the initial event now ends in 2006 or 2007, and I have to set the repeat to end Never again. I fixed all the ones from February that showed up. Now I notice that a huge amount of the other birthdays (all day events) that I have entered are doing it now, and we are talking well over 40 of them. I don't understand why it keeps creating these detached events. I also publish my calendars, if that makes any difference.

  • How I generate index markers using Applescript and tagged text!

    One of the challenges I've faced in automating the book making process using Applescript with inDesign is that there don't seem to be any AS commands for making new index markers (anyone please correct me I if I'm wrong about this).
    I've tried various js scripts which do an OK job, but they don't make the actual native markers. This means you have to wait until the book (consistiing of multiple ID files) is complete (so that all the page numbers have been established) to generate the index.
    Recently, I read a tweet from someone with a link to a technique which uses tagged text and find and replace with GREP to edit the tags, inserting the tagged text index tags in the text file and then re-placing the text file in the ID page. In itself, this works great. But I'm dealing with literally thousands of separate text frames, none of them connected in a story.
    The books typically consist of around 1200 pages with almost that many people, each of whose names I need to index with "Lastname, Firstname" references. And those particular strings don't (can't) appear anywhere on the pages. There will also be about 50 ID files all combined into one book. So it is imperative that I have ID generate the native index markers. To help keep things straight and efficient, I'm creating separate small text frames to hold the lastname, firstname strings. I created an object style for these frames which sets the attributes to "nonprinting", and I place the frames in the margin.
    Then I realized that I don't actually have to have ID export the tagged text files for each. I exported one prototype and copied its tags to properties in my script, and then I concatenate them with the respective list item values I import from the database.
    At the proper point in the page building script, I tell "textwrangleer" to make a new document, set its contents to the index string for the current record, save it to disk, overwriting the previous one, and then tell ID to "place" it in the index text frame, which generates the ID index mark.
    I actually got an AS error when I first tried this: "file doesn't exist" or some such. Then I realized that the "place" command was happening too soon, so I inserted a .5 sec delay in the script, and it worked.
    This is actually my first major script for actual work, and I'm so excited about it! I promises to cut production time down to about a thenth of what it was.
    I still have to add some logic to branch between handlers with slightly different parameters for five different page formats, but the same page building handler will work on all of them.

    A note on this:
    Daniel Swanson wrote:
    I've tried various js scripts which do an OK job, but they don't make the actual native markers. This means you have to wait until the book (consistiing of multiple ID files) is complete (so that all the page numbers have been established) to generate the index.
    These scripts typically search for words and immediately write out the page numbers they are found on -- one shot indexing.
    The solution is to add both the topic and its page reference to the current document's index:
    if (app.activeDocument.indexes.length == 0)
        app.activeDocument.indexes.add();
    app.activeDocument.indexes[0].topics.add(app.selection[0].contents).pageReferences.add(app.selection[0]);
    The first lines only make sure there is an index to add to (per default, a new document has none).
    The last line adds a selected word to the index (it must be a plain text string, hence the use of its 'contents'), and then adds a reference to the selection in the text itself.
    Adding the same word a second time will for a change (quite untypically for ID's Scripting) not result in an error but simply add another page reference to the existing one.
    When doing this in a loop: remember to work backwards, because the index marker itself gets inserted into the running text, and that will throw off your text indices.

  • How can I use AppleScript Studio to display an image

    How can I use AppleScript Studio to display an image in a dialog?

    Add an image well to your window in Interface Builder.
    You can also add an image file to the Resources group of your Xcode project and then set the image to be displayed inside the image well directly in Interface Builder. No AppleScript code is needed if the image is contained within your app bundle and can be set ahead of time like this.
    If the image is contained in your app's bundle but you need to set or change the image at run time then you can use a line of AppleScript to load it into the image well using just it's filename:
    set image of image view "yourImageView" of window "yourWindow" to load image "YourImageFile.jpg"
    If you need to load an image from an arbitrary location outside your app's bundle then use a path to the image file...
    set image of image view "yourImageView" of window "yourWindow" to load image "/path/to/YourImageFile.jpg"
    Steve

  • Simulate Mouse Click using AppleScript

    I want to simulate a mouse click using AppleScript. I used click button of window command but unfortunately it only simulates a half click in the sense that you see the button highlighted but the action is not activated. I used a command key function, where I would press a # many times to make the mouse go down. However, this is very slow. I noticed that there is a couple of additional elements that can be used with AppleScript for example XTools and Extra Suites where I can tell the mouse to go to a certain location and click. I am on a Mac OS X 10.3.9 system (I believe I am using a PowerMac as well) and would like to know if any of the two programs are compatible with this system. I would appreciate any help in how I can install the software and what directory to place the software. Thank you very much for your help.

    Hi, I don't know if the latest version works in 10.3, but might try Quickeys...
    http://startly.com/products/quickeys/mac/4/
    Extra Suites should tell you if it works or not when installing.
    For old Mac SW...
    http://www.oldapps.com/mac/?ModPagespeed=noscript
    I think the most modern Browser for Panther/10.3.9 is Camino...
    http://caminobrowser.org/releases/1.6.9/
    Or iCab 4.8...
    http://www.icab.de/dl.php

  • Using AppleScript to auto-archive mail in Outlook 2011

    I want to use AppleScript to set up a schedule to auto-archive mail greater than X days old. What I've found so far is below, and the error I'm receiving is "error "Microsoft Outlook got an error: Can’t get pop account \"TargetProcess\"." number -1728 from pop account "TargetProcess"".
    # the time we want to archive from
    set theArchiveCutoffTime to ((current date) - (32 * days))
    property theCount : 0
    tell application "System Events"
      set targetProcess to count (every application process whose name is "Mail")
    end tell
    tell application "Microsoft Outlook"
      set thisAccount to pop account "TargetProcess"
      set thisFolders to mail folder of thisAccount
    # find the "Inbox" of topFolder and "Mail ARCHIVE" of on my computer
      repeat with thisFolder in thisFolders
      if name of thisFolder is "Inbox" then
      set theInbox to thisFolder
      else if name of thisFolder is "Mail ARCHIVE" then
      set theARCHIVE to thisFolder
      end if
      end repeat
    # find the archive "Inbox"
      repeat with thisFolder in mail folder of theARCHIVE
      if name of thisFolder is "Inbox" then
      set theArchiveInbox to thisFolder
      end if
      end repeat
      set theArchiveTarget to theArchiveInbox
    # archive the Inbox
      repeat with theMessage in message in theInbox
      if time received of theMessage < theArchiveCutoffTime then
      move theMessage to theArchiveTarget
      set theCount to theCount + 1
      else
      # we get messages from oldest to newest
      exit repeat
      end if
      end repeat
    # archive sub-folders
      repeat with thisSubfolder in mail folder of theInbox
      # find the archive subfolder corresponding to this
      repeat with thisARCHIVEubfolder in mail folder of theArchiveInbox
      if name of thisARCHIVEubfolder is name of thisSubfolder then
      set theArchiveTarget to thisARCHIVEubfolder
      end if
      end repeat
      # archive messages
      repeat with theMessage in message in thisSubfolder
      if time received of theMessage < theArchiveCutoffTime then
      move theMessage to theArchiveTarget
      set theCount to theCount + 1
      else
      # we get messages from oldest to newest
      exit repeat
      end if
      end repeat
      end repeat
    end tell
    I'm working in AppleScript Editor v2.6.1 (152.1), Microsoft Outlook 2011 v14.3.5, OSX 10.9.4 Mavericks.

    Ok, red_menace above me had a shorter and more elegant solution to the question, I'm adding this just for another example.
    To solve your problem I'd make a mail rule that looked for any messages with "Filename:" in them (along with whatever criteria you wanted, like sender, domain, etc). The mail rule would execute the Applescript. My assumption is that the "Filename:foobar" text could be anywhere in the email, not necessarily the first thing in a paragraph, so I had to parse it differently.
    The results end up in a datalist, (theFilename {} ) that you can parse later to collect all filenames found in whatever messages were processed.
    I realize this could be cleaner, hope it's not hard to follow, but I did it really fast. It works flawlessly for me, picking out the name of the file no matter where in the email it appears.
    using terms from application "Mail"
    on perform mail action with messages theSelectedMessages for rule theRule
    repeat with aCounter from 1 to count theSelectedMessages
    set theMessage to item aCounter of theSelectedMessages
    set theContent to content of theMessage
    set theWords to every word of theContent
    set theFilename to {}
    set tid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to ":"
    repeat with thisLoop in theWords
    try
    if (text item 1 of thisLoop) is "Filename" then
    set end of theFilename to (text item 2 of thisLoop)
    -- rest of your logic goes here the display is just to show it finds the filename, take it out!
    display dialog theFilename ¬
    buttons {"OK"}
    end if
    end try
    end repeat
    set AppleScript's text item delimiters to tid
    end repeat
    end perform mail action with messages
    end using terms from
    Message was edited by: stephen.bradley Typos for the win!

  • Who Uses Applescript with Aperture and Why?

    From time to time, I come see Applescript mentioned by Aperture Users. The Apple Support website devotes a few paragraphs.
    For an amateur with lots of time. how would Applescript make my experience with Aperture any better? It automates what?

    http://www.apple.com/aperture/resources/pdf/Aperture_3_AppleScript_Reference.pdf
    http://apertureexpert.squarespace.com/forum-applescript/
    http://www.macosxautomation.com/applescript/aperture/publish/index.html
    http://www.macworld.com/article/2033806/import-like-a-pro-in-aperture.html
    There's also an application that will give you lots of statistics on your Aperture library (lenses used, etc):
    http://www.apertureexpert.com/inspector
    I'm pretty sure it uses AppleScript to get the data.

Maybe you are looking for

  • BW Statistic reports has 'VIRTUAL-00001' entries

    Hi all; I ran a BW stat report which comes from BW stat multiprovider, to see what are the reports that were used for last year and I got some entries with report name VIRTUAL-000011 VIRTUAL-000016 VIRTUAL-000006 Also I have on entry with just letter

  • My mac book fell asleep while migrating...now it is stuck.  What am i supposed to do?

    I was migrating information from my mac book pro to my new mini mac, and the power cord got pulled and my mac book went to sleep.  It is stuck (after 5 and half hours) and i am afraid of shutting either off.  What should i do?

  • Mountain Lion appears to break VNC connection to a headless mac mini.

    I connect to my headless mac mini with VNC.  Under lion this worked perfectly.  With Mountain Lion on my mac mini I can connect but many windows do not update properly.  If I connect an external display to the mac mini all is well again.  Any solutio

  • Problem in Adding Emails in new Blackberry Z10

    Hi I tried adding my work emails (Company Domain from Sites and Stores) here but its not letting me do that. I called Telstra they added from there end and is still not working. They send me service books twice i received nothing and they said i migh

  • Sap form

    INVOICE WINDOW 1. Company Address - Details FS: 5 - LOGIC ADRC-ADRNR = T001-ADRNR(T001-BUKRS = L_ROW-CCFR) - GET : NAME1, STREET, HOUSE NUM1,CITY1, POST CODE1, COUNTRY 2. Bank Details : Details FS : 6 - LOGIC LFBK first record where LIFNR = L_ROW-CUS