Close unwanted windows when they appear

Ask gaming related questions (AHK v1.1 and older)
Bluscream
Posts: 16
Joined: 10 Jan 2017, 23:12
Contact:

Close unwanted windows when they appear

19 Feb 2018, 05:43

Code: Select all

#SingleInstance, Force
#NoEnv
#Warn
SetWorkingDir %A_ScriptDir%

titles := "Cheat Engine 6.7"
classes := "ClassAdvert, MainFrameInstall"
binaries := "clover.exe"

Loop
{
	WinWait, , , , .
    WinGetTitle, title
    TrayTip, found window %title%
    if title in %titles%
        WinClose, %title%
        continue
    WinGetClass, class
    if class in %classes%
        WinClose, ahk_class %class%
        continue
    WinGet, exe, ProcessName
    if exe in %binaries%
        MsgBox, %exe%
        WinClose, ahk_exe %exe%
        continue
}
Can anyone help me getting this to work?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Close unwanted windows when they appear

19 Feb 2018, 06:11

Code: Select all

#Persistent
#SingleInstance, Force

SetTimer, Kill,% 1000 * 1 ; check once every second
Return

Kill:
   Process, Exist, clover.exe
   If ErrorLevel
      PID := ErrorLevel
   Process, Close,% "ahk_PID " . PID
   Return
Not tested.
Bluscream
Posts: 16
Joined: 10 Jan 2017, 23:12
Contact:

Re: Close unwanted windows when they appear

19 Feb 2018, 19:10

A timer is exactly what i don't want, i really want it to only go through the loop when a new window opens

i tried LastFound now but that doesn't seem to change anything:

Code: Select all

#SingleInstance, Force
; #NoTrayIcon
#NoEnv
#Warn
SetWorkingDir %A_ScriptDir%

titles := "Cheat Engine 6.7"
classes := "ClassAdvert, MainFrameInstall"
binaries := "clover.exe"

Loop
{
	WinWait, , , , .
    WinGetTitle, title, LastFound
    TrayTip, found window %title%
    if title in %titles%
        WinClose, %title%
        continue
    WinGetClass, class, LastFound
    if class in %classes%
        WinClose, ahk_class %class%
        continue
    WinGet, exe, ProcessName
    if exe in %binaries%
        MsgBox, %exe%
        WinClose, ahk_exe %exe%
        continue
}
BTW: the binaries are not so important, i can use ProcessLasso for that

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: jameswrightesq and 162 guests