我想自动化以下内容
1)打开RSAToken应用程序
2)模拟按键以输入PIN(例如:在该应用程序中为223344)
3)还要在输入PIN时模拟输入击键
4)复制生成的密码
我尝试通过引用几篇文章来编写它,但它没有用。
以下是代码
Run, "C:\Program Files (x86)\RSA SecurID Software Token\SecurID.exe"
;; 2222 is the PIN Code
Send, 2222
Sleep, 100
Send, {ENTER}
Sleep, 100
Send, ^c
Sleep, 100
谁能告诉我,我错过了什么?
首先,您需要等待应用程序在运行后启动。由于我没有应用程序,我只能建议这样的事情:
WinWaitActive ahk_exe SecurID.exe
然后,您需要复制生成的代码。
Ctrl+C
仅在选择代码时才有效,但可能不是。所以Send ^c
将无法运作。
同样,我没有应用程序,但如果它看起来像这样:
您需要将键盘焦点移动到“复制”按钮并使用键盘将其按下。这可以通过以下方式完成
Send {Tab}{Enter}
或者干脆
Send {Enter}
如果按钮已经是默认按钮。
总的来说,我们有这样的事情:
Run, "C:\Program Files (x86)\RSA SecurID Software Token\SecurID.exe"
; Wait a while for the window to appear and become active.
timeoutSeconds:= 2
WinWaitActive ahk_exe SecurID.exe,, %timeoutSeconds%
if not ErrorLevel {
; The window is now active.
;; 2222 is the PIN Code
Send, 2222 ; Type the PIN code.
Sleep, 100
Send, {ENTER} ; Send the PIN code.
Sleep, 200 ; Wait for the program to generate the passcode.
Send {Tab} ; Move focus to the Copy button; this might not be needed.
Send {Enter} ; Press the Copy button.
Sleep, 100 ; Wait for the copy to happen; often unnecessary.
} else
MsgBox The window did not appear within %timeoutSeconds% seconds.
编写这样的脚本的一般算法是首先仅使用键盘手动执行任务。如果能够完成这项工作,请创建一个脚本,按下您手动按下的相同键。