Applescript keystroke

I created a applescript to automatic fill the login information for a webpage. I made it four months ago and it works fine untill a month aprox. The problem is very wierd, It fills the first field, the username, using the command "keystroke" and it does but not in the right order.
My username is "rsolanilla" and it types "srolanilla" most of the times and other combinations much less often. It types ok some times too, but is quite random.
I use it into a automator application, but I tested from applescript and automator and the results are the same.
This is the part of code I talked about:
tell application "Safari"
    activate
    set thisDocument to make new document at end of documents
    do JavaScript "window.open('" & mainURL & "')" in thisDocument
    tell application "System Events"
        tell application process "Safari"
            delay 3
            -- keystroke (ASCII character 9) — tab character
           keystroke mainLogin
            --delay 1
            keystroke (ASCII character 9) -- tab character
            --delay 1
            keystroke mainPword
            keystroke (ASCII character 13) -- this equals return
        end tell
    end tell
end tell

Repost to
https://discussions.apple.com/community/mac_os/mac_os_x_technologies#/?tagSet=10 44

Similar Messages

  • Applescript keystroke problem

    I'm coding in applescript and whenever I run a keystroke command it types it into the script window instead of the application i activate.
    tell application "--app--"
         activate
    end tell
    tell application "System Events"
         keystroke "--whatever text--"
    end tell
    whenever i do anything if this sort, it opens the application but then reverts to the applescript editor and types the text in that window instead of the activated application.
    If the app is already open it works fine.

    nevermind
    nooby problem
    figured it out

  • How do I use AppleScript keystroke command as a speakable item?

    I am attempting to do what I thought was a rather simple task, but have not had success.
    I would like to use the following script as a voice command to speak selected text in a file, opened for example by Preview, when the key is pressed.
    tell application "System Events" to keystroke "." using control down
    I have placed the script application in the System Preferences, Speech, Speakable Items Folder.  The item is being recognized; however, it appears that it is not functioning in the correct window context.  I would like this to work regardless of the application text (hence the Text to Speech option).  How do I set this up before the keystroke command in the script?
    As an aside, is there a way to convert a script file to a SpeakableItems.app document file?

    I am not sure if this is what you are looking for.
    But have you saved the below workflow as a Service and use a keyboad shortcut?
    I have this as a Service and my keyboard short cut is Command-Shift T.
    Once I select a paragraph in Preview and press the short cut it speaks the text for me.
    Maybe you already thought of this. But here you go.

  • AppleScript-Droplet: convert image to monochrome / grayscale / black&white

    Hello,
    i am used to applescript itself and now willing to write me a small droplet which converts dropped images (jpg & png) to grayscale images.
    right now i am wondering which might be the best application i could use for that ?
    First ideas was ImageMagick (somehow special ...macports) or Sips.
    Is there any chance that i can use a more usual application like Preview from applescript to do the convert task ?
    any ideas ?
    Best regards
    fidel

    Hi Piere,
    that looks great - i added the applescript/keystroke part for save & quit and the result is perfect for my needs.
    My mistake was to just check the offered options in automator - ignoring the keystroke possibilities.
    Thanks once again
    Best regards
    fidel
    code:
    on open droppedImages
    tell application "Preview"
    activate
    repeat with currentImage in droppedImages
    open currentImage
    tell application "System Events"
    keystroke "c" using {option down, command down}
    tell process "Preview"
    set value of value indicator 1 of slider 2 of window 1 to 0
    -- other image modifications are possible here
    end tell
    end tell
    end repeat
    tell application "System Events" to tell process "Preview" to click button 1 of window 1
    -- save
    tell application "System Events"
    keystroke "s" using command down
    end tell
    -- quit preview
    quit
    end tell
    end open

  • Junk email addresses appearing in address book

    For some reason I have tons of junk email addresses appearing in my Mail address -- I have no idea how they got there. Here are just two examples, there are hundreds:
    Alexis Eldridge
    [email protected]
    or
    Gallo Poole
    [email protected]
    Does anyone know why this is happening and how to prevent it? Thanks!

    Well, yes, maybe. I'm a little paranoid -- I download in the regular user account, scan with clamxav, drop the scanned download into the admin dropbox, fast-user-switch to the admin account, move the download to an "installers" folder that I maintain, and install from the admin account. Log out and back in to the standard account. I guess, yeah, if you are doing forty separate software updates and upgrades every day, a process like mine is a little problematic. On the other hand, the Applications folder isn't writeable from a standard user account without authenticating as an administratively privileged user and I just don't do that.
    Actually, that may not quite be true. Although I don't operate that way, you could probably install from the standard user account by authenticating the installer as an admin user from within the standard user account. That kind of defeats the purpose, anyways, if the standard user account has been compromised by a hidden applescript keystroke logger or something, if such thing were to exist.
    Having a separate administrator and standard user account are a trade-off that you have to decide upon: are the added safety and security practices worth a loss of user experience convenience? Once you figure out, if you are able to figure out, how your Address Book started getting loaded up with rogue email addresses, you might be better able to make that determination for your own situation. Page 33 of the snow leopard security guide (http://images.apple.com/support/security/guides/docs/SnowLeopardSecurity_Configv10.6.pdf) recommends having separate administrator and daily use accounts. But, in the end, that's your call. The guide tells you how to lock your computer down so tightly that it's almost worthless.
    With regards to anti-malware, your best bet is to see what respected sites like macworld and others have to say, and just do some google searches. I'm in no position to make a recommendation. With clamxav, which is what I use, the price is right but I can't say how proactive a freeware/donationware anti-malware entity might be when that new occasional Mac malware comes out.
    While I have suggested you performing an anti-MacMalware scan, that may or may not resolve your issue, and offer up some thoughts on future operating practices that really don't help you now, I can only wish you good luck on solving your AddressBook problem. Please post back when you do, I'm sure everyone here would like to be made aware of what and how it happened, and what they can do to do to prevent it.

  • How to use the keystroke feature of applescript?

    I am trying to use the keystroke feature of Applescript.
    On page 200 of "Mac OSX Panther edition The Missing Manual" shows the following example (to select all of a document):
    keystroke "a" using (command down)
    I tried to use this with keystroke "o" and got the message that "using" can't be used this way. Where can I find a few examples of how to use this feature in Applescript? I particularly want to use keystrokes to copy rulers in Appleworks. The keystrokes to do this are "shift-command-v".
    Thanks for comments.

    While I agree with Hiroto as to how to implement 'AppleWorks 6's 'Format, Rules, Copy Ruler' ('Command <shift> C) sub-menu item selection, below is an example of performing the same action using 'keystroke'.
    tell application "AppleWorks 6" to activate
    tell application "System Events" to keystroke "c" using command down & shift down
    Below is an example of performing 'AppleWorks 6's 'Format, Rules, Apply Ruler' ('Command <shift> V) sub-menu item selection using 'keystroke'.
    tell application "AppleWorks 6" to activate
    tell application "System Events" to keystroke "v" using command down & shift down
      Mac OS X (10.4.4)  

  • Applescript help - keystroke part does not work

    Hi guys, I'm new to Applescript and would like some assistance. I have an application called iVPN that I would like to start with some applescript code - just one problem in that it requires the admin password at startup.
    I tried the following, but once the dialogue box appears to enter the password, nothing happens. It seems to stop just before the "delay 10" line. I've also tried it with just the keystroke line, but nothing happens (no password appears in the dialogue box that pops up).
    Any help greatly appreciated, Thanks!.
    tell application "iVPN" to open
    tell application "System Events"
    delay 10
    key code 48 using {command down}
    keystroke "password here"
    key code 36
    end tell

    I had you download the wrong file.
    The new name is XTool-2.0.dmg.tgz Notice the missing src.
    I simplified the example applescript file. You need to write your applescript file as needed.
    The basic plan for you is to move the mouse to the button then click the button.
    --Move mouse to input field.
    move mouse {100, 10} 
    click mouse
    --fill in the data.
    --move mouse & click button
    move mouse {120, 10} 
    click mouse
    Robert
       First, there is the XTools scripting addition, which will give AppleScript the ability to move the mouse. 
       Dowload from:
          http://www.lestang.org/osax/XTool/
       click on:
          XTool-2.0.dmg.tgz 
       Installation :
       Drag XTool.osax from insite the image to one of the following locations (create the directory if it does not exist) :
       a : ~/Library/ScriptingAdditions/
       b : /Library/ScriptingAdditions/
       c : /System/Library/ScriptingAdditions/
       I have it in directory /System/Library/ScriptingAdditions/ 
       My other two directories do not exit: ~/Library/ScriptingAdditions/ & 
          /Library/ScriptingAdditions/
       see download file XTool ReadMe.rtf for documentation
    log "  --- Starting on " & ((current date) as string) & " --- "
    set {x, y} to position of the mouse
    display dialog "mouse at " & x & " " & y giving up after 3
    display dialog "Move mouse to where you want to find coordinates, you have five seconds." giving up after 5
    set {x, y} to position of the mouse
    beep
    display dialog "New mouse position at " & x & " " & y giving up after 5
    -- Go after time message
    move mouse {10, 10}
    delay 5
    -- click mouse
    -- center mouse
    -- find the size of the display with a unix command
    do shell script "/usr/sbin/system_profiler SPDisplaysDataType | grep 'Resolution'" -- get info
    tell the result to set {DisplayWidth, DisplayHeight} to {word 2, word 4} -- get resolution
    move mouse {DisplayWidth div 2, DisplayHeight div 2} -- center mouse
    Message was edited by: rccharles

  • Run applescript on keystroke

    I have a script which I would like to invoke at will via keystrokes. Is there a simple way to do this with or without (preferably without) using third-party programs? My specific application involves a script that moves messages in Mail. Thanks!

    You appear to expect 'System Preferences' 'Keyboard & Mouse's 'Keyboard Shortcuts' to perform as a 'launcher' application. It is not. It is used to (re)assign menu item keyboard equivalents, and nothing else.
    To launch an application or AppleScript script (or applet) consider 'QuicKeys' (commercial)*, 'Butler' (freeware)*, and / or 'Spark' (freeware), to name a few. Other launchers, other links'.
    * - I personally use and like.

  • Applescript for Repeated Keystroke

    Hey Everyone,
    First, I'm brand new to Applescript, so this may be a very obvious answer.
    I want to create a script that will enter the keystrokes "enter, tab, tab, command+V, enter, down" repeatedly, or for a certain amount of times.  I'm basically looking for a way to automate some copy/paste data entry.
    Thanks for any help you can offer!

    AppleScript is a programming language that is tied to certain Applications that support it. Pages v5.5.1 has a scripting dictionary of the terms it will support via AppleScript. Apple's answer to not including Mail Merge functionality in Pages v5.5.1 is for individual users to roll their own, download an example and adapt it, or use another application with built-in Mail merge features.
    See my previous post to you.

  • Applescript Chrome Keystroke switch windows

    Hi guys,
    maybe someone can help me to complete this command. I´m going crazy....
    I Have 2 Chrome windows and i want to switch the active focus between them by pressing the following keys:
    cmd + shift + `  ( ` = shift + ´ )
    I m tryinig to do this command by using the applescript keytroke command. But i do not find the error..... it won t work
    tell application "System Events"
    -- switch window focus
    keystroke "´" using {command down, shift down}
    end tell
    Thank you for your help !

    Thx for response.
    i tried this code, but it only refreshes 1 of the two open chrome windows. The crazy Party is, that at window open script the swith between the two open windows is working ...... I give you my open Chrome Browser with 2 windows on different screens in fullscreen Mode script and my Browser refresh script. May you have a better look with the complete code.... i m frustrated
    refresh of the two Browser windows
    repeat 2 times
        tell application "Google Chrome"
            set index of window 2 to 1
        end tell
        tell application "System Events"
            keystroke "r" using {command down}
        end tell
        tell application "System Events" to delay 5
    end repeat
    Open 2 Browser windows on different Screens
    tell application "System Events" to delay 5
    tell application "Google Chrome"
        --Open new Window on Position
        --List item 1: {72, b,c ,d }
        --The distance in pixels from the left side of the screen to the left side of the Finder window.
        --List item 2: {a, 90, c, d}
        --The distance in pixels from the top of the screen to the top of the Finder window.
        --List item 3: {a, b, 512, d}
        --The distance in pixels from the left side of the screen to the right side of the Finder window.
        --List item 4: {a, b, c, 481}
        --The distance in pixels from the top of the screen to the bottom of the Finder window.
        set aWin to make new window with properties {mode:"normal", bounds:{0, 0, 1000, 1000}}
        tell window 1
            set URL of active tab to "http://www.apple.com"
        end tell
        --Set Fokus on 2nd Window and close
        tell application "Google Chrome"
            set index of window 2 to 1
        end tell
        tell window 1 to close
        tell application "System Events" to delay 7
        set aWin to make new window [1] with properties {mode:"normal", bounds:{1082, 0, 1800, 1000}}
        tell window 1
            set URL of active tab to "http://www.macrumors.com"
        end tell
        tell application "System Events" to delay 10
        tell application "System Events" to tell process "Google Chrome"
            perform action "AXRaise" of window 1
        end tell
    end tell
    --Make Them Fullscreen
    repeat 2 times
        tell application "Google Chrome"
            set index of window 2 to 1
        end tell
        tell application "System Events" to tell process "Google Chrome"
            perform action "AXRaise" of window 1
        end tell
        tell application "System Events"
            keystroke "f" using {command down, shift down}
        end tell
        tell application "System Events" to delay 5
    end repeat

  • Applescript: how to script keystrokes?

    Hello, I am trying to use Applescript to 'clear browsing data' in Chrome.  I'm trying to emulate clicking command-shift-delete to bring up the frame showing the browser clearing options, and then tab-return to click the button. When manually using these keystrokes it works perfetly.  However, I copied some script from this forum and modified it as follows, and can't get it to work:
    tell application "Google Chrome" to activate
    tell application "System Events"
       key code 13 using {command down, option down}
       delay 0.55
       key code 45 using {command down}
       delay 0.55
    end tell
    tell application "Google Chrome"
       tell first window
           set bounds to {0, 0, 1280, 800}
       end tell
    end tell
    tell application "System Events"
       key code 51 using {command down, shift down}
       key code 48
       key code 76
    end tell
    I also tried substituting "keystroke tab" and "keystroke return" for the last 2 key codes above.  Any help with this will be greatly appreciated.

    I don't really know what the first part of your script is intended to do, but focusing on the issue you describe, I think you just need a delay to allow the frame to be displayed:
    tell application "Google Chrome" to activate
    tell application "System Events"
      key code 51 using {command down, shift down}
      delay 1
      key code 48
      key code 76
    end tell

  • Applescript: system events keystroke to background?

    Is there a way to make system events send a keystroke to an application that is in the background (already running no need for activation) without bringing it to the foreground?
    i've looked in several places and can't find a way to do this.

    Sending keystrokes is just imitating what a user can do/does on the keyboard. You can no more send a keystroke to an app via System Events that isn't the front and active application than you can type text into a window that is in the background.
    The only way to deal with apps that aren't active is to script them directly. If they're not applescript-able, consider whether you can do it with a bash or python script instead.

  • Applescript repeat keystroke

    How do i make it so this will repeat automatically forever until i stop it manually?
    set L1 to "1"
    set L2 to "2"
    tell application "Safari" to activate
    tell application "System Events" to tell process "Safari"
    keystroke L1
    delay 2
    keystroke L2
    end tell

    Camelot - I thought the same (as you); but, followed 'to the letter' the originator's request.
    'loo[' - thank you. Nice to know others, on occasion, strike an incorrect key ...

  • Applescript assistance keystroke command

    Hi guys,
    I have written this script but for some reason the like keystroke command w does not work as in it doesn't close the eye tv window. Is there somthing that I have missed. I dont want to quit the app but just close its windows.
    if application "EyeTV" is running then
              tell application "Finder"
                        set visible of process "EyeTV" to true
              end tell
              tell application "System Events"
                        tell application "EyeTV" to activate
                             keystroke "W" using command down
                  end tell
              tell application "Finder"
                        set visible of process "EyeTV" to false
              end tell
    end if
    tell application "XBMC"
      activate
    end tell

    try this:
    if application "EyeTV" is running then
              tell application "System Events"
                        tell process "EyeTV"
                                  set visible to true
                                  set frontmost to true
                                            keystroke "W" using command down
                                  set visible to false
                        end tell
              end tell
    end if
    tell application "XBMC"
      activate
    end tell
    your use of tell blocks was overly complex.

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

Maybe you are looking for

  • Help!!! Ipod touch problems. PLEASE Help!!!!

    Hey guys, I've been having some trouble with my Ipod i just got. I have a friend who just pick up an Iphone and didn't need his anymore. So I picked it up from him. It was working fine at his house and last night. I was trying to sync my music to it

  • Default value for variable are not within permitted value range (precalc)

    Hello BW community Issue: I have created a variable (Characteristic Value/ Manual input-default value) and use the precalculated value set (details-basic settings). In the further variable definition I could select the  precalculated value set in 'De

  • Video no longer plays on iPad 2 with iOS 8.3

    I used to watch videos using the Apple Trailers app, YouTube, CBS and ABC apps.  After the iOS 8.3 update, none of them will play videos anymore.  They all basically indicate they cannot connect to the source server.  Some of them even state my iPad

  • Disappearing Hard Drive Space After Yosemite Update

    After installing OS X Yosemite my hard drive space has dwindled to basically nothing, rendering my computer useless.  I had at least 50 gb (maybe more) of hard drive space before updating from mavericks to yosemite.  Now, after using my computer for

  • Unsharp Mask

    I have Photoshop Elements 10 on my Mac Mini, and the unsharp mask feature, which originally worked fine, no longer works. When you click on it all you get is a little square that replaces the curser and doesn't do anything, while most of the menu bar