How to automate , to open a RSAToken application and simulate keystroke and to press Enter using AutoHotKey - automation

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.

Related

AutoHotKey: catching & manipulating windows without human interaction

Something sounding very basic has taken a lot of time: how can an AutoHotKey script be programmed to wait for a specific window and then accept it, Send {enter}, to close it down? In this case it’s an annoying settings confirmation dialogue which comes up every time certain file types are opened for a programme. A minor complication is also that the windows title changes every time, while its ahn_class is shared with the mother programme – things which i’ve tried to tackle by catching the window by its pixel size instead:
#IfWinActive ahk_class SALFRAME
~LButton::
WinGetActiveStats, , width, , ,
if (width = "681") {
Send {enter}
}
return
This works, but forces to click somewhere on the dialogue when it comes up, which is faster then before, but still not really automated. I also tried with WinWaitActive among other things, but it doesn’t seem to catch the window (at some point some of the scripts i’ve tried to write actually killed the window when the script was executed, but only once, without touching subsequent windows coming after the script first ran). What is the correct way to wait for and terminate certain windows without human input with AutoHotKey?
#Persistent
SetTimer, Send_Enter_to_specific_window, 50
return
Send_Enter_to_specific_window:
IfWinActive ahk_class SALFRAME
{
WinGetPos,,, width,, A
if (width = "681")
Send {enter}
}
return
https://autohotkey.com/docs/commands/SetTimer.htm#Examples

Auto Hot Key - Holding down one key holds down 2 different keys

So I've used AutoHotKey to disable the AppsKey (the button on the keyboard which brings up the right-click menu). But I thought I could put it to better to use, and am trying to get it so that while I'm holding down the AppsKey the computer thinks I'm holding down Shift & Control instead.
I've been reading through the Command List but can't see anything for AppsKey down & up. Would anyone be able to share anything to enable me to do this?
Thanks
I don't understand what your problems are, but this little piece of code works for me:
AppsKey::Send, {SHIFT down}{CTRL down}
AppsKey up::Send, {CTRL up}{SHIFT up}
As you can see, there is an AppsKey up. Down on the other hand doesn't exist for hotkeys. In this example, the first hotkey triggers when AppsKey is pressed (that is, it triggers as soon as you hit it). The second hotkey triggers when it is released.

AHK for selecting Context Menu Option - Not working

I am trying to create a Hotkey (Ctrl+l) to do following:
Right Click at Current Mouse Location. (to bring up context menu)
In the context menu go to Second option. (or any other option)
Click Enter on that option.
^l::MouseClick, right
Sleep, 1000
Send, {DOWN 2}{ENTER}
Problem:
The problem is that ONLY the Right Click command works and brings up the Context Menu successfully but Down doesn't work at all, so NO OPTION is Selected from the menu.
Additional Info:
I found that if context menu is already there and then if I run following script:
Send, {DOWN 2}{ENTER}
It selects the option Successfully.
But I need both Right Click and Selection of Option to be done by single Hotkey.
What am I doing wrong ?
If you declare your hotkeys with command in the same line only that line will be executed
^l::MouseClick, right ; only this line is executed
Sleep, 1000
Send, {DOWN 2}{ENTER}
Compared to this:
^l::
MouseClick, right
Sleep, 1000
Send, {DOWN 2}{ENTER}
return
All lines get executed.
You wrote MouseClick, Right in the same line as ^l::, this way ONLY the first line is executed.
^l::
MouseClick, right
Sleep, 100
Send, {DOWN 2}{ENTER}
Return

AutoHotkey background clicking and typing

I'm trying to use AutoHotkey to do some background clicking and typing while I'm doing other stuff in the foreground.
I've gotten used to Send but I haven't figured out how ControlSend works yet. Can anyone give me an example using something simple like MSPaint in the background and changing the color of paint.
Is this even possible to do? I have a script currently that pulls from daily Excel report, assigns each row a variable and punches it into another program, but I need it to click and type some canned messages as well.
The first question should probably be why use mouse control? Keyboard control is sooo much easier and often more reliable. What is it that you try to do with a mouseclick that can't be done through keyboard commands?
Also mouse clicks normally activate the hidden app.
OK you wanted an example...
+Home:: ;Shift + Home = stop/start radio
SetControlDelay -1
ControlClick, x384 y143, Radioplayer
Return
Here i click on the play/pause button of a streaming radioplayer. The mouse coordinates are found with the aforementioned Windows Spy and the title of the browser (you might have to use SetTitleMatchMode). Why not look at the AutoHotKey Command list and check out the examples there....
Let me know if this is (roughly) what you are looking for....
SendMode Input ; Recommended for new scripts
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2 ; A window's title can contain the text anywhere
!F1:: ; Press Alt F1 to execute
IfWinExist, Microsoft Excel
{
ControlSend ,, 1000{Enter}{Down}, Microsoft Excel
}
return
Here is some code I used to first record the mouse position (relative mouse position did not work since the window was tiled and the click position could be changed by moving the tiles). Immediately after that I click the mouse at the recorded position (and redo this later on in the code as well).
SplashTextOn, 200, 100, Script Preparations, Please Click on the Person `"Search Term`" link (1) in SAP. ; Show new instructions to the user
WinMove, Script Preparations,, (A_ScreenWidth/2)-150, (A_ScreenHeight/2)-200 ; Move the text instructions window with the name "Script Preparations" 150 pixels right of the center of the screen and 200 pixels up SoundBeep 600, 300 ; Wake up user
; From here on the left mouse button will temporarily be disabled
Hotkey, LButton, on ; Turn Left Mouse Button OFF, to capture the Mouse click
KeyWait, LButton, D ; Wait for LeftMouseButton click Down
MouseGetPos, xposS ,yposS ; Store the position where the mouse was clicked (Search Box)
MouseClick, left, %xposS% ,%yposS% ; Perform the mouse click on the captured mouse location
Hope this helps.
In your situation, I assume that you only need to determine the mouse position with Window Spy.

type to controls on locked workstation?

I'm using AutoHotKey Send command http://www.autohotkey.com/docs/commands/Send.htm to type to controls. It works fine, but it doesn't work if the workstation is locked.
But I need to type to controls on locked workstation.
If AutoHotKey can not do that I can use any other utility.
AutoHotkey scripts still run when the computer is locked, and the ControlSend command is able to send keystrokes directly to controls on a window.
Here's a quick test. After running it waits five seconds, opens up notepad, types some text and then beeps through the PC speaker to let you know that it's done. Run the script and lock your computer straight away. Windows key + L works as a shortcut, adjust the value given to the Sleep command on the first line if you need more than five seconds to lock your machine. After the beep unlock your machine and check the Notepad window.
Sleep 5000
Run notepad.exe
WinWait Untitled - Notepad
Sleep 300
ControlSend, Edit1, Test typing while locked, Untitled - Notepad
SoundBeep,, 500
Notepad was never the active window on my machine after the text was entered, but the text still made it to the window.