Need help with GUI.

Ask gaming related questions (AHK v1.1 and older)
Oblivion Deleted
Posts: 2
Joined: 11 Apr 2021, 05:14

Need help with GUI.

Post by Oblivion Deleted » 18 May 2022, 14:06

Hello, I need help to make two checkbox enable/disable a looped script (set by timer).
The script looks for an image and if found or not sends a key.
Thank you very much in advance. :thumbup:

Code: Select all

#IfWinActive, ahk_class Qt5QWindowOwnDCIcon
#NoEnv
#Warn
#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
ListLines Off
SendMode Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
Thread, interrupt, 0
Process, Priority,, High
Thread, NoTimers, true

Gui, Add, CheckBox, vCB1 gUtani, Utani
Gui, Add, CheckBox, vCB2 gUtito, Utito
Gui, Show
return
GuiClose:
 ExitApp



Utito:
 Gui, Submit, NoHide
 if (CB1)
   SetTimer, Utito1, 500 ;ms
 else
   SetTimer, Utito1, Off
return

Utito1:
If WinActive("ahk_class Qt5QWindowOwnDCIcon")
{
	ImageSearch, BuffX, BuffY, A_ScreenWidth - 368, 0, A_ScreenWidth, A_ScreenHeight - A_ScreenHeight + 480, *35, Imagens\Strengthen.png
	If ErrorLevel = 1
	{
		Send, {-}
		Sleep 200
	}
}
return

Utani:
 Gui, Submit, NoHide
 if (CB2)
   SetTimer, Utani1, 200 ;ms
 else
   SetTimer, Utani1, Off
return

Utani1:
If WinActive("ahk_class Qt5QWindowOwnDCIcon")
{
	ImageSearch, HurX, HurY, A_ScreenWidth - 368, 0, A_ScreenWidth, A_ScreenHeight - A_ScreenHeight + 480, *35, Imagens\Hur.png
	If ErrorLevel = 1
	{
		Send, {F6}
		Sleep 200
	}
	ImageSearch, LyzeX, LyzeY, A_ScreenWidth - 368, 0, A_ScreenWidth, A_ScreenHeight - A_ScreenHeight + 480, *35, Imagens\paralyze.png
	If ErrorLevel = 0
	{
		Send, {F1}
		Sleep 200
	}
}
return

The script works without gui, but I'm having trouble getting it to work.
Here is the example, but I would like the gui to be able to activate or deactivate functions, it would be great.

Code: Select all

#IfWinActive, ahk_class Qt5QWindowOwnDCIcon
#NoEnv
#Warn
#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
ListLines Off
SendMode Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
Thread, interrupt, 0
Process, Priority,, High
Thread, NoTimers, true


SetTimer, Utani, 500		
SetTimer, Utito, 200

Utani:
If WinActive("ahk_class Qt5QWindowOwnDCIcon")
{
	ImageSearch, HurX, HurY, A_ScreenWidth - 368, 0, A_ScreenWidth, A_ScreenHeight - A_ScreenHeight + 480, *35, Imagens\Hur.png
	If ErrorLevel = 1
	{
		Send, {F6}
		Sleep 200
		goto, Utani
	}
	ImageSearch, LyzeX, LyzeY, A_ScreenWidth - 368, 0, A_ScreenWidth, A_ScreenHeight - A_ScreenHeight + 480, *35, Imagens\paralyze.png
	If ErrorLevel = 0
	{
		Send, {F1}
		Sleep 200
		goto, Utani
	}
}
return

Utito:
If WinActive("ahk_class Qt5QWindowOwnDCIcon")
{
	ImageSearch, BuffX, BuffY, A_ScreenWidth - 368, 0, A_ScreenWidth, A_ScreenHeight - A_ScreenHeight + 480, *35, Imagens\Strengthen.png
	If ErrorLevel = 1
	{
		Send, {-}
		Sleep 200
		goto, Utito
	}
}
return

User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: Need help with GUI.

Post by mikeyww » 18 May 2022, 19:06

One approach to debugging your script would be to display the values of each variable, function, and conditional statement. That could help you to pinpoint the problem quickly.

Rohwedder
Posts: 7556
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need help with GUI.

Post by Rohwedder » 20 May 2022, 01:04

Hallo,
replace:

Code: Select all

Gui, Add, CheckBox, vCB1 gUtani, Utani
Gui, Add, CheckBox, vCB2 gUtito, Utito
by:

Code: Select all

Gui, Add, CheckBox, vCB2 gUtani, Utani
Gui, Add, CheckBox, vCB1 gUtito, Utito

Post Reply

Return to “Gaming Help (v1)”