First of all, let me thank you for the excellent tool AutoHotkey has created. I discovered it a couple of days ago. After I went through the tutorial and most of its documentation I was able to use it for my task at hand. I am testing a Windows application written in .Net/C# that presents a Login screen. I have a list of users in a file whose logins I have to verify. My ahk script is:
Code: Select all
usersfile := "gtids.txt"
reportfile := "report.txt"
if A_Args.length() == 1 {
usersfile := A_Args[1]
}
Login(member, user, marker)
{
global reportfile
Run, app.exe
WinWait, Login
WinActivate
FileAppend, Logging in %marker%...%A_Space%, %reportfile%
Send, {Tab}
Send, {Tab}
Send, {Tab}
Send, %member%
Send, {Tab}
Send, %user%
Send, {Tab}
Send, password
Send, {Tab}
Sleep 1000
Send, {Enter}
WinWait, %marker%
FileAppend, Logged in %marker%.%A_Space%, %reportfile%
Sleep 5000
}
Logout(user, marker)
{
global reportfile
WinClose, %marker%
WinWait, [%user%]
WinActivate
Send, {Tab}
Sleep 1000
Send, {Enter}
WinWait, %marker%
FileAppend, Logged out %marker%.`n, %reportfile%
}
^!t::
Loop, Read, %usersfile%
{
a := StrSplit(A_LoopReadLine, A_Space)
member := a[1]
user := a[2]
marker = %member%~%user%
Login(member, user, marker)
Logout(user, marker)
}
return
In Login():
Code: Select all
ControlClick, LOGIN, Login
In Logout():
Code: Select all
ControlClick, YES, %marker%
I confirmed the titles on the windows with Window Spy. For some reason ControlClick did not work in both cases. Can you give me any hints why so and how to make it work?
I will also appreciate any advices how to make my script better. Thank you in advance.
Regards
rambius