start my script directly while ingame, i want to NOT have to click desktop>click hotkey>back to game

Ask gaming related questions (AHK v1.1 and older)
DedicatedLearner
Posts: 2
Joined: 02 Feb 2023, 22:30

start my script directly while ingame, i want to NOT have to click desktop>click hotkey>back to game

Post by DedicatedLearner » 02 Feb 2023, 22:46

Code: Select all

F5::
  Loop {
    Send, 1
    Sleep, 1000
  }

[Mod actions: Moved topic to “Gaming” and fixed code tags.]

Rohwedder
Posts: 7511
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: HELP start my script directly while ingame, i want to NOT have to click desktop>click hotkey>back to game

Post by Rohwedder » 03 Feb 2023, 02:00

Hallo,
try:

Code: Select all

#Persistent
SetTimer, Send1, 1000
Return
Send1:
MouseGetPos,,, GameId
IF !WinExist("ahk_id " GameId " ahk_exe notepad.exe")
	Return
WinActivate
Send, 1
Return
As soon as the cursor is in the Notepad window, it is activated and ones are written in it.

User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: HELP start my script directly while ingame, i want to NOT have to click desktop>click hotkey>back to game

Post by DuckingQuack » 03 Feb 2023, 06:01

Rohwedder has a great suggestion, but this will still require starting the script outside of the game. I’m not sure I fully understand the your motivation for starting the script after the game is running or why tabbing out and back in after starting it is an issue. Without the use of an extra script (that would need to be started outside of the game anyway), I don’t see how we could help you achieve your goal as you presented it. I believe you may want to set a more achievable goal. Any additional information you can provide will be extremely helpful.
Best of Luck,
The Duck

DedicatedLearner
Posts: 2
Joined: 02 Feb 2023, 22:30

Re: start my script directly while ingame, i want to NOT have to click desktop>click hotkey>back to game

Post by DedicatedLearner » 03 Feb 2023, 21:01

Hi guys, thank you so much for your replies @Rohwedder and @DuckingQuack

I have been using ahk for several years now. I have no programming background of sort but self studying ahk hard. Im sorry the title is kind of misleading, its my first time to post question here.
So basically i use my scripts as such: right click ahk/exe > run as admin > click hotkey (lets say F5) > and go to game. But i noticed that every time i want to pause / resume / break the running script, i had to click to the desktop (basically outside the game) > click hotkey to pause / resume / break > and then back to game every single time. So if u dont mind and im really sorry, what i really mean is 'i want to pause /resume/break the current running script through its respective hotkeys without losing focus in the game such as clicking desltop.
Thank you so much

User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: start my script directly while ingame, i want to NOT have to click desktop>click hotkey>back to game

Post by DuckingQuack » 04 Feb 2023, 08:03

@DedicatedLearner
If the script you posted is your whole script then the solution is simple, add a way to toggle. If your script is one hotkey, it is as easy as adding a hotkey for pause.
If that was not the whole script that you posted and you already have a way to toggle the hotkey, then the problem could be something far more complicated. A possible issue could be the game itself blocking your usage of the hotkeys, although that seems unlikely if AHK is able to send commands to the game.

Here are some examples of what I meant. First adding a pause hotkey, then creating a togglable hotkey.

Code: Select all

#Requires AutoHotkey v1.1.33
Esc:: ExitApp
F5::
  Loop {
    Send, 1
    Sleep, 1000
  }
F6::Pause

Code: Select all

#Requires AutoHotkey v1.1.33 ;MADE BY @MIKEYWW
F1::
If on := !on {
 SetTimer timer, 9000 ;THIS IS INTERVAL BETWEEN WHEN THE TIMER OBJECT IS STARTED
 SoundBeep 1500 ;BEEPS ARE OPTIONAL
} Else {
 SetTimer timer, Off
 SoundBeep 1000 ;BEEPS ARE OPTIONAL
}
Return

timer() {
    ;INSERT COMMANDS HERE
}
Best of Luck,
The Duck

Kolonel
Posts: 33
Joined: 28 Jun 2020, 00:44

Re: start my script directly while ingame, i want to NOT have to click desktop>click hotkey>back to game

Post by Kolonel » 21 Aug 2023, 16:22

Add "$" to your hotkey.
Basically

Code: Select all

$F5::

Post Reply

Return to “Gaming Help (v1)”