Jump to content
Sign in to follow this  
MFrancisca

Can't kill error message

Recommended Posts

MFrancisca
Posted (edited)

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

Share this post


Link to post
Share on other sites
MFrancisca

This is the specific window that is giving me headaches:

 image.png.d7b61edf62caa0219238b638882dfc70.png

Is there any chance that there is some hidden parameter that is blocking the window from being closed? 

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
MFrancisca

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 <<<<

 

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
MFrancisca
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? 

Share this post


Link to post
Share on other sites
water

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

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
MFrancisca
Posted (edited)
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

Share this post


Link to post
Share on other sites
MFrancisca

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

Share this post


Link to post
Share on other sites
water
12 hours ago, MFrancisca said:

Which one is? 

_OL_Warnings.au3


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • FMS
      By FMS
      Hello,

      I'm having a problem whit winwait on firefoxscreens whit the same title and text.
      On mine quest on this forum and internet I've found some work around and solutions.
      unfortunaly This wasn't working for me.

      I've tried searching tru winlist or finding some unique text but wasn't finding any solution.
      Does anyone know how to get the wright handle?
      I just want to move the browser to the right place in the end whit WinMove.

      thnx in advanced.

       
      #include <Array.au3> Global $A_URL[4][2] = _ [["url1" , "same_title"] , _ ["url2", "same_title"] , _ ["url3" , "other_title" ] , _ ["url4" , "other_title" ]] ;~ _ArrayDisplay($A_URL) ;-----kill all firefox.exe ;~ Run("taskkill /IM firefox.exe /F", "", @SW_HIDE) ;Sleep(5000) For $i = 0 To 1 ConsoleWrite("running 1 : " & $i & @CRLF) Local $ID = ShellExecute("firefox.exe", "-new-window " & $A_URL[$i][0] ,"C:\Program Files\Mozilla Firefox" ) ConsoleWrite("$ID = " & $ID & @CRLF) Next sleep(200) ;~ Local $screen1HWND = WinWait($A_URL[0][1],"") ;~ If Not WinActive($screen1HWND) Then WinActivate($screen1HWND) ;~ ConsoleWrite("$screen1HWND = " & $screen1HWND & @CRLF) ;~ Local $screen2HWND = WinWait($A_URL[1][1],"") ;~ If Not WinActive($screen2HWND) Then WinActivate($screen2HWND) ;~ ConsoleWrite("$screen2HWND = " & $screen2HWND & @CRLF) $sWinTitle = $A_URL[0][1] $avWinList = WinList($sWinTitle) For $n = 1 to $avWinList[0][0] ConsoleWrite("Window " & $n & ": Text: " & WinGetText($avWinList[$n][1]) & @LF) Next For $i = 0 To 1 ;~ WinWait("title1", "", 10) ;~ WinActive("title1", "") ;~ WinMove ("title1", "", $i , $i ) Next  
    • ur
      By ur
      if ControlClick("[CLASS:MsiDialogCloseClass]"," ","[CLASS:SysTreeView32; INSTANCE:1]") Then $htreeview=ControlGetHandle($hwnd,"","[CLASS:SysTreeView32; INSTANCE:1]") ControlTreeView($hwnd," ",$htreeview,"Select","#4") The above code worked well to enable the martupgrade feature on windows 7.
      As part of our Installation Testing Automation before delivering the installer to end user.To confirm whether all the screens are working good.

      But it is not working on windows 10.
       
      $h= ControlTreeView($hwnd," ",$htreeview,"Select","#4") The $h is getting value 1,which means error.
    • ur
      By ur
      I have automated an install process by using the below code.
       
      Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc $win1 = "Text 1" $win2 = "Text 2" _WinWaitActivate($win1,"WARNING: This progra") Send("{ALTDOWN}n{ALTUP}");Send("{SPACE}") _WinWaitActivate($win1,"I DISAGREE and &do n") Send("{UP}n") _WinWaitActivate($win1,"Customer Information") Send("{ALTDOWN}n{ALTUP}");Send("{TAB}{TAB}n") _WinWaitActivate($win1,"Click Next to instal") Send("{ALTDOWN}n{ALTUP}");Send("n") _WinWaitActivate($win1,"This feature require") Send("{ALTDOWN}n{ALTUP}");Send("{TAB}n") _WinWaitActivate($win1,"Ready to Install the") Send("{ALTDOWN}i{ALTUP}");Send("i") _WinWaitActivate($win1,"The InstallShield Wi") Send("{ALTDOWN}f{ALTUP}");Send("f") _WinWaitActivate($win2,"You must restart you") Send("{ALTDOWN}n{ALTUP}");Send("n") Now if any new screen comes in the middle of installation, like some VC++ installation error or like that.
      The AutoIT is waiting in the background.
      Is there any way to skip the new screens with just "enter" and continue the installation??
    • TheInfamousOne
      By TheInfamousOne
      I have a small exe I created in AutoIt that seems to be causing some problems in OutLook when people go to save a PDF or Reply to emails.

      Here is my code.
       
      TraySetState(2) WinWait("[CLASS:#32770]", "Make sure that your sign-in address, user name, and password are correct and try again.", 0) WinClose( "Lync")  
      So this works just fine, it closes these message prompts we are trying to suppress.  But if the autoit executable is running when someone is using Outlook and they go to Save as PDF.  When they click "Save As" and go to type in the name of the file to save, they can't type in the box.  So if they close the autoit executable that's running only the code above, then they can use type in the name of the file.  So we know the EXE is preventing users from saving documents.

      Now, I'm sure it could be the way I've written this code, but I'm new to AutoIt and I'm not sure what could be causing this.  This little script seems like it' targeting the correct CLASS # and Window TItle and exact message.  So I don't understand why it's interfering with other applications.

      Any ideas?
×