I need help with Controlsend

Get help with using AutoHotkey and its commands and hotkeys
Posts: 1
Joined: 24 Nov 2017, 20:03

I need help with Controlsend

24 Nov 2017, 20:18

Hello there! I'm having some troubles with the controlsend in a game

What i'm trying to do is: sending a bunch of {space} in a game while it is minimized/unfocused

Here's the code i came up with

Code: Select all

SetKeyDelay, 30, 100,

WinGet, swbpid, PID, STAR WARS Battlefront II
Winget, swbid, ID, STAR WARS Battlefront II
WinGetClass, swbclass, STAR WARS Battlefront II
msgbox, class is %swbclass% pid is %swbpid% and Id is %swbid% ,, just for informations and testing

$*F12::Reload ,,  pauses the script

if (enable := !enable)
  setTimer, MoveAround, -1

while enable
  ifWinExist, ahk_id %swbid%
    SetKeyDelay, 30, 100,
    ControlSend, , {space}, ahk_id %swbpid%
    Sleep, 140
    Random, r, 1000, 5000
    Sleep r

The thing is, no keystroke is sent....
I know my script is trash and all, but idk why it's not working, it worked in other games! anyone to help please? maybe i'm doing something wrong :(
User avatar
Posts: 5272
Joined: 19 Dec 2016, 01:58
Location: UK

Re: I need help with Controlsend

24 Nov 2017, 21:15

Some possibilities:
- Run AHK in admin mode.

Code: Select all

ControlSend, ahk_parent, {Space}, ahk_id %swbpid%

Code: Select all

ControlGetFocus, vCtlClassNN, ahk_id %swbpid%
ControlFocus, % vCtlClassNN, ahk_id %swbpid% ;this probably won't change the active window
ControlSend, % vCtlClassNN, {Space}, ahk_id %swbpid%

Return to “Ask For Help”

Who is online

Users browsing this forum: Eden, eqv, Galaxis, Google [Bot] and 45 guests