#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
name := "GTA:O Solo Lobby"
proc := "GTA5.exe"
frozen := false
if (!isProcess(proc))
{
MsgBox, 16, %name%, GTA 5 doesn't seem to be running
ExitApp
}
Gui, Font, S12 CDefault, Times New Roman
Gui, Add, Text, x95 y9 w420 h20 vinfo , Going solo, you'll leave the current lobby.
Gui, Add, Button, x62 y49 w120 h40 gsolo vbtn1 , Go solo
Gui, Add, Button, x242 y49 w120 h40 gGuiClose vbtn2 , Discard
Gui, Show, w443 h114, % name
return
solo:
frozen := true
GuiControl, +Disabled, btn1
; random, timeout, 8500, 10000
; timeout += A_TickCount
timeout := A_TickCount + 10000
settimer, wait, 1
Process_Suspend(proc)
return
wait:
rest := timeout - A_TickCount
secs := round(rest / 1000, 3)
if rest <= 0
{
frozen := false
settimer, wait, off
GuiControl, move, info, x50 y9 w420 h20
GuiControl,, info, You've gone solo! Now you can safely exit the program.
GuiControl,, btn2, Exit
Process_Resume(proc)
; ExitApp
} else {
GuiControl, move, info, x120 y9 w420 h20
GuiControl,, info, It will be ready in %secs% seconds...
}
return
GuiClose:
GuiEscape:
if frozen
{
MsgBox, 51, %name%, The game is still suspended. If you leave now`, it will be resumed.`nYou better wait until it's done.`n`nAre you sure you still want to exit?
ifmsgbox yes
{
Process_Resume(proc)
ExitApp
}
return
}
ExitApp
Process_Suspend(PID_or_Name){
PID := (InStr(PID_or_Name,".")) ? isProcess(PID_or_Name) : PID_or_Name
h:=DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", pid)
If !h
Return -1
DllCall("ntdll.dll\NtSuspendProcess", "Int", h)
DllCall("CloseHandle", "Int", h)
}
Process_Resume(PID_or_Name){
PID := (InStr(PID_or_Name,".")) ? isProcess(PID_or_Name) : PID_or_Name
h:=DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", pid)
If !h
Return -1
DllCall("ntdll.dll\NtResumeProcess", "Int", h)
DllCall("CloseHandle", "Int", h)
}
isProcess(PID_or_Name=""){
Process, Exist, % (PID_or_Name="") ? DllCall("GetCurrentProcessID") : PID_or_Name
Return Errorlevel
}