Two ifwinactive - neither works Topic is solved

Get help with using AutoHotkey 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: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

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”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], HELLiPOD, HiSoKa, IceBubble, Lord-9621, TAC109 and 44 guests