I have a window that just won't close. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

I have a window that just won't close.

Post by LAPIII » 20 Mar 2022, 17:46

Help me try to close a Advanced SystemnCare. It won't close with control w, only alt F4. The Send and Click says that only SendRaw, SendInput, SendPlay, and ControlSend work. I tried each like:

Code: Select all

#IfwinActive ahk_exe ASC.exe
^w::SendRaw !{F4}

Code: Select all

#IfwinActive ahk_exe ASC.exe
^w::SendInput !{F4}

Code: Select all

#IfwinActive ahk_exe ASC.exe
^w::SendPlay !{F4}

Code: Select all

#IfwinActive ahk_exe ASC.exe
^w::ControlSend, TPanel5, !{F4}
And with the class and #If directive after each script. I even tried:

Code: Select all

#if WinExist("ASC.exe")
    WinKill ASC.exe 
[code]#if WinExist("ASC.exe")
    WinClose ASC.exe 
Any ideas?

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

Re: I have a window that just won't close.

Post by mikeyww » 20 Mar 2022, 17:53

Perhaps:

Code: Select all

If !A_IsAdmin && !(DllCall("GetCommandLine", "str") ~= " /restart(?!\S)") {
 Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
 ExitApp
}
winTitle = ahk_exe ASC.exe
#If WinActive(winTitle)
^w::WinKill
#If

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: I have a window that just won't close.

Post by LAPIII » 20 Mar 2022, 17:56

It worked! :P

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: I have a window that just won't close.

Post by LAPIII » 20 Mar 2022, 18:03

Can I use more than one application in the script?

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

Re: I have a window that just won't close.

Post by mikeyww » 20 Mar 2022, 18:08

Yes, an unlimited number.

Code: Select all

GroupAdd, close, ahk_exe notepad.exe
GroupAdd, close, ahk_exe chrome.exe
#IfWinActive ahk_group close
^w::WinClose
#IfWinActive

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: I have a window that just won't close.

Post by LAPIII » 20 Mar 2022, 18:22

How? I tried adding a winTitle line below line 5 and it didn't work. I tried to copy the whole thing in replacing the exe, but eventually gave an error that said Same hotkey

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

Re: I have a window that just won't close.

Post by mikeyww » 20 Mar 2022, 18:23

Use the last script that I posted. You can change the WinTitle entries in the GroupAdd commands.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: I have a window that just won't close.

Post by LAPIII » 25 Jun 2022, 19:00

I want to try and close a File Upload window with AHK. This one is in Waterfox and has the same process and class, but It does have a ClassNN: DirectUIHWND2.

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

Re: I have a window that just won't close.

Post by mikeyww » 25 Jun 2022, 19:08

Running Window Spy will help you to retrieve the window title and other WinTitle elements.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: I have a window that just won't close.

Post by LAPIII » 25 Jun 2022, 19:42

!{F4} closes this window. I had tried:

Code: Select all

#IfWinActive ahk_group close
GroupAdd, close, ahk_exe waterfox.exe, File Upload
Send !{F4}
#IfWinActive
I had also replaced ahk_exe waterfox.exe with the class and Send !{F4} with:

Winclose
WinKill

I tried all these with:

Code: Select all

if not A_IsAdmin
{
  Run *RunAs "%A_ScriptFullPath%"
  ExitApp
}

Nothing works.

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

Re: I have a window that just won't close.

Post by mikeyww » 25 Jun 2022, 20:46

If you want a hotkey trigger, then add a hotkey.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: I have a window that just won't close.

Post by LAPIII » 26 Jun 2022, 01:52

Still won't work:

Code: Select all

#IfWinActive ahk_group close
GroupAdd, close, ahk_exe waterfox.exe, File Upload
^w::Send !{F4}
#IfWinActive

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

Re: I have a window that just won't close.

Post by mikeyww » 26 Jun 2022, 06:23

Post a screenshot of Window Spy when your target window is active.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: I have a window that just won't close.

Post by LAPIII » 26 Jun 2022, 06:28

jdBkz6xMB2.png
jdBkz6xMB2.png (251.3 KiB) Viewed 795 times

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

Re: I have a window that just won't close.  Topic is solved

Post by mikeyww » 26 Jun 2022, 07:00

Could try:

Code: Select all

GroupAdd, close, File Upload ahk_exe waterfox.exe
#IfWinActive ahk_group close
^w::WinClose
#IfWinActive
Please read some documentation. :arrow: WinTitle

In Window Spy, window titles are shown at the top; window text is shown at the bottom.

Post Reply

Return to “Ask for Help (v1)”