use 2 buttons with a small delay to target a specific window
use 2 buttons with a small delay to target a specific window
Requesting help with a fairly simple script thank you!
Hi I am looking to use 2 buttons on keyboard with a small delay in between. But I need it to target a specific window (which is a game)
I will have 2 windows of the same game open though, so not sure how it would differentiate them?
Hi I am looking to use 2 buttons on keyboard with a small delay in between. But I need it to target a specific window (which is a game)
I will have 2 windows of the same game open though, so not sure how it would differentiate them?
Last edited by gregster on 08 Feb 2023, 21:21, edited 1 time in total.
Reason: Replaced topic title with smth more descriptive.
Reason: Replaced topic title with smth more descriptive.
Re: use 2 buttons with a small delay to target a specific window
forgot to mention I want it to repeat until the script is stopped
Re: use 2 buttons with a small delay to target a specific window
hi I was able to get a loop running, i tried using window spy to use exe pid id to target a specific window, but it only targets the window that I am currently focused on.
Re: use 2 buttons with a small delay to target a specific window
if the first and second window has the same Title, ahk_pid, and ahk_exe, ofcourse the script will only run at the currently focusing window, i suggest using Sandboxie which make different Title and pid from one application..
If the ahk_pid different, you can use ControlSend
example:
Code: Select all
ControlSend,, a, ahk_pid xxxx
ControlSend,, a, ahk_pid yyyy
example:
Code: Select all
WinSetTitle, <original window title>,, <new window title>
and if this works, you can use:
Code: Select all
ControlSend,, a, Game Window 1 ; (original)
ControlSend,, a, Game Window 2 ; (WinSetTitle-ed)
Re: use 2 buttons with a small delay to target a specific window
You don’t want to hard-code in PID numbers because they change every time the application is run.off wrote: ↑ If the ahk_pid different, you can use ControlSend
example:
Code: Select all
ControlSend,, a, ahk_pid xxxx ControlSend,, a, ahk_pid yyyy
Not only is this not recommended, there is no reason to do it. Once the windows are differentiated, ascertain the HWND (unique window ID) of each so you can refer to each by that using ahk_id. These also change with each incarnation of the window, so you wouldn’t hard-code the numbers in. You capture them in variables and refer to them using those variables.off wrote: ↑ you can also use WinSetTitle to differentiate same windows, and it only set the title to last active window
example:tested to change 2 File Explorer with same title, ahk_class, and ahk_pidCode: Select all
WinSetTitle, <original window title>,, <new window title>
and if this works, you can use:Code: Select all
ControlSend,, a, Game Window 1 ; (original) ControlSend,, a, Game Window 2 ; (WinSetTitle-ed)
Re: use 2 buttons with a small delay to target a specific window
the scripts are working fine, but it does not work on a window that is unfocused.