running script in a particular window.

Ask gaming related questions (AHK v1.1 and older)
TurboCharged_fnc
Posts: 6
Joined: 02 Jun 2021, 02:18

running script in a particular window.

12 Sep 2021, 11:59

so i've tried to find it in other forums, but im not able to understandabt it. I even tried to read abt it in the ahk website, but i couldnt understand that either.

Code: Select all

#MaxThreadsPerHotkey 2
^y::
Toggle := !Toggle
loop
{
    If not Toggle
        break
    Send, .route 24
    Send, {enter}
    sleep, 4000
    Send, 4
    Send, {enter}
    sleep, 4500
}
return
Plz someone make it work in a specific window, i.e. Google Chrome
Last edited by gregster on 12 Sep 2021, 12:34, edited 1 time in total.
Reason: Topic moved from 'Scripts and Functions > Gaming'.
User avatar
boiler
Posts: 16977
Joined: 21 Dec 2014, 02:44

Re: running script in a particular window.

12 Sep 2021, 13:23

It depends on what you mean. Do you want the hotkey to be active only when Chrome is the active window, or do you want it to alway send those keystrokes to Chrome whether it is the active window or not? Use #IfWinActive for the former and ControlSend for the latter.
TurboCharged_fnc
Posts: 6
Joined: 02 Jun 2021, 02:18

Re: running script in a particular window.

13 Sep 2021, 00:01

boiler wrote:
12 Sep 2021, 13:23
It depends on what you mean. Do you want the hotkey to be active only when Chrome is the active window, or do you want it to alway send those keystrokes to Chrome whether it is the active window or not? Use #IfWinActive for the former and ControlSend for the latter.
yes i want it to work when google chrome is not the active window, u cud say that i want it to run in the background on only google chrome.
TurboCharged_fnc
Posts: 6
Joined: 02 Jun 2021, 02:18

Re: running script in a particular window.

13 Sep 2021, 01:25

i tried this but it only works when the window is active.

Code: Select all

#MaxThreadsPerHotkey 2
^y::
Toggle := !Toggle
loop
{
    If not Toggle
        break
    ControlSend, , .route 24 {enter} 4 {enter}, turbos-pokemon - Google Chrome
    SetKeyDelay, 800
}
return
User avatar
boiler
Posts: 16977
Joined: 21 Dec 2014, 02:44

Re: running script in a particular window.

13 Sep 2021, 04:07

Chrome apparently only acts on virtual key presses when it is the active window. Confirmed by sending ^t to try to open a new tab both when its window is active and inactive.
TurboCharged_fnc
Posts: 6
Joined: 02 Jun 2021, 02:18

Re: running script in a particular window.

22 Sep 2021, 09:59

boiler wrote:
13 Sep 2021, 04:07
Chrome apparently only acts on virtual key presses when it is the active window. Confirmed by sending ^t to try to open a new tab both when its window is active and inactive.
so it is not possible? do u know of any other browser. or maybe i should try discord app?
User avatar
boiler
Posts: 16977
Joined: 21 Dec 2014, 02:44

Re: running script in a particular window.

22 Sep 2021, 10:19

It's possible you are out of luck. I am not aware of any other browsers that respond better to this, although some may. From what I've seen, Edge and Firefox do not. You could try using other automation methods such as the Chrome.ahk library.

I don't use the Discord app, so I can't comment on that.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 109 guests