Sign in to follow this  
Followers 0
SupraNatural

Pixel Search help please

19 posts in this topic

When using the PixelSearch function how do you get the left, top, right, bottom, coordinates out of Top Left, Bottom Left, Top Right, Bottom Right, since they each come out with an X,Y not just 1 number. If im not explaining this right please ask.


Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Share this post


Link to post
Share on other sites



When using the PixelSearch function how do you get the left, top, right, bottom, coordinates out of Top Left, Bottom Left, Top Right, Bottom Right, since they each come out with an X,Y not just 1 number. If im not explaining this right please ask.

<{POST_SNAPBACK}>

What do you mean? Where are the corner coordinates coming from? Here's an example where they come from the mouse in the form of a 2 element array. Run it a couple of times and move the mouse to a new positon at each prompt.

MsgBox(4096, "Get Mouse Position", "About to get the mouse position.  Please wait", 3)
$a1 = MouseGetPos()
MsgBox(4096, "Get Mouse Position", "About to get next mouse position.  Move it a little and wait", 3)
$a2 = MouseGetPos()
MsgBox(4096, "Example", "First Mouse Positon X = " & $a1[0] &@lf& "First Mouse Positon Y = " & $a1[1] &@lf&  "2nd Mouse Positon X = " & $a2[0] &@lf& "2nd Mouse Positon Y = " & $a2[1])
Exit

Phillip

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Alright i did the diagonal heres what i got

HotKeySet("{F1}", "CreateAndEnterPortal");F1

While 1
    Sleep(100)
WEnd

Func CreateAndEnterPortal()
    PixelSearch (508, 414, 224, 89, 0x212021)
If Not @error Then
    MouseMove($coord[0], $coord[1])
    MouseClick("left")
EndIf
EndFunc

508,414 is the top left corner and 224,89 is the bottom right. Maybe its just the color im looking for, I'll try some different ones. I want it to move the mouse to the found color and click on it.

Edited by SupraNatural

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Alright i did the diagonal heres what i got

HotKeySet("{F1}", "CreateAndEnterPortal");F1

While 1
    Sleep(100)
WEnd

Func CreateAndEnterPortal()
    PixelSearch (508, 414, 224, 89, 0x212021)
If Not @error Then
    MouseMove($coord[0], $coord[1])
    MouseClick("left")
EndIf
EndFunc

508,414 is the top left corner and 224,89 is the bottom right. Maybe its just the color im looking for, I'll try some different ones.  I want it to move the mouse to the found color and click on it.

<{POST_SNAPBACK}>

You did not assign the coordinate returned by PixelSearch to the $Coord variable. And the parameter order is Left, Top, Right, Bottom (where Left < Right, and Top < Bottom). If the color is found, the mouse should move to that location.

$coord = PixelSearch(224, 89, 508, 414, 0x212021)

Edited to correct the parameter order.

Edited by phillip123adams

Phillip

Share this post


Link to post
Share on other sites

Well that doesn't seem to work, what i dont get is why it doesn't click on the pixel if it finds it, all it does is move the mouse to a different spot and click there. Here is what i've got.

HotKeySet("{F1}", "CreateAndEnterPortal") ;F1

While 1
    Sleep(100);Idle around
WEnd

Func CreateAndEnterPortal()
    Send("{F8}");Opens portal skill
    MouseClick("right");Casts portal skill
    $coord = PixelSearch(224, 89, 508, 414, 0x212021);Search for portal
If Not @error Then
    MouseMove($coord[0], $coord[1]);Move to portal
    MouseClick("left");Click on portal
EndIf
EndFunc

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Share this post


Link to post
Share on other sites

Nothing obviously wrong with that code, but why not combine the two mouse actions? --

; click on portal
mouseClick("left", $coord[0], $coord[1])

That might make things slightly better. If not, take note of the pixel colour underneath where the mouse is moved -- is it identical to the pixels at your desired location?

Off-topic: When using a loop to idle around you'll always use less CPU with larger Sleep() values. Personally I always use the largest value that I can:

while (1)
    sleep(0x7fffffff)
wEnd

Share this post


Link to post
Share on other sites

Well that doesn't seem to work, what i dont get is why it doesn't click on the pixel if it finds it, all it does is move the mouse to a different spot and click there. Here is what i've got.

<{POST_SNAPBACK}>

I added two message boxes for testing purposes. Which one appears? I would also implement LxP's suggestions.

Func CreateAndEnterPortal()
   Send("{F8}");Opens portal skill
   MouseClick("right");Casts portal skill
   $coord = PixelSearch(224, 89, 508, 414, 0x212021);Search for portal
   If Not @error Then
      MouseMove($coord[0], $coord[1]);Move to portal
      MouseClick("left");Click on portal
      MsgBox(4096, "Debug 1", "The color was found and the mouse should have left clicked on it.")
   Else
      MsgBox(4096, "Debug 2", "The color was not found?")
   EndIf
EndFunc

Phillip

Share this post


Link to post
Share on other sites

Ok well it says the color was found and it should have been left clicked on, but it doesn't left click on it. It clicks like WAY to far left of it, here is what it should do:

1. Select portal using F8

2. Create portal using Right Click

3. Scan for portal using pixel search

4. Use the pixel search coords to click on portal

That's all it needs to do but it never clicks on it. Here is the code once again;

HotKeySet("{F1}", "CreateAndEnterPortal") ;F1

While 1
    Sleep(100)
WEnd

Func CreateAndEnterPortal()
   Send("{F8}");Opens portal skill
   MouseClick("right");Casts portal skill
   $coord = PixelSearch(224, 89, 508, 414, 0x212021);Search for portal
   If Not @error Then
      MouseClick( "left", $coord[0], $coord[1] );Click on portal
      MsgBox(4096, "Debug 1", "The color was found and the mouse should have left clicked on it.")
   Else
      MsgBox(4096, "Debug 2", "The color was not found?")
   EndIf
EndFunc

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Share this post


Link to post
Share on other sites

At the top of your Script include these two things:

Opt("MouseCoordMode", 0) ; if Window Coords / , 2 if Client Coords

Opt("PixelCoordMode", 0) ; Same as above

Good Luck


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Well your using Debug... did you at least get the Debug Error ... The color is not found?

If so... try putting it in a while loop till it is found:

Opt("MouseCoordMode", 0); if Window Coords / , 2 if Client Coords
Opt("PixelCoordMode", 0); Same as above

HotKeySet("{F1}", "CreateAndEnterPortal");F1

While 1
    Sleep(100)
WEnd

Func CreateAndEnterPortal()
While 1
   Sleep(100)   
   Send("{F8}");Opens portal skill
   MouseClick("right");Casts portal skill
   $coord = PixelSearch(224, 89, 508, 414, 0x212021);Search for portal
   If Not @error Then
      MouseClick( "left", $coord[0], $coord[1] );Click on portal
      MsgBox(4096, "Debug 1", "The color was found and the mouse  should have left clicked on it.")
      ExitLoop   
   EndIf
Wend
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Ok well it says the color was found and it should have been left clicked on, but it doesn't left click on it. It clicks like WAY to far left of it.


Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Opt("MouseCoordMode", 0); if Window Coords / , 2 if Client Coords
Opt("PixelCoordMode", 0); Same as above

Global $Game = "YOUR GAME TITLE HERE"

HotKeySet("{F1}", "CreateAndEnterPortal");F1

While 1
    Sleep(100)
WEnd

Func CreateAndEnterPortal()
While WinExists($Game)
   Sleep(100)  
   
   If Not WinActive($Game) Then 
   WinActivate($Game)
   Sleep(500)
   EndIf

   Send("{F8}");Opens portal skill
   MouseClick("right");Casts portal skill
   $coord = PixelSearch(224, 89, 508, 414, 0x212021);Search for portal
   If Not @error Then
      MouseClick( "left", $coord[0], $coord[1], 1, 1 );Click on portal
      Sleep(1000)
      MsgBox(4096, "Debug 1", "The color was found and the mouse  should have left clicked on it.")
      MsgBox(0, "Pixel Coords", "Found at x: " & $coord[0] & "  y: " & $coord[1])
      ExitLoop  
   EndIf
Wend
EndFunc

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

And what of the option I gave you? If you've done it as I've put it, it will return the results you desire.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Ok it is done!! This will open a portal and take you into town, I will be implenting this into many other scripts, thanks all for helping.

HotKeySet("{HOME}", "CreateAndEnterPortal");F1

While 1
    Sleep(100)
WEnd

Func CreateAndEnterPortal()
While 1
   Sleep(100)   
   Send("{F8}");Opens portal skill
   MouseClick("right");Casts portal skill
   $coord = PixelSearch(224, 89, 508, 414, 0xFFFFFF, 4);Search for portal
   If Not @error Then
      MouseClick( "left", $coord[0], $coord[1] );Click on portal
      ExitLoop   
   EndIf
Wend
EndFunc

;224, 68 = Top Left
;508, 414 = Bottom Right
Edited by SupraNatural

Visit http://www.blizzedout.com/forums/register....referrerid=8306 for the top blizzard hacks. WoW, TfT, D2/LOD, CS. You name it we got it!

Share this post


Link to post
Share on other sites

cool lookin nice :whistle:

shame i dun play D2 nymore

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