Two ifwinactive - neither works Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ambrosedheffernan
Posts: 3
Joined: 20 Sep 2019, 16:43

Two ifwinactive - neither works

20 Sep 2019, 16:57

Hi,

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

User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Two ifwinactive - neither works  Topic is solved

20 Sep 2019, 17:00

The #IfWinActive needs to come before the hotkeys it is supposed to modify
Please excuse my spelling I am dyslexic.
ambrosedheffernan
Posts: 3
Joined: 20 Sep 2019, 16:43

Re: Two ifwinactive - neither works

20 Sep 2019, 17:06

Brilliant, thank you that is working now!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, demon740, gsxr1300, ht55cd3 and 275 guests