nynepro Posted January 14, 2009 Share Posted January 14, 2009 Can somebody tell, how can I push the button on MsgBox without title... There is some program, which sometimes call MsgBox with 2 button's ("OK" and "Cancel") and there is no title here. I need to press Cancel button. Im trying ControlClick ("", "Cancel", "[CLASS:Button; INSTANCE:2]") or ControlClick ("", "Cancel", "Button2") or even ControlClick ("", "Cancel", "Button2", "left", 1, 317, 60) but its doesnt work... >>>> Window <<<< Title: Class: #32770 Position: 327, 463 Size: 633, 147 Style: 0x940001C5 ExStyle: 0x00010101 Handle: 0x002806C6 >>>> Control <<<< Class: Button Instance: 2 ClassnameNN: Button2 Advanced (Class): [CLASS:Button; INSTANCE:2] ID: 2 Text: Cancel Position: 317, 60 Size: 75, 23 ControlClick Coords: 17, 12 Style: 0x50010000 ExStyle: 0x00000004 Handle: 0x00300786 >>>> Mouse <<<< Position: 334, 72 Cursor ID: 2 Color: 0x250875 >>>> StatusBar <<<< >>>> Visible Text <<<< OK Cancel P.S. sry for my English Link to comment Share on other sites More sharing options...
FireFox Posted January 14, 2009 Share Posted January 14, 2009 @nynepro ControlClick("","","button2", 1) Cheers, FireFox. Link to comment Share on other sites More sharing options...
nynepro Posted January 14, 2009 Author Share Posted January 14, 2009 Thx, but still not work As I understand it tries to click in the wrong window.. And I don't know how to select this MsgBox with empty title.. Link to comment Share on other sites More sharing options...
FireFox Posted January 14, 2009 Share Posted January 14, 2009 @nynepro ControlClick("[CLASS:#32770]", '', "button2", 1) Cheers, FireFox. Link to comment Share on other sites More sharing options...
nynepro Posted January 15, 2009 Author Share Posted January 15, 2009 Thanks again, but main program has the same class name, and it's still don't work. Link to comment Share on other sites More sharing options...
Malkey Posted January 15, 2009 Share Posted January 15, 2009 The MsgBox() function halts the script until a button is pressed or until the end of the "timeout" parameter, This is one way the Msgbox button can be pressed. #include <Timers.au3> #include <WinAPI.au3> $hGUI = GUICreate("") GUISetState() $msgb = _Timer_SetTimer($hGUI, 500, "_Update"); create timer MsgBox(1, "", "First MsgBox"); Autoclicks First MsBox _Timer_KillTimer($hGUI, $msgb) MsgBox(1, "", "Second MsgBox"); Timer is not working for this MsgBox ; "#32770" being the Class name of the active MsgBox Func _Update($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime ;ConsoleWrite(WinGetHandle("") & @CRLF) If _WinAPI_GetClassName(WinGetHandle("")) = "#32770" Then ControlSend(WinGetHandle(""), '', "Button2", "{ENTER}"); EndFunc ;==>_UpdateStatusBarClock Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 15, 2009 Moderators Share Posted January 15, 2009 The MsgBox() function halts the script until a button is pressed or until the end of the "timeout" parameter, This is one way the Msgbox button can be pressed. #include <Timers.au3> #include <WinAPI.au3> $hGUI = GUICreate("") GUISetState() $msgb = _Timer_SetTimer($hGUI, 500, "_Update"); create timer MsgBox(1, "", "First MsgBox"); Autoclicks First MsBox _Timer_KillTimer($hGUI, $msgb) MsgBox(1, "", "Second MsgBox"); Timer is not working for this MsgBox ; "#32770" being the Class name of the active MsgBox Func _Update($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime ;ConsoleWrite(WinGetHandle("") & @CRLF) If _WinAPI_GetClassName(WinGetHandle("")) = "#32770" Then ControlSend(WinGetHandle(""), '', "Button2", "{ENTER}"); EndFunc ;==>_UpdateStatusBarClockI think you missed the point of him dealing with an application other than his own AutoIt app. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now