Using Applescript to make a repeatedly keystroke

Hi, I am wondering if there's another place where this thread would be morewellplaced, but couldnt find anything about Applescripting, so here goes:
I dont know if this is possible, but i would like to have a key pressed repeatedly - all the time - while i am playing World of Warcraft on my mac.
I am playing in windowed mode - this means not in full screen.
In the game i have bound a certain action to the button "0" (zero).
I need to have this key repeatedly pressed every second or so.
Is this possible with applescript? And how would the script look?
Hope someone can help me
Kind regards

Hi,
Thx for the suggestion
I tried using this script. It didnt really do anything "inside" the game, other that my movements behaving strangely. I think it was running outside the game and kind of interfering in some manner.
I then tried to make an extra line in the script myself:
activate application "World of Warcraft"
I dont really know what it does, but it sounded like it maybe would press the key inside the actual game (in the right application window)... but this didnt work either.
So i may have to give up unless someone know something more about this.

Similar Messages

  • Pages 09 Saving using applescript automatically makes a package

    I can manually save a document as a flat file, but when I run my applescript, it saves as a package, even though "Save new documents as packages" in the Preferences is unchecked.
    Is this the same issue as this thread? http://discussions.apple.com/thread.jspa?threadID=2141532&start=15&tstart=0

    OK, I am using Pages 09
    Here is a sample letter I want to save:
    Marcus Welby, M.D.
    666 Hemingway
    Kansas City, KS 66111
    Re: Joe Jones
    5/3/80
    Dear Dr. Welby:
    I appreciated the opportunity to see your patient in the office today
    Thank you very much for letting me help with the patient’s care.
    Sincerely,
    Dr. Doolittle
    Here is a sample from the script I run to save, print, organize my dictation for the day:
    --sets the date as a string yymmdd
    set theyear to (year of (current date)) - 2000
    if theyear < 10 then
    set theyear to "0" & theyear
    end if
    set themonth to (month of (current date) as integer)
    if themonth < 10 then
    set themonth to "0" & themonth
    end if
    set theday to (day of (current date) as integer)
    if theday < 10 then
    set theday to "0" & theday
    end if
    set datefolder to theyear & themonth & theday
    set datefolder to datefolder as string
    --gets the patient's name from the document (all my documents have "Re: patient's name" at the top of the page
    tell application "Pages"
    set newdoc to front document
    set AppleScript's text item delimiters to "Re: "
    set ptdoctext to text of newdoc as string
    set ptname to 1st paragraph of 2nd text item of ptdoctext
    set AppleScript's text item delimiters to ""
    --save the document in datefolder under ptname
    set filen to ":Users:[home folder]:Documents:Dictation:" & datefolder & ":" & ptname & ".pages" as string
    save newdoc in filen
    end tell
    If I run this script on the document, it saves as a package
    If I save the document manually, it saves as a flat file (because the preference to save as a package is not checked)
    It's not a big deal to save as a package, just takes up more disk space.
    Please try running the script on your system with Enregistrer les nouveax documents comme pacquets not checked. I bet it still saves as a package.
    Merci

  • I am trying to use AppleScript to make a quick compose app for iMessage.

    tell application "Messages"
                        set theBuddy to buddy of service " "
      send myMsg to theBuddy
              end tell
    I was wondering, what are possible services. Because every time I try to run the program it says cannot get the service. And how can generalize this service in case I choose to distribute this application. Or use it for some other application.

    Easy:

  • What is speech recognition server? Can I use applescript to make an app like siri??

    tell application "SpeechRecognitionServer"
    set response to listen for {"good","bad"} with prompt "How are you?"
    if response is "good" then
    say "Wonderful sir.. Is there anything you want me to do for you?"
    else
    say "Cheer up! Is there anything I can do for you?"
    end if
    end tell
    This is the script i'm trying to run, but there's a problem! it says - "Where is Speech Recognition Server"

    The path for that is /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognit ion.framework/Versions/A/SpeechRecognitionServer.app

  • Using applescript to open launchpad

    Hello all,
    I just bought a new iMac yesterday, and I love the multitouch features of my new magic mouse, but I had wanted to be able to add a few more so that I could use similar functions to those which I use on my iPad. I discovered the app Magicprefs, and it works great, but one thing I wanted to do was make it so that a two finger swipe up opens Launchpad, and a two finger swipe down closes it. From what I can tell, Magicprefs makes it so that a two finger swipe up will open and close Launchpad, and same with a two finger swipe down. I was trying to use applescript to make it so that a swipe up will only open it and a swipe down will only close it, not do both. The problem is that while I am familiar with basic programming I am not familiar with the exact language used in applescript and also it looks like launchpad is not simply opened and then quit so these basic commands are not working. Could anyone give me the basic code I can use to tell Magicprefs to open it with a swipe up and to close it with a swipe down? Or if this is even possible? Thanks for any help!

    You can't make a keyboard shortcut to run a specific application from OSX, although there are third party applications such as Quicksilver that can do things like that. You can use an AppleScript to activate an existing menu item, for example:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "Finder" to activate
    tell application "System Events" to tell application process "Finder"
    keystroke "A" using {shift down, command down}
    end tell</pre>
    Other alternatives to keyboard shortcuts are to use the Scripts Menu or add an application to the Finder's toolbar. The Script Editor does not need to be active to use scripts.

  • How to make a spot swatch with specific name by using AppleScript?

    Hi there,
    I am trying to create a script in AppleScript to make a new spot color swatch that must be the COLOR TYPE : SPOT (with specific values). I've got it to make a global process color but can't seem to make a spot swatch. I'm using the script below :
    tell application "Adobe Illustrator"
        set docColorSpace to color space of document 1
        if (docColorSpace is CMYK) then
            set SpotColor to {cyan:100.0, magenta:0, yellow:0.0, black:0.0}
        else
            set SpotColor to {red:0.0, green:174.0, blue:239.0}
        end if
        make new spot in document 1 with properties {name:"ADHESIVE", color:SpotColor}
    end tell
    I did find an entry in an old forum that did this using javascript, however, I am not experienced with this at all and have no idea what or how to use it on a mac platform. This script is listed below.
    #target illustrator
    var docRef = app.activeDocument;
    var newCMYK = new CMYKColor();
    newCMYK.cyan = 100;
    newCMYK.magenta = 0;
    newCMYK.yellow = 0;
    newCMYK.black = 0;
    var thisSpot = docRef.spots.add();
    thisSpot.name = 'ADHESIVE';
    thisSpot.color = newCMYK;
    thisSpot.colorType = ColorModel.SPOT;
    Any help would be greatly appreciated.
    Thank you!

    You are close but missing the last property listed in the JavaScript… It translates to… 'color type:spot color'
    tell application "Adobe Illustrator"
    set docColorSpace to color space of document 1
    if (docColorSpace is CMYK) then
    set SpotColor to {cyan:100.0, magenta:0, yellow:0.0, black:0.0}
    else
    set SpotColor to {red:0.0, green:174.0, blue:239.0}
    end if
    make new spot in document 1 with properties {name:"ADHESIVE", color:SpotColor, color type:spot color}
    end tell
    BTW… The use of JavaScript in the CS apps is more common because of its 'platform independence' There is a toolkit supplied along with the CS install.

  • 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

  • How to press a button on a webpage in safari using applescript?

    Hi I am new using the applescript so I am learning about it
    I am right now trying to make one with a webpage
    http://nycserv.nyc.gov/NYCServWeb/NYCSERVMain
    I want to press a button and I can't get to it
    this is what I have until now:
    tell application "Safari"
    activate
              open location "http://nycserv.nyc.gov/NYCServWeb/NYCSERVMain"
              click button "Go"
    end tell
    Please help me with this. At least with the button "GO" then I will figure it out to finish the rest
    thanks

    You might like to experiment with something like this:
    tell application "Safari"
        activate
        set URL of tab 1 of window 1 to "http://nycserv.nyc.gov/NYCServWeb/NYCSERVMain"
        delay 5
        beep 2
        tell application "System Events"
            repeat with CounterA from 1 to 10
                keystroke tab
                delay 0.5
            end repeat
            keystroke return
        end tell
    end tell
    It is a bit rough, but it works on my system (Mac OS X 10.4.11, G5, Safari 4.1.3).
    The intial delay of 5 seconds is to give the page a chance to load - you might need to increase that. The 2 beeps are to give an audible indication of when the rest of the script starts so, if the page hasn't fully loaded, then you know to increase the delay by a few more seconds. (There is a way of somehow checking the page and/or its contents so that the rest of the script will start only once the page has "settled down". I don't know how to do that, but it would make the delay unnecessary and removes the problem of a slow connection taking longer to load the page than normal.)
    The repeat loop sends the tab keystroke 10 times - on my system that's how many presses of the tab key it took to move the "focus" from the URL to the Go button after the "Parking/Red Light..." button. The return keystroke selects that Go button (same as clicking on it), which should then take you to the next page. The 1/2 second delays are there so you can see where things are moving.
    That's as far as I got. Hopefully it will give you a start. You might need to experiment a fair bit to find out if your version of Safari behaves the same way with emulated key-presses using the keystroke command in AppleScript (done from within System Events). When I sent 9 tabs instead of 10 (so that the "Parking/Red Light..." button is highlighted, sending the down arrow keystroke ( keystroke (ASCII character 31) ) made the drop-down menu appear.
    Sorry I can't give more info, but this should get you going. There are probably much better, more reliable and more efficient ways of doing this but sometimes the quick-and-dirty methods fit the bill enough to do the job.

  • How to use Applescript to print out a certain calendar at 7am every morning?

    Hey guys,
    I am trying to use AppleScript to print out one of my calendars each day at 7am every morning.
    I have come up with this so far:
    tell application "Calendar"
           view calendar "My Appointments" at (my (current date))
           switch view to day view
           activate
                        tell application "System Events"
                     keystroke "p" using command down
                     delay 1 -- (seconds)
                     tell process "Calendar"
                                                      tell window "Print"
                                                                     if value of checkbox "Calendar Keys" is not 0 then
                                      click checkbox "Calendar Keys"
                               end if
                                                      end tell
                                       end tell
                        end tell
    end tell
    The problem with this is that it will print out whatever calendars are currently viewable. I can't figure out how to tell it to deselect other calendars and just select the one I want. I also want to tell it to print this out at 7am every morning.
    Any help would be very appreciated!

    If you wanted to do the printout over multiple days, you would be best to loop through each day's events in the way the current script does, but to put a new loop around it that gets each new day's data:
    --opens a temporary file
    set fileRef to open for access ((path to desktop) as string) & "meetings.txt" with write permission
    --effectively empties the file
    set eof fileRef to 0
    tell application "Calendar"
              set dayCount to 9 --this will be the number of days to look forward (not including today)
              repeat with currentDay from 0 to dayCount
                        set startList to {}
      --get's today's date
      --set startRange to ((current date) + 12 * days) -- I used this for testing, to point to a day that had many appointments.  I've left it so you can use it, too.
                        set startRange to ((current date) + (currentDay * days))
      --set the start of the range to previous midnight
                        set hours of startRange to 0
                        set minutes of startRange to 0
                        set seconds of startRange to 0
      --set end of the range to next midnight
                        set endRange to (startRange + 1 * days)
      --get today's events
                        set todaysEvents to get (events of calendar "My Appointments" whose (start date is greater than startRange) and (end date is less than endRange))
      --make a new list with start time of the event for sort purposes
                        repeat with theEvent in todaysEvents
                                  set end of startList to {startdate:start date of theEvent, eventID:theEvent}
                        end repeat
      --sort using a bubble sort (suitable for short lists)
                        repeat with i from 1 to (count of startList) - 1
                                  repeat with j from i + 1 to count of startList
                                            if startdate of item j of startList < startdate of item i of startList then
                                                      set temp to item i of startList
                                                      set item i of startList to item j of startList
                                                      set item j of startList to temp
                                            end if
                                  end repeat
                        end repeat
      --empty the original list
                        set todaysEvents to {}
      --repopulate the list in correct chronological order
                        repeat with theEvent in startList
                                  set end of todaysEvents to eventID of theEvent
                        end repeat
      --write today's date to the file
      write (date string of startRange & return & return) to fileRef
      --if there are no events, write this to the file as well
                        if length of todaysEvents is 0 then
                                  write "No events" & return & return to fileRef
                        else
      --process each event into format: hh:mm-hh:mm/new line/event summary
                                  repeat with theEvent in todaysEvents
                                            set startdate to start date of theEvent
                                            set enddate to end date of theEvent
                                            set startHours to hours of startdate as string
                                            if length of startHours is 1 then set startHours to "0" & startHours
                                            set startMins to minutes of startdate as string
                                            if length of startMins is 1 then set startMins to "0" & startMins
                                            set starttime to startHours & ":" & startMins
                                            set endHours to hours of enddate as string
                                            if length of endHours is 1 then set endHours to "0" & endHours
                                            set endMins to minutes of enddate as string
                                            if length of endMins is 1 then set endMins to "0" & endMins
                                            set endTime to endHours & ":" & endMins
      --write the event to the file
                                            set theSummary to (starttime & "-" & endTime & return & summary of theEvent & return & return) as string
      write theSummary to fileRef
                                  end repeat
                        end if
      write return to fileRef
              end repeat
    end tell
    --close the file
    close access fileRef
    --print the file
    set theFile to (((path to desktop) as text) & "meetings.txt") as alias
    tell application "TextEdit"
              print theFile without print dialog
    end tell

  • 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.

  • ICal and subscribed calendars with MobileMe using AppleScript

    I am having the same problem as many of you; I have a MobileMe account which does not sync the calendars I have in iCal that are subscriptions. I found this great script online which I'll post below. I don't know anything about AppleScript so I'm just copy-pasting. I want it to work, but I'm getting the error "The variable theOldEvent is not defined." right around the line "if similar_found is true then set theOldSummary to the summary of theOldEvent" kinda near the middle. Like I said, I don't know anything about AppleScript. So my question is; how can I fix this error and/or is there some better way of using AppleScript/Automator to do this same thing? Thanks!
    Script to duplicate Calendar orgCalendar into target dupCalendar
    E.H. 12.9.2008
    property myCopies : 0
    property myUpdates : 0
    property myObsoletes : 0
    property orgCalendar : "Sekretariat"
    property dupCalendar : "Sekretariat copy"
    property dupEvents : {}
    property myDeletes : {}
    set myCopies to 0
    set myUpdates to 0
    set myObsoletes to 0
    set dupEvents to {}
    tell application "iCal"
    -- set theCalendars to every calendar
    set theCalendarNames to title of every calendar
    set theOrgCalendar to a reference to calendar orgCalendar
    if theCalendarNames contains dupCalendar then
    set theCalendar to a reference to calendar dupCalendar
    else
    set theCalendar to make new calendar with properties {title:dupCalendar}
    --set theCalendar to make new calendar with properties {title:dupCalendar, color:"{65535, 0, 0}"}
    end if
    set the eventList to uid of every event of theOrgCalendar as list
    set the eventCount to the count of the eventList
    repeat with theUId in eventList
    tell theOrgCalendar
    set theEvent to (the first event whose uid is theUId)
    -- set theProperties to the properties of theEvent as record
    set theDate to the start date of theEvent
    set theSummary to the summary of theEvent
    set theStampDate to the stamp date of theEvent
    end tell
    tell theCalendar
    try
    set theOldEvent to (the first event of theCalendar whose (start date) is theDate as date)
    set similar_found to true
    on error
    set similar_found to false
    set theEndDate to the end date of theEvent
    set theAllDay to the allday event of theEvent
    set theLocation to the location of theEvent
    -- Funny construction to work araund the fact that location may be missing a value
    try
    if theLocation is equal to "" then
    end if
    on error
    set theLocation to ""
    end try
    set theDescription to the description of theEvent
    try
    if theDescription is equal to "" then
    end if
    on error
    set theDescription to ""
    end try
    if theAllDay is true then -- work around a funny bug with all day events
    set theDate to (theDate as date) + 2 * hours
    set theEndDate to (theEndDate as date) + 2 * hours
    end if
    set newEvent to make new event at end with properties {summary:theSummary, location:theLocation, start date:theDate, end date:theEndDate, allday event:theAllDay, description:theDescription}
    -- make new event at end with properties theProperties
    set the end of dupEvents to (the uid of newEvent)
    set myCopies to (myCopies + 1)
    end try
    end tell
    set second_necessary to false
    if similar_found is true then
    set theOldSummary to the summary of theOldEvent
    if theSummary is not equal to theOldSummary then
    --is there a different one?
    try
    set theOldEvent1 to (the second event of theCalendar whose (start date) is theDate as date)
    set theOldSummary to the summary of theOldEvent1
    if theSummary is equal to theOldSummary then
    set theOldEvent to theOldEvent1
    set the end of dupEvents to (the uid of theOldEvent)
    else
    -- cycle repeat ?
    end if
    on error
    -- beep
    try
    set theEvent1 to (the second event of theOrgCalendar whose (start date) is theDate as date)
    set second_necessary to true
    on error
    set the end of dupEvents to (the uid of theOldEvent)
    end try
    end try
    else
    set the end of dupEvents to (the uid of theOldEvent)
    end if
    if second_necessary is true then
    set theEndDate to the end date of theEvent
    tell theCalendar
    set theOldEvent to make new event at end with properties {summary:theSummary, start date:theDate, end date:theEndDate}
    end tell
    set the end of dupEvents to (the uid of theOldEvent)
    end if
    set theOldStampDate to the stamp date of theOldEvent
    if theStampDate is greater than theOldStampDate then
    -- update the event
    set summary of theOldEvent to theSummary -- capitalization may have changed
    set theAllDay to the allday event of theEvent
    set allday event of theOldEvent to theAllDay
    set theEndDate to the end date of theEvent
    if theAllDay is true then -- work around a funny bug with all day events
    set theEndDate to (theEndDate as date) + 2 * hours
    end if
    set end date of theOldEvent to theEndDate
    set theDescription to the description of theEvent
    try
    if theDescription is equal to "" then
    end if
    on error
    set theDescription to ""
    end try
    set description of theOldEvent to theDescription
    set myUpdates to myUpdates + 1
    end if
    end if
    end repeat
    end tell
    -- Delete obsolete events
    set myObsoletes to 0
    set myDeletes to {}
    tell application "iCal"
    set myUIDs to uid of events of theCalendar
    end tell
    repeat with myUID in myUIDs
    if dupEvents does not contain myUID then
    set the end of myDeletes to myUID
    set myObsoletes to (myObsoletes + 1)
    end if
    end repeat
    tell application "iCal"
    repeat with myDel in myDeletes
    delete (every event of theCalendar whose uid is myDel)
    end repeat
    end tell
    -- delete duplicates
    set myDeletes to {}
    tell application "iCal"
    set myStarts to start date of events of theCalendar
    set mySummaries to summary of events of theCalendar
    set myUIDs to uid of events of theCalendar
    set myLength to length of myUIDs
    end tell
    repeat with i from 1 to (myLength - 1)
    set thisStart to (item i of myStarts)
    set thisSumm to (item i of mySummaries)
    repeat with j from (i + 1) to myLength
    set thatStart to (item j of myStarts)
    set thatSumm to (item j of mySummaries)
    if thisSumm is equal to thatSumm and thisStart is equal to thatStart then
    set the end of myDeletes to (item j of myUIDs)
    exit repeat
    end if
    end repeat
    end repeat
    set n to count of myDeletes
    tell application "iCal"
    repeat with myDel in myDeletes
    delete (every event of theCalendar whose uid is myDel)
    end repeat
    -- set the visible of calendar theCalendar to false
    end tell
    display dialog (myCopies & " records duplicated, " & myUpdates & " records updated and " & myObsoletes & " obsolete ones deleted") as text

    No longer an issue.

  • Pages '09: Can't use AppleScript for selected text inside tables?

    When I run get selection on selected text in a Pages document, I get something like this:
    <pre>text from character 1 to character 4 of body text of document id 9943974 of application "Pages"</pre>
    When I run get selection on selected text inside a table cell in a table in a Pages document, I get something like this:
    <pre>text from character 1 to character 4 of some table of document id 3539679 of application "Pages"</pre>
    When I run get selection on selected text inside a table cell in ANOTHER table in the same Pages document, I get the exact same thing. It still says "some" table. So there is no way to distinguish between tables if there are more than one table in the same Pages document.
    Am I correct in understanding that this means that most AppleScript commands for manipulating text are unusable inside table cells?
    For example, it seems impossible to get the properties of the selection when the selection is selected text inside "some" table. So it's impossible do anything about text styles, etc.
    Is AppleScript support in Pages ’09 really that limited, or am I missing something?

    The first script below should return the character style of any selection made in Pages ’09, whereas the second script should apply the "XXX" character style to any selection:
    --BEGINNING OF SCRIPT 1
    tell application "Pages"
    activate
    tell application "System Events" to tell process "Pages"
    -- Show the format bar:
    if not (pop up button 1 of window 1 exists) then
    click menu item "Show Format Bar" of menu 1 of menu bar item "View" of menu bar 1
    end if
    -- Show the styles drawer and character styles:
    if menu item "Show Styles Drawer" of menu 1 of menu bar item "View" of menu bar 1 exists then
    keystroke "t" using {shift down, command down}
    end if
    tell front window
    tell checkbox 1 of group 1 of drawer 1 -- “Show or hide character styles.” checkbox
    repeat until it exists
    delay 0.1 -- wait until the styles drawer is open
    end repeat
    if description is "show character style" then click
    end tell
    -- Get the row index (although it is not a property) of the character style:
    tell menu button 2 -- “Choose a character style.” menu button
    click
    set k to 0
    repeat
    set k to k + 1
    if value of attribute "AXMenuItemMarkChar" of menu item k of menu 1 exists then exit repeat
    end repeat
    keystroke return -- hide the menu
    end tell
    -- Get the character style name:
    if k > 1 then set k to k + 1
    value of static text 1 of row k of outline 1 of scroll area 2 of splitter group 1 of group 1 of drawer 1
    end tell
    end tell
    end tell
    --END OF SCRIPT 1
    --BEGINNING OF SCRIPT 2
    set myStyle to "XXX" -- the name of the character style you want to apply
    tell application "Pages"
    activate
    tell application "System Events" to tell process "Pages"
    -- Show the format bar:
    if not (pop up button 1 of window 1 exists) then
    click menu item "Show Format Bar" of menu 1 of menu bar item "View" of menu bar 1
    end if
    -- Show the styles drawer and character styles:
    if menu item "Show Styles Drawer" of menu 1 of menu bar item "View" of menu bar 1 exists then
    keystroke "t" using {shift down, command down}
    end if
    tell front window
    tell checkbox 1 of group 1 of drawer 1 -- “Show or hide character styles.” checkbox
    repeat until it exists
    delay 0.1 -- wait until the styles drawer is open
    end repeat
    if description is "show character style" then click
    end tell
    set characterStyles to value of static text 1 of rows of outline 1 of scroll area 2 of splitter group 1 of group 1 of drawer 1
    set k to 0
    repeat with thisStyle in the characterStyles
    set k to k + 1
    if thisStyle as text is myStyle then exit repeat
    end repeat
    -- Apply the character style:
    if k > 1 then set k to k - 1
    click menu button 2 -- “Choose a character style.” menu button
    click menu item k of menu 1 of menu button 2
    end tell
    end tell
    end tell
    --END OF SCRIPT 2
    I suppose that +paragraph styles+ should work the same.
    I'm beginning to know Pages ’09 a little better now.
    Message was edited by: Pierre L. (show format bar)

  • How to update popup (drop down) cells in Numbers using Applescript

    I understand that the list popups (dropdown lists in cells) cannot be dynamic in Numbers.
    I have the same dropdown list in multiple cells and tables, and this list often needs to be changed. Its not practical to amend one list, then copy/paste it into 200 plus cells that require the dropdown facility (they are not in sequential rows).
    Can Applescript be used to do the copy/paste function, as i could specify the cell ranges. My simple attempt only managed to copy/paste the cell values rather than the dropdown/popup list.
    Any constructive help would be appreciated.
    Thanks.

    Hi Hiroto,
    I have this script running, with one issue.
    set tValues to my doThis(1) -- get values of the selection
    if tValues is not "" then
      activate
              display dialog "Select the cells where you want to create the PopUp." & return & "After that, click on the 'OK' button."
              my doThis(tValues) -- set the cell format of the new selection to "PopUp Menu" and set the values of the each menu item
              tell application "Numbers" to display dialog "Done"
    else
              tell application "Numbers" to display dialog "You must select the cells in a table before running this script."
    end if
    on doThis(n)
              tell application "Numbers"
                        set tTables to (tables of sheets of front document whose its selection range isnot missing value)
                        repeat with t in tTables -- t is a list of tables of a sheet
                                  if contents of t is not {} then -- this list is not empty, it's the selected sheet
                                            set activeTable to (get item 1 of t)
                                            if n = 1 then return value of cells of selection range of activeTable-- return values of the selection
                                            set format of (cells of selection range of activeTable) to pop up menu -- set the format to pop up menu
                                            return my setValuePopUp(n) -- set value of each menu item
                                  end if
                        end repeat
              end tell
              return ""
    end doThis
    on setValuePopUp(L)
              tell application "System Events"
                        tell process "Numbers"
                                  set frontmost to true
                                  delay 0.3
                                  set inspectorWindow to missing value
                                  set tWindows to windows whose subrole is "AXFloatingWindow"
                                  repeat with i in tWindows
                                            if exists radio group 1 of i then
                                                      set inspectorWindow to i
                                                      exit repeat
                                            end if
                                  end repeat
                                  if inspectorWindow is missing value then
      keystroke "i" using {option down, command down} -- Show Inspector
                                  else
      perform action "AXRaise" of inspectorWindow -- raise the Inspector window to the front
                                  end if
                                  delay 0.3
                                  tell window 1
      click radio button 4 of radio group 1 -- the "cell format" tab
                                            delay 0.3
                                            tell group 2 of group 1
                                                      set tTable to table 1 of scroll area 1
                                                      set tc to count rows of tTable
                                                      set lenL to (count L)
                                                      if tc < lenL then -- ** add menu items **
                                                                repeat until (count rows of tTable) = lenL
      click button 1 -- button [+]
                                                                end repeat
      keystroke return -- validate the default name of the last menu item
                                                      else if tc > lenL then -- ** remove menu items **
                                                                repeat while exists row (lenL + 1) of tTable
                                                                          select row (lenL + 1) of tTable
      click button 2 --  button [-]
                                                                end repeat
                                                      end if
                                                      tell tTable to repeat with i from 1 to lenL -- ** change value of each menu item **
                                                                set value of text field 1 of row i to item i of L
                                                      end repeat
                                            end tell
                                  end tell
                        end tell
              end tell
    end setValuePopUp
    ==============================
    When the popup is created, if there is one header row, it adds "1" to the list of popup items, if there are two header rows, it adds "1", "2" to the list of popup items. What should i amend to remove this (i have two header rows in my sheet).
    I would ideally like to add a "-" to the list (to represent nothing selected in the cell) as default i.e. top of the list (i could add the symbol to my source data but that would look untidy). At the moment, after running the script all cell values change to 1.
    Oh, what would the best way to modify the script so it selects a specific cell range? At the moment i have to first select a column, then run the script, then select the source cells, then click ok on the dialog box before it does the magic.
    Someone else will be running the script, and if its easy to change, i would prefer to have an absolute source cell range values so the user can just rund the script without any selection required.
    If you can advise on this, that would be most helpful.

  • Using applescript to open a folder with a keyboard shortcut

    hello -
    i have a rather simple question (probably). is there a way using applescript to create a keyboard command to open a folder? i.e. command shift a opens the applications folder and command shift u opens utilities. can i use applescript to designate a keyboard command to open a folder i have created? also, the script editor does not have to be open for me to utilize scripts, correct?
    thanks for your patience with a newbie.

    You can't make a keyboard shortcut to run a specific application from OSX, although there are third party applications such as Quicksilver that can do things like that. You can use an AppleScript to activate an existing menu item, for example:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "Finder" to activate
    tell application "System Events" to tell application process "Finder"
    keystroke "A" using {shift down, command down}
    end tell</pre>
    Other alternatives to keyboard shortcuts are to use the Scripts Menu or add an application to the Finder's toolbar. The Script Editor does not need to be active to use scripts.

  • 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!

Maybe you are looking for

  • How can I convert from color balance in FCE to color balance in FCPX?

    Let me start off by saying that I've been having an issue with a project in Final Cut Express - a project I'd put a lot of time into and thought I was finished with. Before continuing on, I encourage you to take a look at my other thread: https://dis

  • Camera raw doesn't open when opening a raw file in photoshop

    I have a mac mini and am using the latest version of lightroom and have an EOS70d. The problem I experience is that when I open a raw file from lightroom it goes directly into photoshop without launching the camera raw plugin and when I manually laun

  • JAVA GUI window content does not fill out when window is enlarged (Win,Mac)

    I've been using the SAP JAVA GUI on a Windows XP workstation as well as a couple of MacBooks running OS X over the last year and a half or so, running versions from 7.10 r 7(maybe earlier) thru 7.10 r 10 (installed today.) The GUI has performed gener

  • Gmail compose - command left/right still broken (Mac)

    This question was [https://support.mozilla.com/en-US/questions/767732 asked previously] , and was marked solved, but was never really solved. In the 'Compose mail' window of GMail the shortcut Command-left arrow or Command-right arrow to jump to resp

  • Icons disappear in Download stack fan

    When I fan out my downloads stack, the icons and file names do not appear. They appear in grid, but not fan. I have repaired permissions, restarted computer, but nothing works. How do I fix it?