Jump to content
Sign in to follow this  
Phil77

How to Automatically click on decided color with text OK

Recommended Posts

Phil77

Posted Image

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.

Share this post


Link to post
Share on other sites
Melba23

Phil77,

Welcome to the AutoIt forum. :bye:

The OK Buttom will automatically popup inside this application, at random spots

What sort of "application" are you trying to complete? You have read the Forum Rules, I trust? :oops:

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Phil77

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 :oops:,

Share this post


Link to post
Share on other sites
Melba23

Phil77,

Sounds fine to me - and I did apologise in advance. :bye:

Will the buttons always be the same colour and will there be more than one visible at any one time? :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Phil77

No problem mate.

Yes, Sometimes if the ping fails there will be multiple OK buttoms, and yes always the same colour.

Share this post


Link to post
Share on other sites
Melba23

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

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

Pretty easy stuff - give it a go yourself and see how you get on. You know where we are if you run into problems. :bye:

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Realm

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

Share this post


Link to post
Share on other sites
Phil77

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.

Share this post


Link to post
Share on other sites
Phil77

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?

Share this post


Link to post
Share on other sites
Melba23

Phil77,

Any ideas please?

Read my post above. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Phil77

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?

Share this post


Link to post
Share on other sites
somdcomputerguy

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)
  • Like 1

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Phil77

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!

Share this post


Link to post
Share on other sites
Phil77

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?

Share this post


Link to post
Share on other sites
somdcomputerguy

MouseClick()

  • Like 1

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Phil77

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.

Share this post


Link to post
Share on other sites
Blue_Drache

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 by Blue_Drache
  • Like 1

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
JohnQSmith

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 by JohnQSmith
  • Like 1

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Share this post


Link to post
Share on other sites
Jos

@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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Phil77

Thanks guys! I've sorted this out mixed with information from youtube - And the forum!

I thanks alot for the warm welcome!

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  

×