Jump to content
Sign in to follow this  
pezo89

Pixelsearch, and mouseclick upon pixel

Recommended Posts

pezo89

Hi guys how can i have it search for the blue pixel (see img)

and then click on whenever it is found (it tend to bounce abit up and down as the sites are diffrent)

have tried this without luck

$pixelSearch=PixelSearch(28,425,796,1014,0x0099FF)
If IsArray($pixelSearch) Then
MouseClick("left",$pixelSearch[0],$pixelSearch[1],1,5)'
endif

what i need it to do, is to search for that color, click on it, and just continue with the script (this just a small part of it, but the rest contains personal information

so wont post the entire script here

anyways, thx for the help in advance..

post-44830-12738611135494_thumb.jpg

Share this post


Link to post
Share on other sites
JohnOne

Thats quite not the right way to go about what you are wanting to do (if click a button on the website is what you wat to do)

You want to be looking into the IE or FF UDFs.

Im sorry I cannot offer you an example as Im not that familiar with them myself but I do offer sage council, the pixel functions are just wrong for your job.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
pezo89

yea but ie commands are for Internet Explorer only arent they?

might it be able to use an imgsearch with AHK to jumpstart the cycle of the AU script?

Share this post


Link to post
Share on other sites
pezo89

yea but my scripting knowledge is far beneeth the requirement to implement that lol =)

Share this post


Link to post
Share on other sites
JohnOne

Ok, fair enough, but I gurantee you will turn to FF.au3 after wasting your time with this approach, and wonder why you didnt spend that time looking at FF examples, because like you say the sites are not the same.

First you will need to look in a more likely place for the button as there will almost certainly be another colour the same as the one you are looking for, before the one you want (If its at the bottom then maybe you should search from bottom to top)

Next you will want to get a checksum of the pixels around that area to validate to are at the correct place

Then

$pixelSearch=PixelSearch(28,425,796,1014,0x0099FF) ;<<=======This needs to be nearer the area you are likely to find the button
If IsArray($pixelSearch) Then
    $checksum = PixelChecksum($pixelSearch[0]-4,$pixelSearch[1]-4,$pixelSearch[0]+4,$pixelSearch[1]+4) ;<==Get a checksum from the area around the first pixel found
    If $checksum = $CalculatedChecksum Then; <======== Check it against one you have previously calculated
       MouseClick("left",$pixelSearch[0] + 4,$pixelSearch[1] + 4,1,5)
    EndIf   
Endif

Good luck.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
pezo89

Ok, fair enough, but I gurantee you will turn to FF.au3 after wasting your time with this approach, and wonder why you didnt spend that time looking at FF examples, because like you say the sites are not the same.

First you will need to look in a more likely place for the button as there will almost certainly be another colour the same as the one you are looking for, before the one you want (If its at the bottom then maybe you should search from bottom to top)

Next you will want to get a checksum of the pixels around that area to validate to are at the correct place

Then

$pixelSearch=PixelSearch(28,425,796,1014,0x0099FF) ;<<=======This needs to be nearer the area you are likely to find the button
If IsArray($pixelSearch) Then
    $checksum = PixelChecksum($pixelSearch[0]-4,$pixelSearch[1]-4,$pixelSearch[0]+4,$pixelSearch[1]+4) ;<==Get a checksum from the area around the first pixel found
    If $checksum = $CalculatedChecksum Then; <======== Check it against one you have previously calculated
       MouseClick("left",$pixelSearch[0] + 4,$pixelSearch[1] + 4,1,5)'
    EndIf   
Endif

Good luck.

Thx alot, but there is somthing wrong, getting an syntax error :S

Share this post


Link to post
Share on other sites
pezo89

theres a quote at the end of the mouseclick line needs removing.

tried that lol

still gets this msg'es

C:\Users\Andreas\Desktop\Del 2.au3(37,128) : WARNING: $pixelSearch possibly not declared/created yet
$pixelSearch=PixelSearch(28,425,796,1014,0x0099FF) ;<<=======This needs to be nearer the area you are likely to find the button
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Andreas\Desktop\Del 2.au3(39,165) : WARNING: $checksum possibly not declared/created yet
    $checksum = PixelChecksum($pixelSearch[0]-4,$pixelSearch[1]-4,$pixelSearch[0]+4,$pixelSearch[1]+4) ;<==Get a checksum from the area around the first pixel found
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Andreas\Desktop\Del 2.au3(40,40) : WARNING: $CalculatedChecksum: possibly used before declaration.
    If $checksum = $CalculatedChecksum Then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Andreas\Desktop\Del 2.au3(40,40) : ERROR: $CalculatedChecksum: undeclared global variable.
    If $checksum = $CalculatedChecksum Then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Andreas\Desktop\Del 2.au33 - 1 error(s), 3 warning(s)

Share this post


Link to post
Share on other sites
JohnOne

Dosent make sense to me why that happens sometimes

lets look at your fist message for example

"C:\Users\Andreas\Desktop\Del 2.au3(37,128) : WARNING: $pixelSearch possibly not declared/created yet"

Then underneath it shows the line where its clearly defined

"$pixelSearch=PixelSearch(28,425,796,1014,0x0099FF)"

Maybe you have to declare it previously

Local $pixelSearch

etc....


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
XKahn

LOL So you are mass spamming the job site with your resume no doubt. I really do wish you the best of luck on that effort. So let me assist you by using an "old school" method of finding the submit button.

The younger crowd is way too mouse dependent. What you actually need to do is use the Send("{TAB}") inside a loop until it crosses the correct link. So the next thing we look at is; what could be used to define that link. A quick look at the properties shows; javascript:document.sendSoeknad.submit(); That could be used as a whole or just the simple "submit" in part. Use $x = StatusbarGetText("Internet Explorer") or $x = StatusbarGetText("Mozilla Firefox")

So now you need to have your script looking for the button property in a TAB loop until found. Once found, you simply do Send("{ENTER}") and your done.

To recap;

AutoItSetOption("WinTitleMatchMode", 2)

$x = StatusbarGetText('Firefox')
$result = StringInStr($x, "submit")
MsgBox (0,'READY?','Get to the site before you say ok.')
While $result = 0
    Send("{TAB}")
    $x = StatusbarGetText('Firefox')
    $result = StringInStr($x, "submit")
    Sleep (20)
WEnd
Send("{ENTER}")

The above code is not yet perfected but is pretty close, I am having some difficulty reading the status bar info for FFox but IE works.

See no hunting down those pixels after all. Happy hunting!

Edited by XKahn

Share this post


Link to post
Share on other sites
pezo89

LOL So you are mass spamming the job site with your resume no doubt. I really do wish you the best of luck on that effort. So let me assist you by using an "old school" method of finding the submit button.

The younger crowd is way too mouse dependent. What you actually need to do is use the Send("{TAB}") inside a loop until it crosses the correct link. So the next thing we look at is; what could be used to define that link. A quick look at the properties shows; javascript:document.sendSoeknad.submit(); That could be used as a whole or just the simple "submit" in part. Use $x = StatusbarGetText("Internet Explorer") or $x = StatusbarGetText("Mozilla Firefox")

So now you need to have your script looking for the button property in a TAB loop until found. Once found, you simply do Send("{ENTER}") and your done.

To recap;

AutoItSetOption("WinTitleMatchMode", 2)

$x = StatusbarGetText('Firefox')
$result = StringInStr($x, "submit")
MsgBox (0,'READY?','Get to the site before you say ok.')
While $result = 0
    Send("{TAB}")
    $x = StatusbarGetText('Firefox')
    $result = StringInStr($x, "submit")
    Sleep (20)
WEnd
Send("{ENTER}")

The above code is not yet perfected but is pretty close, I am having some difficulty reading the status bar info for FFox but IE works.

See no hunting down those pixels after all. Happy hunting!

did this work for you?, as it wont work for me.. :idea:

Share this post


Link to post
Share on other sites
pezo89

tried another approach, but im lost, it works out of the main code, but not within the maincode

This works=

#include <IE.au3>
Global $Paused
sleep ("1000")
HotKeySet("{Insert}", "TogglePause")
send ("{Insert}")
        $kordinater = PixelSearch(29, 573, 668, 901, 0x0099FF)
        If IsArray($kordinater) Then MouseClick("left", $kordinater[0], $kordinater[1], 1, 0)


Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ;toolTip('Script -  "Scriptet er - AV"',0, 40)
    WEnd
    ToolTip("")
EndFunc

Maincode = witch not work

Opt('MustDeclareVars', 1)
    Opt("SendKeyDelay", 10)          ;5 milliseconds
Opt("SendKeyDownDelay", 1)      ;1 millisecond
Opt("MouseClickDelay", 10)      ;10 milliseconds
Opt("MouseClickDownDelay", 10)  ;10 milliseconds
Opt("MouseClickDragDelay", 250) ;250 milliseconds
;;Endre linje 150 til mouseclick;SEnde Søknad

Global $Paused
sleep ("1000")
HotKeySet("{Insert}", "TogglePause")

WinActivate("Microsoft Excel - Jobber som skal søkes på")
     sleep (1000)
     WinWaitActive("Microsoft Excel - Jobber som skal søkes på")
sleep (1000)
MouseMove (119,601,12)
sleep (1000)
mouseclick ("Left")
sleep (1000)
send ("{Down}")
sleep (1000)
send ("^{c}")
sleep (1000)
WinActivate ("Mozilla Firefox")
WinWait ("Mozilla Firefox")
sleep (1000)
MouseMove(419,56,25)
sleep (1000)
MouseClick("LEFT")
sleep (1500)
send ("^{v}")
sleep (1500)
send ("{enter}")
sleep (3000)
send ("^{0}")
sleep (1000)
send ("^{NUMPADSUB 3}")
sleep (1000)
$kordinater = PixelSearch(29, 573, 668, 901, 0x0099FF)
sleep (1000)
If IsArray($kordinater) Then MouseClick("left", $kordinater[0], $kordinater[1], 1, 0)
sleep (2000)

Share this post


Link to post
Share on other sites
pezo89

Got it working. well sort of. i start the search for the blue button command with a runwait command lol :idea:

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.