How to creat a script to only work in my game window?

Ask gaming related questions (AHK v1.1 and older)
SteezyHamad
Posts: 2
Joined: 25 Sep 2022, 12:53

How to creat a script to only work in my game window?

Post by SteezyHamad » 25 Sep 2022, 12:57

I just need to run the hotkey only on my game so i can use pc

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: How to creat a script to only work in my game window?

Post by Lepes » 25 Sep 2022, 13:29

The easy way for me is by executable

Code: Select all

#ifWinActive, ahk_exe blender.exe
f1:: Send, +s    ; I use F1 to send  Shift+S

#if   
Everything inside #ifWinActive and #if is only executed when blender.exe is focused (the active window, the one that takes mouse and keyboard inputs)

Each game is different (anticheat and things like that) so you need to test.

SteezyHamad
Posts: 2
Joined: 25 Sep 2022, 12:53

Re: How to creat a script to only work in my game window?

Post by SteezyHamad » 25 Sep 2022, 13:52

@Lepes
sorry it didnt work im very very new to ahk maybe id did something wrong with my script

#SingleInstance, Force

Code: Select all

6::
loop,
{
    Send, k
    Sleep, 100
    Send, {s Down}
    Sleep, 100
    Send, {s Up}
    Sleep, 100
    Send, v
    Sleep, 100
    Continue
}
Return

7::Reload

8::
ExitApp
[Mod edit: [code][/code] tags added.]

this is my script where i should put ur code ?

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: How to creat a script to only work in my game window?

Post by Lepes » 26 Sep 2022, 04:55

Code: Select all

 #SingleInstance, Force 

#ifWinActive, ahk_exe blender.exe
6::
loop,
{
    Send, k
    Sleep, 100
    Send, {s Down}
    Sleep, 100
    Send, {s Up}
    Sleep, 100
    Send, v
    Sleep, 100
    Continue
}
Return
#if

#ifWinActive, ahk_exe Notepad.exe
6:: Send 7    ; teaching how the same hotkey will work different on another program
#if

7::Reload
8::ExitApp 

hotkey 6 will only work with Blender.exe and notepad.exe
hotkeys 7 and 8 will work on any window

Post Reply

Return to “Gaming Help (v1)”