Help AutoHotKey can't ControlSend {ENTER} or F keys 0.3.7/0.3dl

izdisril

Member
Joined
Jan 1, 2023
Messages
9
Reaction score
1
Somehow while having the game paused, ControlSend can input any key into SA:MP, just very very very slowly.
As such, I decided to get SAMP Addon installed so that the game never pauses.
The problem that arose was that while I could ControlSend any normal keys into SA:MP with the game unfocused/minimized, special characters such as {ENTER} or {F6} didn't work. Thus, I could have the command entered into the chat by using "t" instead of {F6}, but I could never actually send it. My aim is to send commands with the game minimized so that I can do something else in the meantime.
Right now, I have to use ControlFocus or ControlClick for {F6} and {ENTER} to work, but that makes my cursor get stuck in the middle of the screen until I maximize SA:MP again.
I've thought of using a CLEO script to input the command and having AHK activate it in the background, but the CLEO script doesn't recognize AHK's virtual inputs as genuine key presses.
How may I address this issue?

Code:
#MaxThreadsPerHotkey 2
#If WinExist("GTA:SA:MP")

SetTitleMatchMode, 2
SetControlDelay -1
SetKeyDelay, -1, 10

!4::
ControlFocus,, ahk_exe gta_sa.exe ;this is the only way I could get it to work
ControlSend,, {F6}/work{ENTER}, ahk_exe gta_sa.exe
Return
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
456
Solutions
9
Reaction score
166
Location
Poland
Working ANY SA:MP Version.
PHP:
#Include %A_ScriptDir%\SAMP.ahk
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance Force
#CommentFlag //

// Stop running after 3 seconds
1::
{
    
    hWnd := WinExist("ahk_exe gta_sa.exe")
    ControlSend,, {w down}, ahk_id %hWnd%
    Sleep, 3000
    ControlSend,, {w up}, ahk_id %hWnd%
}
return

// Write "/g" twice in chat
2::
{
    hWnd := WinExist("ahk_exe gta_sa.exe")
    ControlSend,, t/g{enter}, ahk_id %hWnd%
    Sleep, 1000
    ControlSend,, t/g{enter}, ahk_id %hWnd%
}
return
 

Attachments

  • Script.zip
    25.9 KB · Views: 3

izdisril

Member
Joined
Jan 1, 2023
Messages
9
Reaction score
1
Top