Exactly what the title says...

I'm new to coding and I am trying to make AppleScript simulate the key press of LShift. When I run the program, there seems to be a delay, indicating that it may be actually pressing LShift, but I tried a virtual keyboard tester, and it does not indicate LShift being pressed... I am not sure how to make the program. Help would be greatly appreciated.


Edit: Basically, I want AppleScript to press Shift (on the left). I don't know what the coding for this part is.

This is my code so far:

       repeat 5 times
          tell application "System Events"
             keystroke "r"
             delay 5
          end tell
       end repeat
       repeat 10000 times
          tell application "System Events"
             keystroke using {shift down}
          end tell
       end repeat
    end repeat

I don't know whether pressing "keystroke using {shift down} actually is pressing shift.

  • Yes, I obviously searched Google...! I don't know how to press Shift, I full understand how to simulate the pressing of a letter. – ThatCoder Jan 25 '17 at 0:44
  • Sorry but is was not at all obviously you had done anything yet, until you posted some code! Unless you're focusing the System Events somewhere, then what's the purpose of what you're trying to do? – user3439894 Jan 25 '17 at 1:30
  • Well, that let down my hopes... Thanks for the information though! – ThatCoder Jan 25 '17 at 2:50

I think you want this

tell application "System Events"
    key code 56
end tell
  • Sorry, I'm kinda new to AppleScript... what does that mean? – ThatCoder Jan 25 '17 at 21:29
  • @ThatCoder, You're being told to replace keystroke using {shift down} with key code 56 as 56 is the key code for the left shift key. BTW I had already tested this while the question was on hold and couldn't see that it worked when I made the comment previously. I've since retested using the Keyboard Viewer and it does register albeit it happens so quick I couldn't see it on an application menu as a modifier key but could with the Keyboard Viewer that it's registering. That said though, I don't know what pressing the left shift key 1000 times is going to do for you, if anything! – user3439894 Jan 25 '17 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .