Phil77 Posted March 7, 2012 Share Posted March 7, 2012 Hello AutoIT forum!I've tried to code a script, to automatically click on this OK Buttom in a Java - Frameset.asp window.But I can't get it to work... I've talk'd to guys at the work who usually use AutoIT, but none of them know how to make a script to react on a Color + OK buttom.The OK Buttom will automatically popup inside this application, at random spots - So I need a script searching and clicking automatically on that boxs whenever wherever it pops up.I hope you guys can help me, so I can complete my application.Best Regards Phil. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2012 Moderators Share Posted March 7, 2012 Phil77,Welcome to the AutoIt forum. The OK Buttom will automatically popup inside this application, at random spotsWhat sort of "application" are you trying to complete? You have read the Forum Rules, I trust? Apologies in advance if this is legitimate, but random pop-ups always make us think it might be something that the designer does not want automated. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 Hello Thank you, Well it's a server task running at my home servers - Home made software, keep pinging my running servers from different locations - in different windows, the results will be logged everytime I click OK - So I'll be able to see the result from my android during holidays etc. I've just registered my own company for 2 days ago, I got a completed website + rented servers in Paris & London atm. Yes I did read the forum rules , Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2012 Moderators Share Posted March 7, 2012 Phil77, Sounds fine to me - and I did apologise in advance. Will the buttons always be the same colour and will there be more than one visible at any one time? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 No problem mate. Yes, Sometimes if the ping fails there will be multiple OK buttoms, and yes always the same colour. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2012 Moderators Share Posted March 7, 2012 Phil77,First find the colour of the button using the Window Info tool (C:\Program Files\AutoIt3\Au3Info.exe if you did a standard install) - you find the colour under the "Mouse" tab. Then use PixelSearch to find the first pixel of that colour. Finally use MouseClick to click those coordinates - although I would add a few pixels to each one to make sure I hit the button fully. As you might have several buttons, you will need a loop to repeat the process until the PixelSearch function fails to find a button. If there is something else of the same colour on the screen you will need to adjust the coordinates you search to prevent false results. Pretty easy stuff - give it a go yourself and see how you get on. You know where we are if you run into problems. M23 Phil77 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Realm Posted March 7, 2012 Share Posted March 7, 2012 (edited) When the button appears and you have actual coordinates of it, have you been able to test and find the button then? Reason I ask, is because you mentioned in your OP that it is a Java application, and if it is Java Flash, then the internal Pixel functions in AutoIt will not detect them. Java Flash appears to be transparent to the AutoIt Pixel functions. The only other way around that I have found was by taking a screen shot of the area being searched, and searching the screenshot. Edit: Might not be all Java Flash Applications, but I have yet to find one that can be read by the native AutoIt pixel functions. Edited March 7, 2012 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 When the button appears and you have actual coordinates of it, have you been able to test and find the button then?Reason I ask, is because you mentioned in your OP that it is a Java application, and if it is Java Flash, then the internal Pixel functions in AutoIt will not detect them. Java Flash appears to be transparent to the AutoIt Pixel functions. The only other way around that I have found was by taking a screen shot of the area being searched, and searching the screenshot.Edit: Might not be all Java Flash Applications, but I have yet to find one that can be read by the native AutoIt pixel functions.I've tried to use the sniper drag and drop, to find the Buttom - But as you said, it will just take the full window. Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 Here is what I've created untill now, I couldn't make it to work :/ While 1 If WinExists("Color 0xFFD166") then WinClose("OK") Endif sleep(2000) Wend Any ideas please? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2012 Moderators Share Posted March 7, 2012 Phil77,Any ideas please?Read my post above. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 Sorry mate. It works, My mouse moves to the color $pixel = PixelSearch(0,0,973,509,0xFFD166) If IsArray($pixel) = True Then MouseMove($pixel [0], $pixel [1], 1) EndIf But even if I change the cordinates - It will still find the OK Box. For some reason it places my mouse in the upper left cornor, Is there a change that I can make it stay in the middle? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 7, 2012 Share Posted March 7, 2012 This may do it. Add half the width and half the height of the button to the coords (both width and height in pixels), so.. MouseMove($pixel [0] + half the width, $pixel [1] + half the height, 1) Phil77 1 - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 This may do it. Add half the width and half the height of the button to the coords (both width and height in pixels), so.. MouseMove($pixel [0] + half the width, $pixel [1] + half the height, 1) Cool mate thx alot! Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 Okay status atm is $pixel = PixelSearch(0,0,5000,2500,0xFFD166) If IsArray($pixel) = True Then MouseMove($pixel [0] + 20, $pixel [1] + 10, 1) EndIf How can I make the script clicking on the OK buttom? As I understand it does only "move" to the cordination, everywhere on the screen. And it should keep running in a loop, I've tried to youtube it - but I can't seem to find any guides. Any ideas? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 7, 2012 Share Posted March 7, 2012 MouseClick() Phil77 1 - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 MouseClick() Thx alot! $pixel = PixelSearch(0,0,5000,2500,0xFFD166) If IsArray($pixel) = True Then MouseMove($pixel [0] + 20, $pixel [1] + 10, 1) MouseClick("left", XXX, XXX, X) EndIf I'm having a problem making the cords on the clicks - Is there someway I can just make it instant click 3 times without cords? I just mean like, the mouse is already placed at the right place. Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 7, 2012 Share Posted March 7, 2012 (edited) If the button is always the same colour and the text is always the same, I wouldn't just search for a pixel that matches that colour. I'd search for a region that matches a pixel checksum. It's the closest we have to an OCR at the moment. Pick a rectangle roughly the size of the word "OK". I just made some arbitrary numbers and tossed something together without testing it. This is the same method I used in another program for a similar problem. ; First, get the Checksum of the region. $var = PixelChecksum($x1, $y1, $x1 + 50, $y1 + 25, 1, $hwnd) MsgBox(0, "Region", "The Checksum is: " & $var & @CRLF & "Write this down.") ; Now ... in your main program $var = {whatever checksum you arrived at} If _FindButton($var) Then MouseClick() ; and this goes in a function: Func _FindButton($CheckSum) Local $y1, $x1, $result, $hwnd For $y1 = 1 To @DesktopHeight For $x1 = 1 To @DesktopWidth $result = PixelChecksum($x1, $y1, $x1 + 50, $y1 + 25, 1, $hwnd) If $result = $CheckSum Then Return 1 EndIf Next Next Return 0 EndFunc ;==>_FindButton Edited March 7, 2012 by Blue_Drache Phil77 1 Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
JohnQSmith Posted March 7, 2012 Share Posted March 7, 2012 (edited) I'm having a problem making the cords on the clicks - Is there someway I can just make it instant click 3 times without cords? I just mean like, the mouse is already placed at the right place.Now is the time to READ the help file, not just look at the pretty pictures. You've got the code listed right there. You even have an X as a placeholder for it. Edited March 7, 2012 by JohnQSmith somdcomputerguy 1 Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
Developers Jos Posted March 7, 2012 Developers Share Posted March 7, 2012 (edited) @Pill77. So let me get this strait: You have a home made server application which has popups that require 3 clicks on the same spot without moving the mouse... am I close? Edited March 7, 2012 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Phil77 Posted March 7, 2012 Author Share Posted March 7, 2012 Thanks guys! I've sorted this out mixed with information from youtube - And the forum! I thanks alot for the warm welcome! Link to comment Share on other sites More sharing options...
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