AppleScript key code

https://eastmanreference.com/complete-list-of-applescript-key-codes

tell application "System Events"
  key code 49
end tell


    Play: tell application "iTunes" to play
    Pause: tell application "iTunes" to pause
    Rewind (previous track): tell application "iTunes" to previous track
    Fast forward (next track): tell application "iTunes" to next track

If you’re using something other than iTunes, you can still try the above. Just substitute “iTunes” with the name of the app. Depending on how scriptable the app is, this may or may not work.

Mute, unmute, set and increment system volume like so:

    Mute: set volume with output muted
    Unmute: set volume without output muted
    Set volume to 100%: set volume output volume 100
    Set volume to 50%: set volume output volume 50
    Set volume to 1%: set volume 1

Make your system volume slowly fade out with this nifty little script. Adjust the “delay 0.2” bit in the middle of the loop to speed up or slow down the fade.

set a to output volume of (get volume settings)

repeat while a is not 0
  set a to (a - 1)
  delay 0.2
  set volume output volume a
end repeat
tell application "System Events" to keystroke "Abcde"
tell application "System Events"
  delay 0.5
  keystroke space using command down
  delay 0.5
  keystroke "Text"
  delay 0.5
  keystroke "Edit"
  delay 0.5
  keystroke return
  delay 1
  keystroke "Hello world!"
end tell
tell application "System Events"
  delay 0.5
  keystroke space using command down
 
  delay 0.5
  set textBuffer to "TextEdit"
  repeat with i from 1 to count characters of textBuffer
    keystroke (character i of textBuffer)
    delay 0.05
  end repeat
 
  delay 0.5
  keystroke return
 
  delay 1
  set textBuffer to "Hello world!"
  repeat with i from 1 to count characters of textBuffer
    keystroke (character i of textBuffer)
    delay 0.05
  end repeat
 	
end tell
posted @ 2023-04-07 12:38  fndefbwefsowpvqfx  阅读(110)  评论(0编辑  收藏  举报