AppleScript Help

Discussion in 'Mac Programming' started by rockstarpunched, Apr 24, 2018.

  1. rockstarpunched macrumors newbie

    Apr 24, 2018
    Hey guys, trying to play Fortnite but their toggle sprint sucks horribly. Was wondering if I could make a script that holds shift down when I press shift, then releases shift when I press shift again. Thanks in advance, hope I posted this in the correct thread as I'm new here (obviously). Also I have no programming background so will need explanations as if I'm 5 years old.
  2. superscape macrumors 6502a


    Feb 12, 2008
    East Riding of Yorkshire, UK
    I'm not sure I have time to talk you through it like a 5 year old, but here's the bare bones of an AppleScript:

    --make sure your target app has focus
    tell application "TextEdit"
    end tell
    tell application "System Events"
       repeat 10 times
           keystroke return
           delay 1 --optional delay between keystrokes
       end repeat
    end tell
    Start with a TextEdit document open - I've used TextEdit for this example since I don't have FortNite. I think the code is reasonably self explanatory.

    As far as I know, there's no way of making the shift key presses continue until the shift key is pressed a second time. However, the code above at least means you can do multiple keypresses with an optional delay.

    As a side note, many years ago (we're talking late 90s!) I had a job where I had to open a huge bunch of large Illustrator files simultaneously (it's a long story). Each one popped up a dialog when opened which needed the return key hitting to continue the opening process. Since I had no idea about scripting at the time, I selected all the files in Finder, dragged them onto Illustrator and wedged the return key down using two books and a banana, then went for my lunch. When I came back, all the files were open. Not all automation requires code! ;-)

    Good luck.

Share This Page