Prevent a pop up dialog from displaying

Get help with using AutoHotkey and its commands and hotkeys
Lem2001
Posts: 89
Joined: 27 Jun 2017, 17:59

Prevent a pop up dialog from displaying

14 Oct 2020, 10:19

I'm running a program that pops up a dialog after a manual search has been done. I would like this pop up dialog to not be displayed at all. However, the dialog is modal, so it has to be closed (rather than just hidden) otherwise the rest of the user interface becomes inaccessible.

I used WinWait to detect the presence of the dialog and then WinClose to close it. This works reliably, but there is an ugly flash of the dialog window before it is closed (and I'd like not to see it at all). The same visible dialog flash happens if I use WinHide.

I also need this auto-closing of the dialog to happen whenever the dialog appears (not just as a one-off).

Something could probably be done using timers, but I'd rather not have to use a constantly running fast-paced timer just to be able to catch the dialog window quickly enough, especially seeing as the dialog only ever appears in response to a press of the Search button (or activating it by hotkey). It might therefore be more efficient to run the timer only when that particular button (or hotkey) is pressed and then stop it after the dialog has been closed. Or maybe there's a cleaner simpler way that doesn't need timers at all?

I'm not sure how to put the various pieces together to achieve this outcome. Can anybody help?

Application Name: ahk_exe RegTune.exe
Dialog Name: Remove Errors ahk_class #32770
Search Hotykey: Ctrl + S
Search Button: Class(NN) XTPToolBar1 Name: Scan
User avatar
mikeyww
Posts: 2330
Joined: 09 Sep 2014, 18:38

Re: Prevent a pop up dialog from displaying

14 Oct 2020, 10:26

Yes. Create a hotkey that runs your search. The hotkey will do the following.

1. Execute the key sequence that activates your search.

2. WinWait for the dialog window.

3. WinClose when the dialog window appears.

4. Return

This works with no timers and no loops. I use this for an e-mail program that pops a dialog window after checking mail. My routine does exactly this to close the window.
User avatar
boiler
Posts: 6597
Joined: 21 Dec 2014, 02:44

Re: Prevent a pop up dialog from displaying

14 Oct 2020, 12:52

There's not much you can do to prevent it from flashing at all.

I don't see what's wrong with using a loop because it's not going to continuously loop while waiting since it stops at the WinWait until the window appears again. It's not taxing the CPU, and it doesn't require a hotkey:

Code: Select all

loop {
	WinWait, Remove Errors ahk_class #32770 ahk_exe RegTune.exe
	WinClose, Remove Errors ahk_class #32770 ahk_exe RegTune.exe
	WinWaitClose, Remove Errors ahk_class #32770 ahk_exe RegTune.exe
}
User avatar
SKAN
Posts: 853
Joined: 29 Sep 2013, 16:58

Re: Prevent a pop up dialog from displaying

14 Oct 2020, 14:08

Lem2001 wrote:I used WinWait to detect the presence of the dialog and then WinClose to close it. This works reliably, but there is an ugly flash of the dialog window before it is closed (and I'd like not to see it at all). The same visible dialog flash happens if I use WinHide.
The flashing can't be totally avoided.
If you aren't already using SetWinDelay, try it. There usually is a 100ms delay inserted between WinWait and WinClose.
My WinCloseAuto() would be slightly faster.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bibliocrat, JoeWinograd, mikeyww, nutnutwin, TAC109 and 51 guests