Sign in to follow this  
Followers 0
jksp22

[new user] Click a pixel or pixels with loop possible?

17 posts in this topic

Hello, there!

I don't know how to use this product, but I am in need of a program where I can input a pixel (x,y) and the program will click on that pixel automatically.

Or I need to specify pixel1 (x1,y1), pixel2 (x2,y2), and pixel3 (x3,y3) where I need to click on pixel1 and loop through to pixel2 by clicking all pixels within the range (box).

But the process goes like this.

1. click x1,y1

2. wait 3 seconds

3. click x3,y3

4. click x1+1,y1

5. wait 3 seconds

6. click x3,y3

and so on.

 

Is this possible?

 

Thank you in advance!

Share this post


Link to post
Share on other sites



Yes

PixelGetColor -> Get the color of a pixel in specified coords (x,y) Then you need X,Y and will get a decimal color

Or

PixelSearch -> Search in an area for a pixel with specified coords Then you need Coords of a rectangle and a color and will get X,Y if some pixel in area have specified color

Or

PixelChecksum -> You generate a checksum of a rectangle and get value, then you can compare later if are the same.

Share this post


Link to post
Share on other sites

It doesn't have to do anything with color. It still works right?

So how can I start? I downloaded autoit and installed it. What's my next step?

Thanks!

Share this post


Link to post
Share on other sites

Same procedure as in every new programming language, read the doc's, the wikis and try the examples for learning the basics.

Share this post


Link to post
Share on other sites

Dig in to the help file, specifically focusing on While, Sleep, and ControlClick (or MouseClick)

Share this post


Link to post
Share on other sites

And that delay of 3-5 seconds. Is that possible as well?

Share this post


Link to post
Share on other sites

And that delay of 3-5 seconds. Is that possible as well?

Did you actually try to search first in the help file for this as MuffinMan clearly gave you the commands already?

Jos


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

Share this post


Link to post
Share on other sites

you didn't have to be that rude to point out that sleep is delay. who's going to ask for help in help forum if you just say go to the help file. it's all there. maybe i just like to talk to actual humans who can provide their knowledge in the area.

but yes, i read it.

thanks for the help everyone. It's going to help me a lot. I've been doing things manually. This might just increase my efficiency by 10 times.

Share this post


Link to post
Share on other sites

I was not rude, just simply stated a fact as you posted your reply within 4 minutes of the help you had receive, so hence the question. ;)

When this feels as being rude then have a look in the mirror and have a good talk to the person you see.

Jos


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

Share this post


Link to post
Share on other sites

well then, i apologize.

i was able to code something very simple for my purpose. It works as I intended.

Now, I tried a simple gui to see if I can use an exe instead of going into the code to change the pixels.

Got the inputs made for pixels, and everything...but gui disappears without a sleep(x).

I don't want the gui to disappear unless I click on X or close button on onevent.

What's required at this point?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

GUICreate("AutoClick", 450, 150)

GUICtrlCreateLabel("Topleft of the box", 30, 10)
Local $x1 = GUICtrlCreateInput("", 150,5, 100, 20)
Local $y1 = GUICtrlCreateInput("", 300,5, 100, 20)

GUICtrlCreateLabel("Bottomright of the box", 30, 50)
Local $x2 = GUICtrlCreateInput("", 150,45, 100, 20)
Local $y2 = GUICtrlCreateInput("", 300,45, 100, 20)

GUICtrlCreateLabel("Pixels for Hole #", 30, 90)
Local $x3 = GUICtrlCreateInput("", 150,85, 100, 20)
Local $y3 = GUICtrlCreateInput("", 300,85, 100, 20)

Local $run = GUICtrlCreateButton("Run", 150, 120, 85, 25)
Local $closeapp = GUICtrlCreateButton("Close", 250, 120, 85, 25)

GUICtrlSetOnEvent($run, "clickpixels")
GUICtrlSetOnEvent($closeapp, "closeapp")

Func closeapp()
    MsgBox($MB_OK, "Good-bye", "You selected CLOSE! Exiting...")
    Exit
EndFunc

GUISetState(@SW_SHOW)
sleep(5000)    <- without this, gui just opens and disappears right away. i'm probably missing something here.

Func clickpixels()

   While $x1 <= $x2
      While $y1 <= $y2
         MouseClick($MOUSE_CLICK_LEFT, $x1, $y1, 1, 10)
         Sleep(3000)
         $y1 = $y1 + 1
         MouseClick($MOUSE_CLICK_LEFT, $x3, $y3, 1, 10)
         Sleep(500)
         MouseClick($MOUSE_CLICK_LEFT, $x1-1, $y1, 1, 10)
         Sleep(1500)
      WEnd
      $x1 = $x1 + 1
   WEnd

EndFunc

 

Edited by Jos
Added codebox

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

You need to add a close loop (While .. Wend)  like is shown in the Helpfile example for GUICtrlSetOnEvent()

Jos

Ps: Please use a codebox when posting code. :)

Edited by Jos

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

Share this post


Link to post
Share on other sites

Hmm a little bit of issues.

Trying to convert the guictrlinput with int or number. int(input) or number(input) doesn't seem to work. Seems like an easy problem but I'm stumped. How should I go about this one?

Share this post


Link to post
Share on other sites

"Doesn't work" doesn't mean much unless you tell us what you are trying to do and what it is that doesn't work.

So give us some details on what you are doing and what is not working.

Jos 


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

Share this post


Link to post
Share on other sites
Local $x1 = 661
Local $y1 = 254
Local $x2 = 767
Local $y2 = 355
Local $x3 = 161
Local $y3 = 539

While $x1 <= $x2
   While $y1 <= $y2
      MouseClick($MOUSE_CLICK_LEFT, $x1, $y1, 1, 10)
      Sleep(3000)
      $y1 = $y1 + 1
      MouseClick($MOUSE_CLICK_LEFT, $x3, $y3, 1, 10)
      Sleep(500)
      MouseClick($MOUSE_CLICK_LEFT, $x1-1, $y1, 1, 10)
      Sleep(1500)
   WEnd
   $x1 = $x1 + 1
WEnd

I need those variables to be numbers. 

GUICtrlCreateInput("", 150,5, 100, 20)

gives me a string?

When i run the script, I think the loop is playing around pixels 0,0.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

The variables will be numbers.
Looks like you logic is flawed as you never reset your $y2 back to its initial value after the second while-wend loop ends.

ps. please make sure you have read our forum rules ... especially the section about game automation.

Jos

Edited by Jos

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

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  
Followers 0