Jump to content
Sign in to follow this  
cookiekiller89

PixelSearch

Recommended Posts

cookiekiller89

Hi everyone,

First off I apologize for any unclarity in my posts or anything out of the norm as I have only just signed up and this is my first scripting language...

I'm aiming to achieve a macro that can push buttons of specific colour in an internet browser

I first tryed configuring and playing around with Imagesearch, but came to a bit of a holt due to my limited knowledge in areas.

I can achieve what i want with this, (see code below) as my idea here was when 1 button dissapears another one shows up to the side at different coordinates... confirming that this is what I want.

I recieved mouse Coords from windows spy, but couldn't get controlid or any text in IE or Firefox

i know this has been covered and there are other ways.

but my problem is when i eventually make my script available to other users, the resolution settings/toolbars and other factors will alter the coordinates and if no colour is found at such coordinates then mouse will not click.

I've tryed looking at the help file and i just can't fathom my problem. Is there anyway to

search the entire screen for such pixels as that colour id is only available on these buttons and if found return coords to array then move mouse that way? do i require multiple arrays working at once?like a massive script with every cooridnate in it?im not to good at maths but do enjoy this type of thing.

Or if you could provide how to gather elements from buttons and a few functions needed or any helpfiles ill be happy to look and research where u tell me. i just feel lost not knowing if what im doing is even correct.

I'm sorry to be spoonfed and i hope i dont waste anyones time

thanks

While 1

$pixel = PixelSearch (465,391,578,391,0x00c02F)
if IsArray ($pixel) = True Then
Sleep (750)
MouseMove($pixel [0], $pixel [1], 1)
MouseClick ( "left" )
Sleep (250)
EndIf

$pixel = PixelSearch (487,487,582,486,0x00c02F)
if IsArray ($pixel) = True Then
Sleep (750)
MouseMove($pixel [0], $pixel [1], 1)
MouseClick ( "left" )
Sleep (1000)

EndIf
WEnd

Share this post


Link to post
Share on other sites
careca

Hello, with the values you got on pixelsearch, you aren't searching the entire screen,

You are searching from left 465 to right 578 and from top 391 to bottom 391, so, a line of pixels.

What you should have is something like, in case your resolution is..say 800x600:

PixelSearch (0,0,800,600,0x00c02F)

Also, under it, i would put:

If @Error = 1 Then
;Nothing
Else
;rest of script, mouse move and the likes

The reason i'd do this is because pixelsearch retrieves the coordinates,

or an error, so it doesn't make much sense to check for "true".

But this is my opinion, experts please step in and confirm.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
cookiekiller89

Hello, with the values you got on pixelsearch, you aren't searching the entire screen,

You are searching from left 465 to right 578 and from top 391 to bottom 391, so, a line of pixels.

What you should have is something like, in case your resolution is..say 800x600:

PixelSearch (0,0,800,600,0x00c02F)

Also, under it, i would put:

If @Error = 1 Then
;Nothing
Else
;rest of script, mouse move and the likes

The reason i'd do this is because pixelsearch retrieves the coordinates,

or an error, so it doesn't make much sense to check for "true".

But this is my opinion, experts please step in and confirm.

thanks careca, I'll try as you suggest, I have also found a temp fix from another thread which does indeed

do what I have requested, ill also had those coords u stated the values there because was location of the button

please see change below...

While 1

$pixel = PixelSearch (0,0,@DesktopWidth,@DesktopHeight,0x00c02F)
if IsArray ($pixel) = True Then
Sleep (750)
MouseMove($pixel [0], $pixel [1], 1)
MouseClick ( "left" )
Sleep (250)
EndIf

$pixel = PixelSearch (0,0,@DesktopWidth,@DesktopHeight,0x00c02F)
if IsArray ($pixel) = True Then
Sleep (750)
MouseMove($pixel [0], $pixel [1], 1)
MouseClick ( "left" )
Sleep (1000)

EndIf
WEnd

added with the @desk seems to search for any colour on the entire screen, I don't understand the mechanics behind itor how stable it is for my script, but it's a step in the right direction, i will continue to use helpfile and cross analyze with thread examples

i will also try @error which i thought i had in there before

if anyone has a better way or can offer any type of advice i will listen on any points i stated

thx again

Edited by cookiekiller89

Share this post


Link to post
Share on other sites
Bert

AutoIt has IE.au3 so you don't need to resort to pixel searching to do what you need. Just look in the help file and you will see a large group of examples of how to interact with Internet Explorer.

If Firefox is your preference, then look here:

Share this post


Link to post
Share on other sites
cookiekiller89

AutoIt has IE.au3 so you don't need to resort to pixel searching to do what you need. Just look in the help file and you will see a large group of examples of how to interact with Internet Explorer.

If Firefox is your preference, then look here:

thanks yogi, i will look into that

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  

×