Jump to content

random popup windows


Recommended Posts

Hey guys, here is my scenario.

When running the app manually, popup windows appear without user intervention and no specific time. Assuming I want to track this popup windows(windowA, windowB and so on), what is the best way to monitor them? Should I use winexists inside a while 1 loop?

And I have another big crisis. This app that I'm talking about is suxpro, I mean, foxpro. :) The different window that pops up have the same window title but have different text in the window. Unfortunately, AutoIT Window Info is not able to grab the control of any object in that suxpro window. Also, the classnameNN of all the popups are the same :evil:

Thanks,

Neil

Link to comment
Share on other sites

I use Adlib function

You can have more than one condition in the Adlib Function you specify.

Example:

AdLibEnable("_PopUps")

; put normal code here

Exit

Func _PopUps()
    If WinExists("Title","Text") Then
       ; do somthing here
    EndIf

; handle a different window
    If WinExists("Title","Text") Then
       ; do something here
    EndIf
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I use Adlib function

You can have more than one condition in the Adlib Function you specify.

Example:

AdLibEnable("_PopUps")

; put normal code here

Exit

Func _PopUps()
    If WinExists("Title","Text") Then
      ; do somthing here
    EndIf

; handle a different window
    If WinExists("Title","Text") Then
      ; do something here
    EndIf
EndFunc

<{POST_SNAPBACK}>

Hi Gafrost,

Below is the flowchart of the application I'm using. How will you write the adlibenable function then?

1. Run the .exe

2. Gui is shown while loading some libraries via its background process

3. During the loading of libraries, an error window may pop up if backend database server is down or other issues such as network connectivity issue. The error window has a Quit and Return button. The classnameNN of this error window is re0002. Title of window shown is re2000.

4. If backend database server is good, it will display username/password dialog box. The classnameNN of this username/password window is re0002. Title of window shown is re2000.

5. User logs in successfully. It will display another window which will cache data from server to his local harddisk. The classnameNN of this cache window is is recache6002. Title of window shown is recache2000.

6. An error window may popup up if database tables or db og files are full which may prevent users from writing to it. They can read though from the tables. But we consider it as an error. This error window has a Quit and Return button. The classnameNN of this error window is re0002. Title of window shown is re2000.

The thing that sux(foxpro) is that, all child error window's title is re2000 and the classnameNN of those error windows are re0002.

I can use Insolence code to capture a text inside this error window and OCR it. Unfortunately, neither Spy++ nor AutoIT window info is able to get the name of controls inside this error window. :)

Please advise.

Thanks,

N

EDIT or ADDED message:

I tried this code and AdLibEnable only works once I have remove the semicolon comment in Msgbox(0,"","Adlib being tested"). Is this a bug?

AdLibEnable("_PopUps")

; put normal code here
;Msgbox(0,"","Adlib being tested")
Exit

Func _PopUps()
    If WinExists("Untitled - Notepad","") Then
      ; do somthing here
       Msgbox(0,"","Notepad has been loaded")
    EndIf

; handle a different window
    If WinExists("untitled - Paint","") Then
       Msgbox(0,"","Paint has been loaded")
    EndIf
EndFunc

or should I the code be written this way:

AdLibEnable("_PopUps")

Run("re2000.exe")

Exit

Func _PopUps()
    If WinExists("Untitled - Notepad","") Then
      ; do somthing here
       Msgbox(0,"","Notepad has been loaded")
    EndIf

; handle a different window
    If WinExists("untitled - Paint","") Then
       Msgbox(0,"","Paint has been loaded")
    EndIf
EndFunc
Edited by v1rtu0s1ty
Link to comment
Share on other sites

Probably more like:

AdLibEnable("_PopUps")

Run("re2000.exe")

ProcessWait("re2000.exe")

While(ProcessExists("re2000.exe"))
   Sleep ( 10 )
Wend

Exit

Func _PopUps()
    If WinExists("Untitled - Notepad","") Then
    ; do somthing here
       Msgbox(0,"","Notepad has been loaded")
    EndIf

; handle a different window
    If WinExists("untitled - Paint","") Then
       Msgbox(0,"","Paint has been loaded")
    EndIf
EndFunc
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Probably more like:

AdLibEnable("_PopUps")

Run("re2000.exe")

ProcessWait("re2000.exe")

While(ProcessExists("re2000.exe"))
   Sleep ( 10 )
Wend

Exit

Func _PopUps()
    If WinExists("Untitled - Notepad","") Then
    ; do somthing here
       Msgbox(0,"","Notepad has been loaded")
    EndIf

; handle a different window
    If WinExists("untitled - Paint","") Then
       Msgbox(0,"","Paint has been loaded")
    EndIf
EndFunc

<{POST_SNAPBACK}>

I tried this and it worked like a charm:

AdLibEnable("_PopUps")

Run("C:\Program Files\Adobe\Photoshop 5.5\Photoshp.exe")

ProcessWait("Photoshp.exe")

While(ProcessExists("Photoshp.exe"))
   Sleep ( 10 )
Wend

Exit

Func _PopUps()
    If WinExists("Help Topics: Adobe Photoshop 5.5 Help","") Then
      ; do somthing here
       Msgbox(0,"","Adobe Help shown")
    EndIf

; handle a different window
    If WinExists("Adobe Photoshop 5.0 Help","") Then
       Msgbox(0,"","Adobe Photoshop 5.0 Help")
    EndIf
EndFunc

So now for my real error window, I will have to add a SEND button to close that error window or else, it will keep on looping to that winexists code. That's what I have noticed in my code above. The msgbox didn't go away until I closed the help. :)

Why Sleep(10) though? I mean, why 10 ms and not 1000? Just making sure so I can really understand the code :evil:

Thanks!

Link to comment
Share on other sites

User preference.

<{POST_SNAPBACK}>

I was able to successfully modify and use Inolesence code from http://www.autoitscript.com/forum/index.ph...topic=8442&st=0. I have now my my own character definitions.

I would like to integrate his code with the code you gave me earlier. In which part of your code should his script be inserted? I'm thinking that the for $Scan..loop be called within the WinExists and all of the 3 functions(Getlines, GetCharacters, and GetAllPixels) be placed after the EndFunc of Func _PopUps()

What do you think?

Please advise.

Thanks again.

N

Link to comment
Share on other sites

I was able to successfully modify and use Inolesence code from http://www.autoitscript.com/forum/index.ph...topic=8442&st=0. I have now my my own character definitions.

I would like to integrate his code with the code you gave me earlier. In which part of your code should his script be inserted? I'm thinking that the for $Scan..loop be called within the WinExists and all of the 3 functions(Getlines, GetCharacters, and GetAllPixels) be placed after the EndFunc of Func _PopUps()

What do you think?

Please advise.

Thanks again.

N

<{POST_SNAPBACK}>

can i ask how you modified the character defs? i have a few ideas for uses of that code, but haven't invested enough time in figuring out the character defs. Any chance you made a script to create character defs based on a font file?
Link to comment
Share on other sites

can i ask how you modified the character defs?  i have a few ideas for uses of that code, but haven't invested enough time in figuring out the character defs.  Any chance you made a script to create character defs based on a font file?

<{POST_SNAPBACK}>

How I was able to figure out the code by adding tons of mousemove and msgboxes to many places in his code. This way, I was able to see what area gets scanned. However, Pixelsearch will not do any mouse movement for you. I just read the manual on how PixelSearch searches, top to bottom, left to right. That gave me an idea.

For your question, I added the code below inside the For $i = 1 to $Find[0][0] loop which is found in the beginning of his script(also inside For $Scans loop).

:

$Nfile = FileOpen("C:\mychars.au3", 1)
         FileWriteLine($Nfile, "$arCharactersTemp[" & $i & "][0]='*'" & @CRLF);
         FileWriteLine($Nfile, "$arCharactersTemp[" & $i & "][1]='" & $DistanceString[$i] & "'" & @CRLF & @CRLF);
         FileClose($Nfile)

Then, I also had to modify the single quotes to double quotes in the C:\mychars.au3 because I couldn't get the double quotes directly in to the code above. I tried 3 double quotes("""), it failed. I'm very sure it's possible. Then the '*' have to match on how you scanned each character you scanned. I just placed all alphabets(small and big in an area and that's about it. :)

Link to comment
Share on other sites

I was able to successfully modify and use Inolesence code from http://www.autoitscript.com/forum/index.ph...topic=8442&st=0. I have now my my own character definitions.

I would like to integrate his code with the code you gave me earlier. In which part of your code should his script be inserted? I'm thinking that the for $Scan..loop be called within the WinExists and all of the 3 functions(Getlines, GetCharacters, and GetAllPixels) be placed after the EndFunc of Func _PopUps()

What do you think?

Please advise.

Thanks again.

N

<{POST_SNAPBACK}>

That would be the way I would try it.

Gary

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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