Close unwanted windows when they appear

Ask gaming related questions
Bluscream
Posts: 15
Joined: 10 Jan 2017, 23:12
GitHub: Bluscream

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: 4111
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: 15
Joined: 10 Jan 2017, 23:12
GitHub: Bluscream

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
Bluscream
Posts: 15
Joined: 10 Jan 2017, 23:12
GitHub: Bluscream

Re: Close unwanted windows when they appear

19 Feb 2018, 20:28

Okay, i think https://gist.github.com/Bluscream/119f0 ... nclose-ahk is good enough for me. Thanks anyway :)

Return to “Gaming”

Who is online

Users browsing this forum: Bing [Bot] and 16 guests