Sign in to follow this  
Followers 0
acarter

Search Screen For Specific Text

12 posts in this topic

Hey all,

I have some code that I use to manipulate a screen (java applet) at work. This code runs our processes using Send.

What I'm trying to do is some error handling. For the most part, the processes run smoothly without running into any error, but every so often there is an error that comes on the screen that I need to enter through (by using Send("[ENTER]")). Is there a way I can read/search the screen for the specific error text and if it comes up, send the extra enter?

Ex:

Send("Y")
Send("[Enter]")
Sleep(100)
Send("N")
Send("[Enter]")
Sleep(100)
Send("123")
Send("[Enter]")
Sleep(100)

If ***Search screen for error*** = "Error:1234" Then
Send("[Enter]")
Else

Continue on with the rest of the script...

Thanks in advance!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This is quite hard to do since most browsers won't allow other programs to see text in the webpage being viewed, for security reasons.

A workaround I've used in the past is to use Javascript to set the page title to the text I want to extract, since Autoit can see this property in virtually all browsers.

Edited by Anteaus

Share this post


Link to post
Share on other sites

Does your applet allows you to copy portions of screen to the clipboard via select by mouse and copy?

if so then an attempt to read characters could be done in >a way like this.


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

Share this post


Link to post
Share on other sites

Well, getting the handletitleclassname will be invaluable for you to automate this app. Use the Autoit window info tool to get this information.

Then, you should be able to specify the title of the error window, once you know the title of this java app (that is if it has any of these properties).


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Use the Autoit Info tool and get the info you need, then just use this:

while 1
   winwait("Error Applying Security","")
   WinActivate("Error Applying Security","")
   ControlClick("","","[CLASS:Button; INSTANCE:1]")
WEnd

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If the info tool cant see it, try looking for the error on the screen, look for a color in the error message, then hit the button. Example:

While 1
sleep(3000)
local $color = 0xFF919D
Local $iColor = PixelGetColor(901,279)
If $iColor = $color then MouseClick("left", 875, 472, 2)
wend
Edited by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

 

If the info tool cant see it, try looking for the error on the screen, look for a color in the error message, then hit the button. Example:

While 1
sleep(3000)
local $color = 0xFF919D
Local $iColor = PixelGetColor(901,279)
If $iColor = $color then MouseClick("left", 875, 472, 2)
wend

How do you know what or if their is any color in this error message?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

How do you know what or if their is any color in this error message?

 

just by that it looks like on the screen. For example, if your desktop background is black, and a grey error pops up, that script sees the grey pop up in that pile space and hits the button


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

just by that it looks like on the screen. For example, if your desktop background is black, and a grey error pops up, that script sees the grey pop up in that pile space and hits the button

 

I don't disagree, just not very relevant to what OP wants. No matter though, always good to help out :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Hey all,

I have some code that I use to manipulate a screen (java applet) at work. This code runs our processes using Send.

What I'm trying to do is some error handling. For the most part, the processes run smoothly without running into any error, but every so often there is an error that comes on the screen that I need to enter through (by using Send("[ENTER]")). Is there a way I can read/search the screen for the specific error text and if it comes up, send the extra enter?

Ex:

Send("Y")
Send("[Enter]")
Sleep(100)
Send("N")
Send("[Enter]")
Sleep(100)
Send("123")
Send("[Enter]")
Sleep(100)

If ***Search screen for error*** = "Error:1234" Then
Send("[Enter]")
Else

Continue on with the rest of the script...

Thanks in advance!

 

 

I don't disagree, just not very relevant to what OP wants. No matter though, always good to help out :)

 

 

Might not OCR the screen, but if it sees something popup matching the error, you can kick off a function to ENTER through the prompts.. Seems legit :thumbsup:


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Might not OCR the screen, but if it sees something popup matching the error, you can kick off a function to ENTER through the prompts.. Seems legit :thumbsup:

 

All you need is the title/class/handle to the window to find it's child. Matching up the child to the parent shouldn't be difficult using WinList() and _WinAPI_GetParent(). ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0