Beginner to autohotkey.
I have a script with two #ifwinactive for excel files, but the keystrokes fire on any page, I'm not sure if I have the correct syntax. What should happen is that ctrl + J should only fire on the first file and ctrl + r on the second. But either command works without the windows being active or open. Also is there information on how to select the correct program name? I will be trying to check if a .exe is running later - do you use the name in task manager?
Sorry if these are silly questions!
Code: Select all
global Values := []
^j::
#IfWinActive production payments - Excel
Send, {Ctrl down}g{Ctrl up}
SendInput, A2
Send, {Enter down}{Enter up}
xl := ComObjActive("Excel.application")
WorkSheet := xl.ActiveSheet
Values := []
Loop 2
{
if (A_Index = 1)
continue ;
row := A_Index
Values[row] := []
For cell in WorkSheet.Range("A" . A_Index . ":F" . A_Index) {
Values[row][A_Index] := cell.Text
}
}
xl := ""
return
^r::
#IfWinActive sample data - Excel
msgBox, start
For row, Cells in Values {
For cell, Value in Cells {
msgBox, %Value%
}
}
return