acarter Posted September 25, 2014 Posted September 25, 2014 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!
Anteaus Posted September 25, 2014 Posted September 25, 2014 (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 September 25, 2014 by Anteaus
Gianni Posted September 25, 2014 Posted September 25, 2014 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. Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
MikahS Posted September 25, 2014 Posted September 25, 2014 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 ~ getENVvarsMy 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
Kovacic Posted September 25, 2014 Posted September 25, 2014 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( ͡° ͜ʖ ͡°)
Kovacic Posted September 25, 2014 Posted September 25, 2014 (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 September 25, 2014 by Kovacic C0d3 is P0etry( ͡° ͜ʖ ͡°)
MikahS Posted September 25, 2014 Posted September 25, 2014 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 ~ getENVvarsMy 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
Kovacic Posted September 25, 2014 Posted September 25, 2014 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( ͡° ͜ʖ ͡°)
MikahS Posted September 25, 2014 Posted September 25, 2014 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 ~ getENVvarsMy 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
Kovacic Posted September 25, 2014 Posted September 25, 2014 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 C0d3 is P0etry( ͡° ͜ʖ ͡°)
junkew Posted September 25, 2014 Posted September 25, 2014 Try with simplespy of iuiautomation to see if text can be seen FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
MikahS Posted September 26, 2014 Posted September 26, 2014 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 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 ~ getENVvarsMy 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
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