only works if INPUTBOX is active Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ktbjx
Posts: 71
Joined: 11 Jul 2015, 23:53

only works if INPUTBOX is active

16 Oct 2018, 21:43

how can I code it?

i only want this code to work, if an inputbox is active, else resume the normal keyboard Function..
i was guessing something like #IfWinActive??

here is the code i need do work only if an Inputbox exist

Code: Select all

Up::
Send, %Copier1%{Enter}
KeyWait, Up
Return

Down::
Send, %Copier2%{Enter}
KeyWait, Down
Return

NumpadAdd::Return
NumpadDiv::Return
NumpadMult::Return
$NumpadSub::Backspace

Here is the Inputbox Sample i use

Code: Select all

Gui +LastFound +OwnDialogs +AlwaysOnTop 
InputBox, q1,Copper,,,100,100,%xtop%,0

Gui +LastFound +OwnDialogs +AlwaysOnTop 
InputBox, q2,Gold,,,100,100,%xtop%,0
buttshark
Posts: 62
Joined: 22 Apr 2017, 20:57

Re: only works if INPUTBOX is active  Topic is solved

16 Oct 2018, 22:18

For multiple InputBoxes, I would say that there are probably 2 things that are universally the same. That would be their ahk_class and ahk_exe. You can determine what those are using

Code: Select all

WinGetClass, winClass, A
and

Code: Select all

WinGet, winProcessPath, ProcessPath, A
respectively when the InputBox is active. You can then use that to theoretically in your #IfWinActive WinTitle, via

Code: Select all

#IfWinActive ahk_class %class%
or

Code: Select all

#IfWinActive ahk_exe %exe%
What seems to work for me is

Code: Select all

Gui +LastFound +OwnDialogs +AlwaysOnTop 
InputBox, q1,Copper,,,100,100,%xtop%,0

Gui +LastFound +OwnDialogs +AlwaysOnTop
InputBox, q2,Gold,,,100,100,%xtop%,0

#IfWinActive, ahk_class #32770

Up::
Send, %Copier1%{Enter}
KeyWait, Up
Return

Down::
Send, %Copier2%{Enter}
KeyWait, Down
Return

NumpadAdd::Return
NumpadDiv::Return
NumpadMult::Return
$NumpadSub::Backspace
Not sure if that's universal or not, but you can try that.
I have no idea what I'm doing.
ktbjx
Posts: 71
Joined: 11 Jul 2015, 23:53

Re: only works if INPUTBOX is active

17 Oct 2018, 00:18

buttshark wrote:
16 Oct 2018, 22:18
For multiple InputBoxes, I would say that there are probably 2 things that are universally the same. That would be their ahk_class and ahk_exe. You can determine what those are using

Code: Select all

WinGetClass, winClass, A
and

Code: Select all

WinGet, winProcessPath, ProcessPath, A
respectively when the InputBox is active. You can then use that to theoretically in your #IfWinActive WinTitle, via

Code: Select all

#IfWinActive ahk_class %class%
or

Code: Select all

#IfWinActive ahk_exe %exe%
What seems to work for me is

Code: Select all

Gui +LastFound +OwnDialogs +AlwaysOnTop 
InputBox, q1,Copper,,,100,100,%xtop%,0

Gui +LastFound +OwnDialogs +AlwaysOnTop
InputBox, q2,Gold,,,100,100,%xtop%,0

#IfWinActive, ahk_class #32770

Up::
Send, %Copier1%{Enter}
KeyWait, Up
Return

Down::
Send, %Copier2%{Enter}
KeyWait, Down
Return

NumpadAdd::Return
NumpadDiv::Return
NumpadMult::Return
$NumpadSub::Backspace
Not sure if that's universal or not, but you can try that.

it works! i even tried it on different computers #32770 works!
thanks so much!
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: only works if INPUTBOX is active

17 Oct 2018, 00:45

Keep in mind the title of the InputBox- InputBox, OutputVar, Title

This means that if the 2 different InputBox(es) have 2 different titles, then you can always distinguish them from each other or if they exist.

If WinActive("Copper") or with If WinActive("Gold"), the code would be

Code: Select all

If WinActive("Copper") OR WinActive("Gold")
If you use ahk_class #32770, remember that there are other windows from other programs that are identified with #32770, so this can lead to unwanted behavior or mistakes by the program.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], jeves and 155 guests