winclose not working

Ask gaming related questions (AHK v1.1 and older)
axo
Posts: 32
Joined: 10 May 2022, 10:50

winclose not working

Post by axo » 03 Jul 2022, 06:14

i have this code :

Code: Select all

gui, add, DropDownList, x180 y50 w200  vAB1 , head|chest|legs
gui, add, DropDownList, x180 y125  w200  vAB2 , legit|rage
gui,add,checkbox,gAB1 vAB c0583FD x180 y165, ab
gui, show
return

AB1:
{
GuiControlGet, Checked,,Ab
If (Checked == 1)    
{
   Gui, Submit, nohide
   run %AB1%.%AB2%.ahk
   return
}
If (Checked == 0)     
{
DetectHiddenWindows, On
SetTitleMatchMode, 2
Loop {
winclose, head.legit.ahk
winclose, head.rage.ahk
winclose, chest.legit.ahk
winclose, chest.rage.ahk
winclose, legs.legit.ahk
winclose, legs.rage.ahk
IfWinNotExist, head.legit.ahk
IfWinNotExist, head.rage.ahk
IfWinNotExist, chest.legit.ahk
IfWinNotExist, chest.rage.ahk
IfWinNotExist, legs.legit.ahk
IfWinNotExist, legs.rage.ahk
 Break 
return
}
}
}
return
but when the checkbox = 1 the selected script run but when checkbox = 0 the selected script should close but the script wont close

head.legit.ahk:

Code: Select all


gui,add,text, c0583FD x1 y1, Select CS:GO recolution Width:
Gui, Add, DropDownList,x1 y15 w150 vVar1 , 1920||1440|1280|1152|1024|800
gui,add,text, c0583FD x1 y50, Select CS:GO recolution Height:
Gui, Add, DropDownList,x1 y65 w150 vVar2 , 1080||1024|960|864|768|600
gui,add,button, x60 y100 gselect, select
gui,color,1B1B1B
gui, show
return

select:
Gui, Submit


#NoEnv
#SingleInstance, Force
#InstallKeybdHook
#UseHook
#KeyHistory, 0
#HotKeyInterval 1
#MaxHotkeysPerInterval 127
SetKeyDelay,-1, -1
SetControlDelay, -1
SetMouseDelay, -1
SetWinDelay,-1
SendMode, InputThenPlay
SetBatchLines,-1
ListLines, Off
CoordMode, Pixel, screen
 
 
DllCall("QueryPerformanceFrequency", "Int64*", freq)
FlickBefore := 0
 
 
aim_key := "xbutton2" ;List of Keys: https://www.autohotkey.com/docs/KeyList.htm
 
game_sens := 0.31 ;Game sens
game_fov  := 103 ;Game fov
game_fps  := 84 ;Display refresh rate
 
 
;use this tool and set sensitivity and dpi to 1, then copy In/360 value https://gamingsmart.com/mouse-sensitivity-converter
;Apex Legends: 16363.64
;CSGO: 16363.64
;Halo Infinite: 17454.6
full360 := 16363.64/game_sens ;Modify it to the value of the corresponding game
 
EMCol := 0x ;Enemy color
ColVn := 10 ;Variation
OffsetX := 0
OffsetY := 4
ZeroX := Floor(Var1  // 2) - OffsetX
ZeroY := Floor(Var2 // 2) - OffsetY
CFovX := deg2coord(2, game_fov, Var1, Var2) ;aimbot fov x. range: 0 ~ game_fov/2
CFovY := deg2coord(2, game_fov, Var1, Var2) ;aimbot fov y. range: 0 ~ game_fov/2
SpeedX := 0.13 ;aimbot speed. range: 0 ~ 1
SpeedY := 0.13 ;aimbot speed. range: 0 ~ 1
ScanL := ZeroX - CFovX
ScanT := ZeroY - CFovY
ScanR := ZeroX + CFovX
ScanB := ZeroY + CFovY
 
 
Loop {
    KeyWait, %aim_key%, D
    AimPixel := _PixelSearch(ScanL, ScanT, ScanR, ScanB, EMCol, ColVn)
    if (!ErrorLevel) {
        AimX := AimPixel[1] - ZeroX
        ,AimY := AimPixel[2] - ZeroY
        ,MoveX := Floor(coord2deg(AimX, game_fov, Var1, Var2) * (full360/360) * SpeedX)
        ,MoveY := Floor(coord2deg(AimY, game_fov, Var1, Var2) * (full360/360) * SpeedY)
        DllCall("QueryPerformanceCounter", "Int64*", FlickAfter)
        if ((FlickAfter-FlickBefore)/freq*1000 >= 1000/game_fps) {
            DllCall("QueryPerformanceCounter", "Int64*", FlickBefore)
            DllCall("mouse_event", "uint", 0x0001, "uint", MoveX, "uint", MoveY, "uint", 0, "int", 0)
        }
    }
}
 
;full360 test
/*
F::
DllCall("mouse_event", "uint", 0x0001, "uint", 6666, "uint", 0, "uint", 0, "int", 0)
return
*/
 
_PixelSearch(X1, Y1, X2, Y2, ColorID, Variation:=0) {
    PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID, Variation, Fast RGB
    Return [OutputVarX, OutputVarY]
}
 
deg2rad(degrees) {
    return degrees * ((4*ATan(1)) / 180)
}
 
rad2deg(radians) {
    return radians * (180 / (4*ATan(1)))
}
 
coord2deg(delta, fov, winwidth, winheight) {
    ;lookAt := delta * 2 / winwidth
    ;return rad2deg(atan(lookAt*tan(deg2rad(fov*0.5)))) ;degrees
    return rad2deg(atan(((delta<<1)/winwidth)*tan(deg2rad(fov*0.5))))
}
 
deg2coord(delta, fov, winwidth, winheight) {
    return winwidth*0.5/tan(deg2rad(fov*0.5))*tan(deg2rad(delta))
}
 
 

F14::Exitapp


why the script wont close when i uncheck the checkbox ? can u help me ?

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

Re: winclose not working

Post by mikeyww » 03 Jul 2022, 06:39

How to debug a computer program?

You can start to debug this script as follows.
1. Write a separate three-line script demonstrating that you can close your target script.
2. In your main script, add a MsgBox just before the WinClose line. See if it appears.

The AHK documentation describes additional approaches to debugging, in case helpful.

In many situations, combining scripts is easier than trying to manage many concurrently running ones, especially if they are related.

axo
Posts: 32
Joined: 10 May 2022, 10:50

Re: winclose not working

Post by axo » 03 Jul 2022, 06:46

i added msgbox and yes it appears .... when i remove this from the head.legit.ahk

Code: Select all

gui,add,text, c0583FD x1 y1, Select CS:GO recolution Width:
Gui, Add, DropDownList,x1 y15 w150 vVar1 , 1920||1440|1280|1152|1024|800
gui,add,text, c0583FD x1 y50, Select CS:GO recolution Height:
Gui, Add, DropDownList,x1 y65 w150 vVar2 , 1080||1024|960|864|768|600
gui,add,button, x60 y100 gselect, select
gui,color,1B1B1B
gui, show
return

select:
Gui, Submit
then it works so it needs to be something here blocking it

axo
Posts: 32
Joined: 10 May 2022, 10:50

Re: winclose not working

Post by axo » 03 Jul 2022, 06:49

+when i use this script :

Code: Select all

DetectHiddenWindows, On
WinGet, AHKList, List, ahk_exe Autohotkey.exe
Loop, %AHKList%
	IF (A_ScriptHwnd <> ID := AHKList%A_Index%)
		WinClose, ahk_id %ID%
ExitApp
then it close the script, but it close every script running in background not only head.legit.ahk

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

Re: winclose not working

Post by mikeyww » 03 Jul 2022, 06:58

So you are now getting somewhere. You can focus on your "head" script, simplifying, shortening, & re-testing it, to determine the specific issue.

axo
Posts: 32
Joined: 10 May 2022, 10:50

Re: winclose not working

Post by axo » 03 Jul 2022, 07:47

i have it

Post Reply

Return to “Gaming Help (v1)”