在函数内设置光标 "keyboard.send_keys"
set the cursor inside the function "keyboard.send_keys"
我正在尝试设置快捷方式以发送如下输出:[DATE]_[thecaret/cursor].somethinelse
例如:18-02-18_[myCursorHere].png
这是linux下AutoKey的脚本:
output = system.exec_command("date +'%Y%m%d'+'_$(cursor).png'")
keyboard.send_keys(output)
但结果确实是这个:
20180218+_$(cursor).png
您知道如何使用此脚本将光标插入正确的位置吗?
PS:Autokey 还让我使用 "phrase" 函数,其中有一些宏,如 "insert date" 和 "insert cursor" 但我无法使用它.在那种情况下,脚本是这个:
test <date format='%d-%m-%y'><cursor> something here
没有任何反应(实际上我的文本编辑器冻结了)
找到解决方案(使用 "time" 而不是 date 命令更好)
import time
t = time.strftime("%d.%m.%Y")
length = "-.pdf"
keyboard.send_keys(t+length)
keyboard.send_key("<left>", len(length)-1)
我正在尝试设置快捷方式以发送如下输出:[DATE]_[thecaret/cursor].somethinelse
例如:18-02-18_[myCursorHere].png
这是linux下AutoKey的脚本:
output = system.exec_command("date +'%Y%m%d'+'_$(cursor).png'")
keyboard.send_keys(output)
但结果确实是这个:
20180218+_$(cursor).png
您知道如何使用此脚本将光标插入正确的位置吗?
PS:Autokey 还让我使用 "phrase" 函数,其中有一些宏,如 "insert date" 和 "insert cursor" 但我无法使用它.在那种情况下,脚本是这个:
test <date format='%d-%m-%y'><cursor> something here
没有任何反应(实际上我的文本编辑器冻结了)
找到解决方案(使用 "time" 而不是 date 命令更好)
import time
t = time.strftime("%d.%m.%Y")
length = "-.pdf"
keyboard.send_keys(t+length)
keyboard.send_key("<left>", len(length)-1)