Stuck at trying to use ControlSend to a particular HWND :(

Ask gaming related questions (AHK v1.1 and older)
StellarFox
Posts: 1
Joined: 21 Jun 2021, 11:50

Stuck at trying to use ControlSend to a particular HWND :(

21 Jun 2021, 12:01

Hello Everyone!

I'm trying to make a macro in Fallout 76 and so far simple commands such as "send" worked fine (the game accepts that). I'm trying to improve my code and what I'm trying to do below is:
1) Get the current ID (HWND) of the game's window from the list of all windows
2) keep it as a "CurrentID" variable
3) Repeatedly send "press w key" only to that window (while I'm doing sth else in another window)

I tried to use hints from the manual (https://www.autohotkey.com/docs/commands/WinGet.htm,), it seems simple, but there must be a mistake somewhere - because the game doesn't react to this :( I used the "Windows Spy" to get the name of the window - it's simply "Fallout76"

Any hints?:

Code: Select all

F1::
WinGet, CurrentID, List, Fallout76

Loop
	{
	ControlSend,,{w down}, ahk_id %CurrentID%
	Sleep 500 
	ControlSend,,{w up}, ahk_id %CurrentID%
	Sleep 1000
	}

F2::pause
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Stuck at trying to use ControlSend to a particular HWND :(

21 Jun 2021, 12:48

Code: Select all

WinGet, CurrentID, List, Fallout76
returns a list of hwnds of non-hidden windows, whose titles start with Fallout76, where CurrentID contains the total number of windows found and CurrentID1 through N - the hwnd of each respective window

in other words, ure misusing the command's return values

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 48 guests