Jump to content

Is there a way to detect if an error box pops up from another application and then hit enter?


Recommended Posts

We have a service account that runs on a server that facilitates the importing of orders from our web store in to our internal accounting system. The problem is that if all licenses are used up, and the application tries to do the import it will fail if there is not a free license. This causes a single error box to pop up. All that has to be done is hit enter on this box, and the next time the schedule is set to run it will just continue as normal.

Is there a way AutoIT can detect this box and then simply hit enter on it so the application can resume? There are times that it takes a whole day before it is realized that this issue has occurred, it would be great if it could just continue on.

Thanks!

Link to comment
Share on other sites

_WinAPI_GetWindow(), option 6 (enabled popup)

Retruns handle = 0x0000000 when no popup, or the popup handle when it is.

I am not sure exactly how to utilize this, but now that I at least have some commands to go by I can probably just research the rest. I appreciate it.

Link to comment
Share on other sites

ah, 10 posts.

Use WinGetHandle, to get the handle of your window (must be the parent window), and use that handle in the function I provided, with the second param = 6.

That function requires: #include <WinAPI.au3>

Search the forum = sample scripts for WinAPI.au3, to download it

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

ah, 10 posts.

Use WinGetHandle, to get the handle of your window (must be the parent window), and use that handle in the function I provided, with the second param = 6.

That function requires: #include <WinAPI.au3>

Search the forum = sample scripts for WinAPI.au3, to download it

Ok thanks, I appreciate it.

Link to comment
Share on other sites

hi killmenext

(another way to try)

I think i had one similar problem, ()

if you know the handle of the main program, ($mainpid) then you know if a popup windows msgbox (or also errorbox?) was opened by the main program (parent) using this command:

$pid = WinGetProcess("Title of errorbox")

the errorbox belongs to main program if this $pid = $mainpid

; example (not tested)

$mainpid = WinGetProcess("Title of main app")

while True
if winExists("Title of errorbox") then
if $mainpid = WinGetProcess("Title of errorbox") then
WinClose("Title of errorbox")
endif
endif

Sleep(5000)

WEnd

.. hope it works..

bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Or, to dynamically grab ANY popup of the main window (most all are Class:#32770)

But this loop does (almost) exactly what the function I pointed out above does in one line:

$mainpid = WinGetProcess("Title of main app")
While True
$array = WinList("[CLASS:#32770]")

For $i = 1 To UBound($array)-1
    If $mainpid = WinGetProcess($array[$i][1]) Then
     MsgBox(1,1,"Child popup found with title=[" & WinGetTitle($array[$i][1]) & "].",3)
     WinClose($array[$i][1])
    EndIf
Next
Sleep(5000)
WEnd

hey! interesting, the tabs ^ stay (reasonably), when you include 2 tabs for each tab you have in scite....even after multiple edits

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

hi killmenext

(another way to try)

I think i had one similar problem, ()

if you know the handle of the main program, ($mainpid) then you know if a popup windows msgbox (or also errorbox?) was opened by the main program (parent) using this command:

$pid = WinGetProcess("Title of errorbox")

the errorbox belongs to main program if this $pid = $mainpid

; example (not tested)

$mainpid = WinGetProcess("Title of main app")

while True
if winExists("Title of errorbox") then
if $mainpid = WinGetProcess("Title of errorbox") then
WinClose("Title of errorbox")
endif
endif

Sleep(5000)

WEnd

.. hope it works..

bye

Let me know if I am doing this correctly. I downloaded an error generating program just to try and test this, but it does not seem to be working. Blow is exactly what I put in to a new script window, am I missing anything? The title of the process is exactly as it shows when I open task manager, and at the top of the command prompt.

http://puu.sh/2tPrW

$mainpid = WinGetProcess("Administrator: C:\Windows\system32\cmd.exe - zenmsg.exe -e -n Error1")

while True
if winExists("Error1") then
if $mainpid = WinGetProcess("Error1") then
WinClose("Error1")
endif
endif

Sleep(500)

WEnd
Edited by killmenext
Link to comment
Share on other sites

hi killmenext

maybe your problem is easier than I thought

if you just have to close one errorbox, then is simpler to use a single statement like you made:

WinClose("Error1")

I was thinking that you had problem to exactly identify an errorbox among many so to be sure to close only the one spawned by a specific program.

however, (just to test)

the code to check the id of a program and that of his errorbox should work, try entering a command ConsoleWrite() to check the two values returned as indicated below, both values ​​should be equal:

$mainpid = WinGetProcess("Administrator: C:\Windows\system32\cmd.exe - zenmsg.exe -e -n Error1")

ConsoleWrite($mainpid & @CRLF) ; <-- check variable value

while True
if winExists("Error1") then

ConsoleWrite(WinGetProcess("Error1") & @CRLF) ; <-- check variable value

if $mainpid = WinGetProcess("Error1") then
WinClose("Error1")
endif

endif

Sleep(500)

WEnd

bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

This is a little AutoIt application that I wrote a few years ago and recently posted in the examples forum. It can be run in the background to deal with any unwanted windows.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...