# Hey Guys

## Recommended Posts

Fine, I admit it, i'm a noob :3

Many people have been talking about  Pixelsearch, Mousemove, and GUIs, so I have a few questions

Heres a little code:

\$coord1 = PixelSearch(250,150,550,450,0xE8041F [,5[,2]])
\$coord2 = PixelSearch(250,150,550,450,0xE41800 [,5[,2]])
\$coord3 = PixelSearch(250,150,550,450,0x8B0625 [,5[,2]])
\$coord4 = PixelSearch(250,150,550,450,0xE31A22 [,5[,2]])

Can i just say

Mousemove(\$coord1,\$coord1 [, 1])
Mousemove(\$coord2,\$coord2 [, 1])
Mousemove(\$coord3,\$coord3 [, 1])
Mousemove(\$coord4,\$coord4 [, 1])

And it would work? o_O

I'll Do GUIs laterz

Edited by Marvens01

##### Share on other sites

PixelSearch()
Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y).

That means \$coord1 has 2 parts after you make it equal PixelSearch().

\$coord1[0]; x

\$coord1[1]; y

;                         x          ,       y

mousemove(\$coord1[0], \$coord1[1])

Edited by Xandy

##### Share on other sites
Mousemove(\$coord1[0],\$coord1[1] [, 1])
Mousemove(\$coord2[0],\$coord2[1] [, 1])
Mousemove(\$coord3[0],\$coord3[1] [, 1])
Mousemove(\$coord4[0],\$coord4[1] [, 1])
\$coord1 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0xE8041F [,5[,2]])
\$coord2 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0xE41800 [,5[,2]])
\$coord3 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0x8B0625 [,5[,2]])
\$coord4 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0xE31A22 [,5[,2]])

So that would work? o_O

##### Share on other sites

First PixelSearch returns an array. Second, the bracket around the parameters in a function example are only there to show you that they're optional parameters, do NOT use the brackets.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

Cool

Mousemove(\$coord1[0],\$coord1[1] , 1)

Mousemove(\$coord2[0],\$coord2[1] , 1)
Mousemove(\$coord3[0],\$coord3[1] , 1)
Mousemove(\$coord4[0],\$coord4[1] , 1)
\$coord1 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0xE8041F ,5,2)
\$coord2 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0xE41800 ,5,2)
\$coord3 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0x8B0625 ,5,2)
\$coord4 = PixelSearch(@DesktopWidth/2-150,@DesktopHeight/2+150,@DesktopWidth-100,@DesktopHeight-100,0xE31A22 ,5,2)

This?

##### Share on other sites

I personally would do it like this, mainly because each of your PixelSearch commands are using the same parameters except for the color being looked for.

```#include <Constants.au3>
Global \$aColors[5] = [4, 0xE8041F, 0xE41800, 0x8B0625, 0xE31A22]
For \$Loop = 1 to \$aColors[0]
\$coord = PixelSearch(@DesktopWidth / 2 - 150, @DesktopHeight / 2 + 150, @DesktopWidth - 100, @DesktopHeight - 100, \$aColors[\$Loop], 5, 2)
If Not @error Then
MouseMove(\$coord[0], \$coord[1], 1)
MsgBox(\$MB_SYSTEMMODAL, "Found", "Found the color")
EndIf
Next```

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

I personally would do it like this, mainly because each of your PixelSearch commands are using the same parameters except for the color being looked for.

```#include <Constants.au3>
Global \$aColors[5] = [4, 0xE8041F, 0xE41800, 0x8B0625, 0xE31A22]
For \$Loop = 1 to \$aColors[0]
\$coord = PixelSearch(@DesktopWidth / 2 - 150, @DesktopHeight / 2 + 150, @DesktopWidth - 100, @DesktopHeight - 100, \$aColors[\$Loop], 5, 2)
If Not @error Then
MouseMove(\$coord[0], \$coord[1], 1)
MsgBox(\$MB_SYSTEMMODAL, "Found", "Found the color")
EndIf
Next```

Look Like I just got lost >.<

##### Share on other sites

Marvens01, did you try the code BrewManNH suggested? Are you getting an error? We need a little more, such as where you are getting lost

√-1 2^3 ∑ π, and it was delicious!

##### Share on other sites

JLogan:  I think I know what he's getting lost on, having experienced it before.  Following the code.  Perhaps a basic understanding of programming and logic flow would be in order?

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

##### Share on other sites

I don't want a code, I want to learn TO code, and explanation.

##### Share on other sites

I don't want a code, I want to learn TO code, and explanation.

Here's the same script, with comments as to what is going on.

```#include <Constants.au3>
Global \$aColors[5] = [4, 0xE8041F, 0xE41800, 0x8B0625, 0xE31A22] ; assign the 4 different colors you're looking for to an array
For \$Loop = 1 to \$aColors[0] ; loop through the array
;Search for the color using pixel search, the color being looked for is the color code in the array \$aColors{\$Loop] element
\$coord = PixelSearch(@DesktopWidth / 2 - 150, @DesktopHeight / 2 + 150, @DesktopWidth - 100, @DesktopHeight - 100, \$aColors[\$Loop], 5, 2)
If Not @error Then ; if the pixelsearch returns without an error, that means it found the color being looked for
MouseMove(\$coord[0], \$coord[1], 1) ; move the mouse to the coordinates that the color was found at
MsgBox(\$MB_SYSTEMMODAL, "Found", "Found the color") ; for informational purposes only
EndIf
Next ; repeat the loop until we've searched for every color```

If you're having trouble understanding the whole array thing, I'd suggest this Array tutorial.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

What happens if you want to loop this without the messagebox?

I really wanna learn Loop

##### Share on other sites

What have you tried?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

IDK loop :/ Do I just add Loop at the end???

##### Share on other sites

IDK loop :/ Do I just add Loop at the end???

I'd suggest opening the help file and start doing some reading on the basics.

Specifically, While/Do loops or For...Next loops.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

I'd suggest opening the help file and start doing some reading on the basics.

Specifically, While/Do loops or For...Next loops.

O_O What?

##### Share on other sites

They're the fundamentals to any programming language. Do you know about the help file? Hit F1 and search while.

Thanks

##### Share on other sites

Loops, by Joshua Songer.

All loops have two parts. A beginning and an end.
Some loops have a condition to exit, and some loops have an increment variable; possibly increment amount (step).
example 1:
while 1;      1 is true so this just loops until a exitloop is encountered by the script.
;stuff in loop

example 2:;count that's 9 iterations of this here loop
for \$i= 0 to 8
;stuff in loop

example 3:

```#include <GUIConstants.au3>;defines \$gui_event_close
\$hgui= guicreate("Window Title", 320, 200);create gui window return reference to \$hgui
guisetstate();this shows the damn gui
do;loop begining
\$msg= guigetmsg();pull gui event
until \$msg= \$gui_event_close;test for gui close event else return to do statement```

I hope you enjoy your programming experience.

Edited by Xandy

##### Share on other sites

Hey you

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...