首页 > 其他分享 >AppleScript key code

AppleScript key code

时间:2023-04-07 12:57:55浏览次数:46  
标签:delay code AppleScript volume application set key keystroke tell

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

标签:delay,code,AppleScript,volume,application,set,key,keystroke,tell
From: https://www.cnblogs.com/Searchor/p/17295791.html

相关文章

  • [CodeForces]4.7
    题目链接:https://codeforces.com/contest/1610/problem/E灵神描述输入t(≤1e4)表示t组数据。所有数据的n之和≤2e5。每组数据输入n(2≤n≤2e5)和长为n的有序数组a(1≤a[i]≤1e9),有重复元素。你需要从a中删除一些元素,对于a的任意非空子序列b,都必须满足:设avg为......
  • CodeForces - 149D Coloring Brackets(区间DP)
    题目大意:给你一个符合括号规则的字符串,现在要求你将这些括号染色,染色规则如下1.一个括号要么被染成红色,要么被染成蓝色,要么不染2.相邻的括号的颜色不能相同(可以同为无色)3.成对的括号只能有一个被染色问染色的方案数解题思路:0表示不染,1表示红色,2表示蓝色那么成对的括号......
  • jackson序列化报 Null key for a Map not allowed in JSON (use a converting NullKey
    报错:"requestParam":null,"errorMsg":"org.springframework.http.converter.HttpMessageNotWritableException:CouldnotwriteJSON:NullkeyforaMapnotallowedinJSON(useaconvertingNullKeySerializer?);nestedexceptionisc......
  • VSCode自建vue示例模板
    步骤打开File->Preferences->ConfigureUserSnippets选择NewGlobalSnippetsfile...输入名字(自定义),填入以下内容,注意修改vue.js路径{"Printtoconsole":{"prefix":"vue","body":["<scrip......
  • 在 Visual Studio Code (VS Code) 中将一段代码注释掉的两种方法
    在VisualStudioCode(VSCode)中,可以使用快捷键或菜单栏的选项来将一段代码注释掉。以下是两种方法:方法一:使用快捷键选中你想要注释的代码。使用下列快捷键:Windows/Linux用户:按下Ctrl+/(单行注释)或Ctrl+Shift+/(块注释)。macOS用户:按下Cmd+/(单行注释)或Cmd+Sh......
  • 【LeeCode】162. 寻找峰值
    【题目描述】峰值元素是指其值严格大于左右相邻值的元素。给你一个整数数组 nums,找到峰值元素并返回其索引。数组可能包含多个峰值,在这种情况下,返回 任何一个峰值 所在位置即可。你可以假设 nums[-1]=nums[n]=-∞ 。你必须实现时间复杂度为 O(logn) 的算法来解决此问题......
  • #yyds干货盘点# LeetCode程序员面试金典:四数之和
    题目:给你一个由n个整数组成的数组 nums,和一个目标值target。请你找出并返回满足下述全部条件且不重复的四元组 [nums[a],nums[b],nums[c],nums[d]] (若两个四元组元素一一对应,则认为两个四元组重复):0<=a,b,c,d <na、b、c和d互不相同nums[a]+nums[b]+nums[c]......
  • #yyds干货盘点# LeetCode面试题:x 的平方根
    1.简述:给你一个非负整数x,计算并返回 x 的算术平方根。由于返回类型是整数,结果只保留整数部分,小数部分将被舍去。注意:不允许使用任何内置指数函数和算符,例如pow(x,0.5)或者x**0.5。 示例1:输入:x=4输出:2示例2:输入:x=8输出:2解释:8的算术平方根是2.82842...,由......
  • 【LeeCode】441. 排列硬币
    【题目描述】你总共有 n 枚硬币,并计划将它们按阶梯状排列。对于一个由 k 行组成的阶梯,其第 i 行必须正好有 i 枚硬币。阶梯的最后一行 可能 是不完整的。给你一个数字 n ,计算并返回可形成 完整阶梯行 的总行数。https://leetcode.cn/problems/arranging-coins/【示例......
  • 代码随想录Day22-Leetcode235. 二叉搜索树的最近公共祖先,701.二叉搜索树中的插入操作,4
    235.二叉搜索树的最近公共祖先题目链接:https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-search-tree/又玩了一天,手又生疏了好多;这道题看了题解,先用公共解法了,之前的题没刷,就给现在留坑了/***Definitionforabinarytreenode.*functionTree......