jsteng Posted December 31, 2018 Share Posted December 31, 2018 Hi, I am writing a script that closes error popups on windows. The error popups always appear as [CLASS:#32770] and thus I wrote this: #RequireAdmin while 1 _CloseErrorPopUps() sleep(100) wend Func _CloseErrorPopUps() if WinExists("[CLASS:#32770]") then local $title = WinGetTitle("[CLASS:#32770]") local $pid = WinGetProcess ( $title ) ControlSend($title, "", "Button1", "{ESC}") ;close the popup tooltip($pid & ' ' & $title) endif endfunc However, I soon realize that some other non-error processes use [CLASS:#32770]. a system service igfxem.exe for instance exists in one of my machine and contains this [class#32770] that could not be closed. My question is: 1. Is there a way to use WinExists to filter only [CLASS:#32770] with Button1? If so how? or 2. Must I use an exhaustive one-by-one approach of listing all the error popups instead? if WinExists('[CLASS:#32770]', 'out of bound error') then . if WinExists('[CLASS:#32770]', 'Autoit Error') then . . . . . thanks. j Link to comment Share on other sites More sharing options...
AutoPM Posted December 31, 2018 Share Posted December 31, 2018 what about the title of that error popup. Use Title instead of [CLASS:#32770], If there is no title. do this when error pops up. open task manager Locate that error application, check it's properties, A name will be there like "whatever_error.EXE" Now Write Something like this #RequireAdmin Func _CloseErrorPopUps() If ProcessExists("whatever_error.EXE") Then Sleep(200) ProcessClose("whatever_error.EXE") Sleep(200) EndIf EndFunc Also If you Want to Use WinExist It Has A Text Part after title name, WinExists ( "title" [, "text"] ) Use text to Define Exactly what window you want to check if exist The window text consists of all the text that AutoIt can "see". This will usually be things like the contents of edit controls (as above with "This is some text!") but will also include other text like: Button text like &Yes, &No, &Next (the & indicates an underlined letter) Dialog text like "Are you sure you wish to continue?" Control text Misc text - sometimes you don't know what it is Check Help File For More Details. Link to comment Share on other sites More sharing options...
mikell Posted January 1, 2019 Share Posted January 1, 2019 You might check both if class is #32770 and if the word "error" exists in the title, or the text of the button in the text, or all together WinExists("[CLASS:#32770; REGEXPTITLE:(?i)(.*error.*)]", "OK") TOOD and kcvinu 1 1 Link to comment Share on other sites More sharing options...
AutoBert Posted January 1, 2019 Share Posted January 1, 2019 Study this small script: ; Open a browser with the basic example page, insert an ; event script into the head of the document that creates ; a JavaScript alert when someone clicks on the document #include <IE.au3> Local $oIE = _IE_Example("basic") _IEHeadInsertEventScript($oIE, "document", "onclick", "alert('Someone clicked the document!');") AdlibRegister('CloseAlert', 1000) $tdStart = TimerInit() While TimerDiff($tdStart) < 60000 Sleep(1000) WEnd _IEQuit($oIE) Func CloseAlert () Sleep(3000) ControlClick('[CLASS:#32770]', 'Someone clicked the document!', 2) EndFunc ;==>CloseAlert after example is shown ckick into brower document. 3 sec's later the shown alert is closed. TOOD 1 Link to comment Share on other sites More sharing options...
kcvinu Posted July 16, 2020 Share Posted July 16, 2020 On 1/1/2019 at 2:38 PM, mikell said: You might check both if class is #32770 and if the word "error" exists in the title, or the text of the button in the text, or all together WinExists("[CLASS:#32770; REGEXPTITLE:(?i)(.*error.*)]", "OK") Thanks a lot @mikell This single line code saved me. After hours of failed attempts, at last, i can click on message box button. I didn't knew that we can use reg exp title inside a string this. TOOD 1 Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) 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