Hello forum,
I have a little problem. I have a mud client - mudlet (mudlet.exe) and defined numpad keys for move and other actions.
My goal is to make script which allow me to use these numpad keys only in mudlet.exe even if working in other window. For expample if im using browser, code editor, others and i press numpad 4, key is activate only in inactive mudlet.exe.
Last time i tried achive such result i had problem with infinity loop.
Activate keys only in inactive window. Topic is solved
Re: Activate keys only in inactive window.
Try something like this:
Code: Select all
#IfWinActive, ahk_exe mudlet.exe
Numpad2::Down
Numpad8::Up
Numpad4::Left
Numpad6::Right
Numpad5:: ; just a peseudo code
Send, ^{Home}
Send, ^+{PgDn}
Return
#IfWinActive
Re: Activate keys only in inactive window.
It doesnt work when I am in other window focused.
Re: Activate keys only in inactive window.
To make work Hotkeys in multiple windows see here.
To make work Hotkeys in all windows don't use #IfWinActive commands at all!
bye!
To make work Hotkeys in all windows don't use #IfWinActive commands at all!
bye!
Re: Activate keys only in inactive window.
OMG! I didn't read attentively! If you want Hotkeys to work in an inactive window then use something like this:Note: In place of "mudletCtrl" you have to determin and put the real ClassNN of your mudlet app.
Code: Select all
#IfWinExist, ahk_exe mudlet.exe
Numpad2::ControlSend, mudletCtrl, {Down}, ahk_exe mudlet.exe
Numpad8::ControlSend, mudletCtrl, {Up}, ahk_exe mudlet.exe
Numpad4::ControlSend, mudletCtrl, {Left}, ahk_exe mudlet.exe
Numpad6::ControlSend, mudletCtrl, {Right}, ahk_exe mudlet.exe
Numpad5:: ; just a peseudo code
ControlSend, mudletCtrl, ^{Home}, ahk_exe mudlet.exe
ControlSend, mudletCtrl, ^+{PgDn}, ahk_exe mudlet.exe
Return
#IfWinExist
Re: Activate keys only in inactive window.
Dont know why but examples above dont work for me.
I have other solution but isnt as fast as it could (but works):
I have other solution but isnt as fast as it could (but works):
Code: Select all
Numpad4::
WinGetActiveTitle, currActiveTitle
WinGetClass, currActiveClass
WinActivate, Arkadia - Mudlet 3.21.0 ahk_class Qt5QWindowIcon
Send w{Enter}
WinActivate, %currActiveTitle%
return
Re: Activate keys only in inactive window.
That's a good news. Here is my little modification:if that works then maybe this could too, if you didn't try it already:
Code: Select all
Numpad4::
WinGetActiveTitle, currActiveTitle
;WinGetClass, currActiveClass ; you don't use that in the code below
WinActivate, Arkadia - Mudlet 3.21.0 ahk_class Qt5QWindowIcon
WinWaitActive, Arkadia - Mudlet 3.21.0 ahk_class Qt5QWindowIcon ; needed if CPU under load
Send w{Enter}
WinActivate, %currActiveTitle%
return
Code: Select all
Numpad4::ControlSend,, w{Enter}, Arkadia - Mudlet 3.21.0 ahk_class Qt5QWindowIconreturn
Re: Activate keys only in inactive window.
Thx, first one works fine but like in my example too, when i press fast f.e. numpad 4 and then numpad 2 (s{Enter}), it doesnt back to previous active window. For sure after pressing numpad4 it is getting Mudlet as active window. Only when i do it fast (0.2s or smth). Is there any fast solution for such behaviour?
Second example doesnt work.
Second example doesnt work.
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Activate keys only in inactive window. Topic is solved
The reason it doesn't work when pressed quickly is because it's getting the active window again, which would be the mudlet window. If you use critical, it should buffer (or ignore) the second activation, rather than interrupt the currently running instance. If it doesn't, then consider using the hotkey command to disable the hotkey after called, then re-enable just before the return.
Re: Activate keys only in inactive window.
thx, Critical works fine.Masonjar13 wrote: The reason it doesn't work when pressed quickly is because it's getting the active window again, which would be the mudlet window. If you use critical, it should buffer (or ignore) the second activation, rather than interrupt the currently running instance. If it doesn't, then consider using the hotkey command to disable the hotkey after called, then re-enable just before the return.
Code: Select all
#SingleInstance, force
setTask(task){
Critical
WinGetActiveTitle, currActiveTitle
WinActivate, Arkadia - Mudlet 3.21.0 ahk_class Qt5QWindowIcon
WinWaitActive, Arkadia - Mudlet 3.21.0 ahk_class Qt5QWindowIcon ; needed if CPU under load
Send %task%
WinActivate, %currActiveTitle%
}
Numpad4::setTask("w{Enter}")
Numpad2::setTask("s{Enter}")
^x::ExitApp
Who is online
Users browsing this forum: Descolada, downstairs, filipemb, Google [Bot], OrangeCat, roysubs and 156 guests