AutoHotkey Community

It is currently May 27th, 2012, 11:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Detect Error Window
PostPosted: September 22nd, 2010, 12:07 pm 
Offline

Joined: September 22nd, 2010, 11:49 am
Posts: 7
Context:
The software I use at work sucks. It has a lot of unhandled exceptions
and the default error msg has a "Quit" button that, if pressed, kills the process and loses any finished work.

Idea:
Detect when one of those error messages apear and stop any user input or force the closing of those message boxes without touching the "Quit" button.

Problem:
Don't know how to do it. I can find windows and manipulate them. But I have no Idea how to "listen" for one. Any ideas?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2010, 12:27 pm 
Offline

Joined: February 7th, 2008, 9:48 pm
Posts: 509
I have this running to close warnings from firewall that someprogram has changed components.

Code:
#Persistent
#NoTrayIcon
SetTitleMatchMode 2

Loop
{
    WinWait,Warning:
    IfWinExist,Warning:
sleep 1000
        Send,{Enter}

sleep 1000
}

return


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks
PostPosted: September 22nd, 2010, 12:42 pm 
Offline

Joined: September 22nd, 2010, 11:49 am
Posts: 7
Thanks I'll give it a try. Maybe with a smaller sleep time.
I'll have to check the sistem monitor in case the script si too resource hungry to worth it.

:)

UPDATE:
I HATE THE GUY WHO MADE MY JOB'S SOFTWARE

The error message doesn't even have a title. So it defaults to the same title as the main window from the same software. So I can't separate the main window from the error message box.

Ideas? I'll keep trying.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2010, 12:54 pm 
Offline

Joined: February 7th, 2008, 9:48 pm
Posts: 509
Because the loop is not running unless the window with matching title pops up it does not consume cpu time.

I have the 1 sec wait so i can read the warning and act if for some reason it is important ! ( if i am watching the screen............)


Try using window spy and see if it has a different class name or if you can read text and use exclude or use the text to differentiate.


WinWait [, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2010, 1:06 pm 
Offline

Joined: September 22nd, 2010, 11:49 am
Posts: 7
Quote:
Try using window spy and see if it has a different class name or if you can read text and use exclude or use the text to differentiate.


WinWait [, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText]


Great Idea I'll see what I can do.
Thanks Again. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2010, 8:45 pm 
Offline

Joined: September 26th, 2007, 11:18 pm
Posts: 101
I have tried to adapt the code to a problem when I close MindManager appliccation, I get an error message, to be confirmed with "enter".

Code:
SetTitleMatchMode, 2   

#Persistent
Loop
{
    WinWait,ahk_class #32770:
    IfWinExist,ahk_class #32770:
        Send,{Enter}
sleep 1000
}
return


The window id is unique to this error msg window, but the code doesn't work. Any idea?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: maybe this helps
PostPosted: September 27th, 2010, 11:16 am 
Offline

Joined: September 22nd, 2010, 11:49 am
Posts: 7
@TOTAL:

How did you get the window id? I've read that with some software the window ID changes with every run. In my case the soft I'm trying to "help" sucks so bad that I can't get an ID to work with. So I used the error msg text instead.

Like this:

Code:
#Persistent
;#NoTrayIcon
SetTitleMatchMode 2

Loop
{
    WinWait,,Input string was not in a correct format.
    IfWinExist,,Input string was not in a correct format.
   ;sleep 100
   ControlClick, &Continue,,Input string was not in a correct format.
   sleep 1000
}
return


I did it that way because some OTHER error messages ARE useful so I want to read them. But every String not in a correct format msg is useless IN MY CASE

Hope this helps
PS: I love the bold tag.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2010, 6:43 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Related: WinTrigger

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject: WOW
PostPosted: September 28th, 2010, 9:44 am 
Offline

Joined: September 22nd, 2010, 11:49 am
Posts: 7
Well look at that...
Miles ahead.
Thank you very much Sr.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2010, 10:14 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
TOTAL wrote:
The window id is unique to this error msg window, but the code doesn't work. Any idea?
  1. As indicated by "ahk_class", that is a window class, not a window ID. (Semantics...)
  2. #32770 is the standard class name for a dialog box in Windows, and is shared by countless applications. Even AutoHotkey's MsgBox uses this class. (In fact, there is a good chance that your target application uses the very same API to show error messages.)
  3. The colon ( : ) at the end of the line has no special meaning, so your code is waiting for a window whose class is "#32770:".


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group