Unknown Issue with Script in AHK v2.0.11 Windows 10

Ask gaming related questions
Edvi UR
Posts: 1
Joined: 19 Jan 2024, 20:30
Contact:

Unknown Issue with Script in AHK v2.0.11 Windows 10

19 Jan 2024, 20:36

Please help me! I have the following script in order to play the letters s, d, w (in that order) for a game, but AHK always says error in line 1 Error: This line does not contain a recognized action. But it's Ok, right?

Code: Select all

#IfWinActive, ahk_class UnrealWindow
GetKeyState("RShift")
	SetKeyDelay, 500
	Send, s
	Sleep, 10
	Send, d
	Sleep, 10
	Send, w
return
#IfWinActive
With the window spy mode that's the name of window but I don't if it doesn't reading the game or it's from the script, I don't know, please help!!!


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
User avatar
boiler
Posts: 17329
Joined: 21 Dec 2014, 02:44

Re: Unknown Issue with Script in AHK v2.0.11 Windows 10

19 Jan 2024, 21:23

Edvi UR wrote: ...AHK always says error in line 1 Error: This line does not contain a recognized action. But it's Ok, right?
How is always getting an error OK? That is a v1 script. AHK v2 has very different syntax. See the AHK v2 documentation.

There are several issues with the script anyway. The #IfWinActive lines don't do anything in that script, even in v1 where it wouldn't report an error. Those directives apply only to hotkeys and hotstrings. And the GetKeyState line essentially does nothing also. Not only because it only gets executed at the instant the script is run and not again, but it doesn't do anything with the result, so that function is being called for nothing. It's also unlikely that your target window would be activated in time for this script to send the letters to it. Bottom line is that this script is not really useful as-is, even when run in v1.
OuroborosGhost
Posts: 3
Joined: 20 Jan 2024, 08:09
Contact:

Re: Unknown Issue with Script in AHK v2.0.11 Windows 10

20 Jan 2024, 08:50

Code: Select all

#Requires AutoHotkey v2.0
HotIfWinActive "ahk_class UnrealWindow"

;100-200ms probably better 10 may be too fast and end up skipping ingame stuff and cloggin buffer

SetTimer Unreal, 10 
Unreal() {
if GetKeyState("RShift", "P") {
While GetKeyState("RShift", "P") {
	Sendinput "sdw"
       }
return
}
}
;this what i been tinkering with. may not be exactly what u need but gives u an idea of other possibilites

best for games to convert to .exe and run as admin ;)
[Mod edit: Removed empty code box,]
[Mod edit: Added [code][/code] tags.]
Last edited by gregster on 20 Jan 2024, 09:02, edited 1 time in total.
Reason: Please put code (or codebox) tags around your code, and not below it. Thank you!
User avatar
boiler
Posts: 17329
Joined: 21 Dec 2014, 02:44

Re: Unknown Issue with Script in AHK v2.0.11 Windows 10

20 Jan 2024, 11:04

OuroborosGhost wrote: best for games to convert to .exe and run as admin
You don’t have to convert a script to .exe in order to run it as admin. Is there some other advantage to doing that?

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 8 guests