need Help with simple script PLEASEE<3!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wtfz
Posts: 1
Joined: 24 Mar 2023, 08:48

need Help with simple script PLEASEE<3!

Post by wtfz » 24 Mar 2023, 09:06

hello, hope u doing well ive used ahk for small things over the years but just found out about controlsend tonight so I was messing around with it trying to create a simple script for Gmod but im having issues, I've been trying to figure it out for hours so any help would be appreciated. basically I want said script to just press E while im tabbed out. down below is the code. I know most of you are probably just going to say its GMOD that isnt possible but I verified that it is indeed possible using the Send and Click Tool V4. It goes thru different ways of executing keystrokes and mouse movement while some of the send commends didnt work controlsend did indeed work. Now im thinking it has to do with the process because GMOD has more then one .exe I have a feeling its hooking to the wrong one id imagine the send and click tool uses WinGet to grab the ID which makes sense why it works in the tool and not in my script I kinda know how to use winget and tried just doing it with PID as u can see but that didnt work im also super tired rn and feel braindead any help would really be appreciated I'm honestly stumped at this point ive tried googling everything I can think of/trying stuff

Code: Select all

[Codebox=autohotkey file=Untitled.ahk]#UseHook
Pause on
myWinTitle:="ahk_exe gmod.exe"
Loop {
ControlFocus,, %wintitle%
ControlSend,,{e down}, %myWinTitle%
sleep 100
}

Shift & g::Pause
[/Codebox]






Code: Select all

#UseHook
Pause on
myWinTitle:="ahk_pid 15244"
Loop {
ControlFocus,, %wintitle%
ControlSend,,{e down}, %myWinTitle%
sleep 100
}

Shift & g::Pause
[Mod edit: Moved topic to AHK v1 help.]

cat dog fox war
Posts: 38
Joined: 15 Mar 2023, 10:18

Re: need Help with simple script PLEASEE<3!

Post by cat dog fox war » 24 Mar 2023, 10:33

1. myWinTitle := "ahk_pid 15244" The pid looks suspicious, because the pid is usually related to each time the os executes the program, you try to close `.exe` and then open a new one, grab its pid to see , I don't think it's the `15244` you hardcoded in the script, suggest use https://www.autohotkey.com/docs/v1/lib/WinGetTitle.htm

2. ControlFocus,, %wintitle looks a bit suspicious. In the script you attached, I didn’t see the variable named wintitle. did you mean myWinTitle

Code: Select all

#UseHook
Pause on

; myWinTitle := "ahk_pid 15244"
Loop {
    WinGetTitle, myWinTitle , % "ahk_exe gmod.exe"
    ControlFocus,, %myWinTitle% 
    /*
    if (ErrorLevel = 1)
    MsgBox % "can't find wintitle, wintitle is `n" wintitle
    */

    ControlSend,,{e down}, %myWinTitle%
    sleep 100
}

Shift & g::Pause

Post Reply

Return to “Ask for Help (v1)”