Jump to content

Can't kill error message


Recommended Posts

OK, after days looking at my code, the help file and forums I come (again) for help on message windows.

I'm having trouble trying to close window messages that appear. This is the code I'm using

#include <MsgBoxConstants.au3>

Local $obs_handler = 0
Opt("WinTitleMatchMode",2)

While 1
    $obs_handler = WinWait("C:\Users\", "", 1)
    If IsHWnd($obs_handler) then
        MsgBox($MB_OK, "Message", "handler: "&$obs_handler, 1)
        ;Sleep(100)
        $obs_handler = HWND($obs_handler)
        WinKill($obs_handler, "") ;<<<<< PROBLEM!!!!!
    Else
        MsgBox($MB_OK, "Message", "No handler", 1)
    EndIf
    Send("{ESC}")
    Sleep(2000)
    $obs_handler = 0
WEnd

The problem is on the Winkill command, it won't just close the window! 

Winwait is capturing the handler, it checks as handler. Ii'm using the HWND() command just to be sure it is the correct variable type.  I've also checked the message box info with the autoit window info tool and the handle value matches the one captured by the code. 

I've tried winkill, winclose, using wingethandle, moving the winkill command to Before the message box so it is not converted to a string, and now using the hwnd function to force the variable type of the handler. The use of the sleep command does not make any diference.

As a side quest, I'd like to use classes to capture the windows instead of titles, just to keep things cleaner, but using the [CLASS:...] value for winwait is not working. I have the class name and number, am I missing something? 

 

Thanks! 

Edited by MFrancisca
Link to comment
Share on other sites

  • Moderators

Can you please post the information you get from the AutoIt Window Info Tool? Since this is generated by your redacted application it is a bit difficult to make guesses as to what information is available to you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

This is the summary from the AutoIT WinInfo

>>>> Window <<<<

Title: C:\Users\.......

Class: #32770

Position: 522, 345

Size: 562, 145

Style: 0x96C80284

ExStyle: 0x00010101

Handle: 0x000C05CC

>>>> Control <<<<

Class: DirectUIHWND

Instance: 1

ClassnameNN: DirectUIHWND1

Name:

Advanced (Class): [CLASS:DirectUIHWND; INSTANCE:1]

ID:

Text:

Position: 0, 0

Size: 556, 116

ControlClick Coords: 147, 42

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x00090538

>>>> Mouse <<<<

Position: 672, 413

Cursor ID: 0

Color: 0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

OK

>>>> Hidden Text <<<<

 

Link to comment
Share on other sites

According to the help file: Some windows (notably explorer windows) can only be terminated using WinClose().

So you might be forced to click the OK button or send Enter to the window. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

2 minutes ago, water said:

According to the help file: Some windows (notably explorer windows) can only be terminated using WinClose().

So you might be forced to click the OK button or send Enter to the window. 

 I did try Winclose to no avail... you are saying that I have to specifically send the OK command instead of using the function? 

Link to comment
Share on other sites

In my OutlookEX UDF you will find a function (used with _OL_Open) to click away security warnings 😃

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

1 hour ago, water said:

In my OutlookEX UDF you will find a function (used with _OL_Open) to click away security warnings 😃

Which one is? 

I tried ControlClick to send a click to the OK button, again is not working. 

I read in some thread that using Opt to gives windows inmunity to winkill, is that bug still there? 

 

Edited by MFrancisca
Link to comment
Share on other sites

Ok, Just to leave it on record, it looks like the Opt function is still bugged! And it is not only with the GUI option, but also affected by the Title Match option

Out of curiosity I took off that line and the script is now working flawlessly.

 

Thanks for the help and advice

Link to comment
Share on other sites

12 hours ago, MFrancisca said:

Which one is? 

_OL_Warnings.au3

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...