Help with an IF condition
Posted: 29 Apr 2014, 23:55
I'm new to AHK. I can do the basic stuff, hotkeys, hotstrings etc. I am working on automating some repetitive stuff at work, which would probably still be pretty basic for you guys. One problem I have to overcome is I don't have access to the program outside of work so I have to figure out stuff at home then try it out when I get to work. Right now I am working on one particular problem. As you can see below it is mainly just navigating through windows and menu items. The problem is depending on who the subject of my query is there is a popup window. which is why I have the WinGetTitle. I can see the windows title fine in the message box. The problem is the while the beginning of the title remains the same the second half becomes the name of the subject of my query. IE if the person I am querying is named John SMITH the title will be Query - KO SMITH,JOHN. If I set my variable = Query - KO SMITH,JOHN everything works fine but obviously if I query another subject the code will not work. I was hoping SetTitleMatchMode would fix it but no luck. I have been trying to figure out how to set the variable = to just Query - KO with a wildcard standing in for whatever name follows but I can't figure out how to make it work. If anyone could point me in the right direction it would be greatly appreciated.
Thanks in advance
Thanks in advance
Code: Select all
; script to query CORE and KO
^\::
SetTitleMatchMode 2
send {enter}
send {shift}+{tab}
Send core{+}{enter}{enter}
send y
sleep 1800
send {enter}
sleep 1000
WinGetTitle, windowstitle, A ; gets windows title, variable to store it in, A specifies active window
msgbox, %windowstitle% ; shows what is currently stored in variable
if windowstitle = Query - KO# ; if what is stored in windows title = windows title name
{
send {tab}{tab}{tab}{tab}k
send {enter}
send {pgUp}
send {enter}
send !f
send p
send {enter}
return
}
else
{
SendInput, {alt down}r {alt up}
send {tab}{tab}{tab}{tab}k
send {enter}
send {pgUp}
send {enter}
send !f
send p
send {enter}
}
return