I want to automate the following
1)Open the RSAToken Application
2)Simulate keystrokes to enter the PIN (say for eg : 223344 in that application)
3)Also to simulate the Enter keystroke upon entering the PIN
4)Copying passcode generated
i tried coding it by referring couple of articles but it was not working.
Following is the code
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
Could anyone tell me , what am i missing ?
First of all, you need to wait for the application to start after running it. As I don't have the application, I can only suggest something like this:
WinWaitActive ahk_exe SecurID.exe
Then you need to copy the resulting code.
Ctrl+C
only works if the code is selected, which it probably isn't. So Send ^c
won't work.
Again, I don't have the application, but if it looks like this:
(source: rsa.com)
you need to move the keyboard focus to the Copy button and push it using the keyboard. That can probably be done either by
Send {Tab}{Enter}
or simply
Send {Enter}
if the button is already the default button.
In total, we have something like this:
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.
The general algorithm for writing a script like this is to first do the task manually using the keyboard only. When you can make that work, make a script that presses the same keys as you pressed manually.