Here is the code I am using (For automating the Login window of the RDP client):
Code: Select all
Login(username, password){
;WinActivate, % "ahk_id " this.hwnd
ControlSend, , {down}, % "ahk_id " this.hwnd
Sleep % this.DefaultSleep
ControlSetText, Edit2, % username, % "ahk_id " this.hwnd
Sleep % this.DefaultSleep
ControlSetText, Edit3, % password, % "ahk_id " this.hwnd
Sleep % this.DefaultSleep
while (WinExist("ahk_id " this.hwnd)){
ControlClick, Button2, % "ahk_id " this.hwnd
Sleep % this.DefaultSleep
}
}
If I uncomment the WinActivate statement, it works (as long as you do not click anywhere else while it is running)
Any ideas on what is wrong? It should be able to function without the Login window having focus surely?