Jump to content

2 different pixel search and clicking it after another


wenyen
 Share

Recommended Posts

Hello,

this is my first script and sorry if it is not perfect,

HotKeySet ("{F1}", "start")
HotKeySet ("{F2}", "stop")


 $Variable1 = PixelSearch (37, 0, 1195, 742, 0x752850)


Func stop()
    Exit
EndFunc




Func start()
 $on = 1
While $on = 1
$Variable = PixelSearch (37, 0, 1195, 742,0x9AD234)
if IsArray ($Variable) Then
        MouseMove ($Variable [0], $Variable [1], 0)

        MouseClick ("left")
        Sleep (1000)
Else

$Variable1 = PixelSearch (37, 0, 1195, 742, 0x752850)
If IsArray ($Variable1) Then
        MouseMove ($Variable1 [0], $Variable1 [1], 0)
        MouseClick ("left")
        Sleep (1500)
EndIf
EndIf
WEnd



EndFunc

While 1
    Sleep (100)
WEnd

$variable is always clicking the pixel but it cannot go through $variable1

and also a code that search always for the $variable after the $variable1 performs, 

 please help me..

 

Link to comment
Share on other sites

The following is NOT meant to be rude. Only to inform and to ask questions.

-----------------

Your new. Glad you are here. Now, before I go further, I have no idea the INTENT of your script. It could be for anything. OK, got that out of the way.

Now, here is the rub. Usually the new person who comes here who does pixel searching and mouse moves is 99% of the time using it for a game. That will be a problem. You see, game automation is not allowed to be discussed here in the AutoIt forum. Again, I have no idea if that is your intent or not but if it is, then you may want to ask a moderator to delete your post. It will save lots of time and save you lots of grief. If you have questions on our forum rules you can look here. We are happy to help you, however we have to go by the forum rules.

Now if game automation isn't your intent, would you be so kind in telling us the name of your application you are automating? In just about every case using pixel searching is a bad idea for it is notoriously unreliable. Usually one can hook into the controls of the application to do what they need and in some cases command line can be used and the GUI can be bypassed all together. Using this approach will be much more rewarding to you and save you time.

Edited by Bert
Link to comment
Share on other sites

thank you for your reply, im only new to this and i learn only through videos, im using ms paint for this with a resolution of 768x1280. i want only a script that will click my 1st color and then it will click the 2nd color and back again to the 1st color and so on. the color given in my script above was the result of using autoit info tool. 

but the problem is,  

1. only clicking 1st color and then no click on 2nd color.

2. and i want to have it return to search for 1st color and so on,

Link to comment
Share on other sites

OK, you make this in MSPaint but for what practical purpose will it serve? Again, I want to point out how notoriously unreliable using pixel search is. Even if you get this to work - how will this help you? Saying you want to "learn" I can understand, however if the knowledge doesn't really help you in any practical purpose, whats the point?

Also, your script is searching a LARGE area - pretty much the entire screen. This also is a huge red flag in that this looks like game automation. (I can point to lots of post that look the same as yours) If you are using MSPaint the colors are static and not moving. Why do you need to do a search on the entire screen? You would be able to pick the exact spot you want to look if the picture was not changing

Third thing - why do you need to loop in MSPaint? Again, it is STATIC image, not moving so once you find a pixel, why do you need to search for it again?

Forth thing - Why do you need to do a mouse click on the spot where the color is found? Unless you have a certain control in MSPaint preset before you run your script the mouse click won't do anything.

I'm sorry, but I'm having a real hard time believing you are using MSPaint to do a pixel search. It makes no sense. Everything your doing is saying you are trying to automate a game. At this point you are on a very short leash and I've alerted a moderator to take a look.

Edited by Bert
Link to comment
Share on other sites

  • Moderators

wenyen,

im using ms paint for this with a resolution of 768x1280

Fine. :)

Bert,

You have a PM. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...