Sign in to follow this  
Followers 0
CyNDeR

New to Autoit

5 posts in this topic

I'm currently writing a script to automate something in a game i play (Diablo II LoD). I'm trying to find out how to search for a certain block of pixels on the screen and click on it. I didnt think a simple pixelsearch would work as what i need to click on has no unique single pixel colors, but searching for a block of pixels would give me much more accuracy. The only thing i've been able to find so far was http://www.autoitscript.com/forum/index.php?showtopic=51094, but i'm not sure how to use it. I've been able to find the block of pixels i want to search for but i'm not sure as to how to use the dll within the script. The block of pixels i want to find as output from the above program is:

CODE
2F302E33313032302F

43444239373632302F

3E3F3D353535303030

I'm not sure how to use the DllOpen and DllCall functions properly. (If that is indeed what i need to use)

Any help would be greatly appreciated.


My scripts: Random Painter

Share this post


Link to post
Share on other sites



I'm not familiar with this DLL and or Delphi code (looks a mess).

I'm also not understanding why there's only 1 set of coords... Looks like he's getting every single pixel color on the screen.

Knowing you have to use DLLStructGetData() to pull that information out, you can count on this being one pain stakingly slow function.

Here's a stab on how I "partially" understood the code:

Func _FindPixels($nX1, $nY1)
    Local $tStruct, $pPtr
    $tStruct = DllStructCreate("int[" & (@DesktopWidth * @DesktopHeight) * 4 & "]")
    $pPtr = DllStructGetPtr($tStruct)
    DllCall("pixfind.dll", "int", "FindPixels", "ptr", $pPtr, "long", DllStructGetSize($tStruct), _
            "long", BitOR($nY1 * 0x10000, BitAND($nX1, 0xFFFF)))
    If @error <> 0 Then Return SetError(1, 0, 0)
    Return $pPtr
EndFunc

You'd be better off using PixelCheckSum() and some of the options that have been showed here on the forum.

http://www.autoitscript.com/forum/index.ph...st&p=300569

Something like that maybe.


[center]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.[/center]

Share this post


Link to post
Share on other sites

To be honest, i just started learning Autoit just over 24 hours ago, so i have no idea what most of that stuff means, lol. But, thank you for pointing it out, i'll bookmark that stuff so i can learn it after i get better. I do have another question though. My code so far is:

$sum1 = 2291709728 ;El Rune, space #1 in inventory
WinActivate("Diablo II")
WinWaitActive("Diablo II")
Sleep(1000)
MouseClick("right", 455, 352, 1, 0) ;Buy El rune
Do
    Sleep(100)
Until PixelChecksum(796, 505, 815, 525) = $sum1 ;Wait until El rune is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll

So far it buys a certain item from an NPC and waits until it reaches the inventory then buys another item, it will be much longer when i'm through though. But, i would like to be able to run the script then have it pause until i press a key to start it, I read the manual page for HotKeySet but i'm not sure i understand it.


My scripts: Random Painter

Share this post


Link to post
Share on other sites

To be honest, i just started learning Autoit just over 24 hours ago, so i have no idea what most of that stuff means, lol. But, thank you for pointing it out, i'll bookmark that stuff so i can learn it after i get better. I do have another question though. My code so far is:

$sum1 = 2291709728;El Rune, space #1 in inventory
WinActivate("Diablo II")
WinWaitActive("Diablo II")
Sleep(1000)
MouseClick("right", 455, 352, 1, 0);Buy El rune
Do
    Sleep(100)
Until PixelChecksum(796, 505, 815, 525) = $sum1;Wait until El rune is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0);Buy TP scroll

So far it buys a certain item from an NPC and waits until it reaches the inventory then buys another item, it will be much longer when i'm through though. But, i would like to be able to run the script then have it pause until i press a key to start it, I read the manual page for HotKeySet but i'm not sure i understand it.

Not one for game playing, but all I can say (since you are in the right area of the help file), is trial and error... keep sticking the togglepause function with the HotKeySet function in your code until it works as expected.

[center]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.[/center]

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