Sign in to follow this  
Followers 0
CyNDeR

My first script!

5 posts in this topic

Finally i'm done with this thing, lol. This is a script for Diablo II that buys certain items from an NPC and then creates an item using said bought items. Every step is meant to take lag in account, so it won't go to the next step until the previous is completed. I was wondering if anyone see's any changes or anything to make it better.

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.9.3 (beta)
    Author:         CyNDeR
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

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) = 2291709728;Wait until El rune is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #1
Do
    Sleep(100)
Until PixelChecksum(796, 476, 816, 493) = 2195706521 ;Wait until TP scroll #1 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #2
Do
    Sleep(100)
Until PixelChecksum(768, 506, 783, 521) = 3332747689 ;Wait until TP scroll #2 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #3
Do
    Sleep(100)
Until PixelChecksum(770, 475, 781, 491) = 1837407101 ;Wait until TP scroll #3 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #4
Do
    Sleep(100)
Until PixelChecksum(743, 505, 756, 522) = 853656473 ;Wait until TP scroll #4 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #5
Do
    Sleep(100)
Until PixelChecksum(741, 474, 756, 493) = 1555684005 ;Wait until TP scroll #5 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #6
Do
    Sleep(100)
Until PixelChecksum(739, 447, 755, 463) = 1030013021 ;Wait until TP scroll #6 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #7
Do
    Sleep(100)
Until PixelChecksum(740, 417, 757, 432) = 176733501 ;Wait until TP scroll #7 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #8
Do
    Sleep(100)
Until PixelChecksum(710, 504, 726, 524) = 249818129 ;Wait until TP scroll #8 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #9
Do
    Sleep(100)
Until PixelChecksum(709, 476, 725, 494) = 3857957633 ;Wait until TP scroll #9 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #10
Do
    Sleep(100)
Until PixelChecksum(710, 446, 728, 466) = 547875901 ;Wait until TP scroll #10 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #11
Do
    Sleep(100)
Until PixelChecksum(712, 420, 725, 436) = 2338632605 ;Wait until TP scroll #11 is in inventory
Sleep(500)
MouseClick("left", 543, 559, 1, 0) ;Exit NPC screen
Sleep(1000)
Send("i") ;Open Inventory
Do
    Sleep(100)
Until PixelChecksum(600, 200, 610, 210) = 476143433 ;Wait until inventory is open
Sleep(500)
MouseClick("right", 791, 444, 1, 0) ;Open cube
Do
    Sleep(100)
Until PixelChecksum(477, 434, 487, 444) = 2003332385 ; Wait until cube is open
Sleep(500)
MouseClick("left", 805, 515, 1, 0) ;Pickup El rune
Sleep(500)
MouseMove(485, 390, 0) ;Move El rune to cube
Do
    Sleep(100)
Until PixelChecksum(789, 504, 799, 514) = 1629759053 ;Make sure El rune is moved
MouseClick("left") ;Put El rune in cube
Sleep(500)
MouseMove(808, 485, 0) ;Move to ID scroll #1
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 3815738197 ;Make sure El rune is in cube
MouseClick("left") ;Pickup ID scroll #1
Sleep(100)
MouseMove(484, 363, 0) ;Move ID scroll #1 to cube
Do
    Sleep(100)
Until PixelChecksum(797, 478, 813, 494) = 1296305645 ;Make sure ID scroll #1 is moved
Sleep(500)
MouseClick("left") ;Put ID scroll #1 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #1 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(777, 486, 0) ;Move to ID scroll #2
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 1911389945 ;Make sure Eld rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #2
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #2 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #2 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #2 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #2 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(777, 515, 0) ;Move to ID scroll #3
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 3676465189 ;Make sure Tir rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #3
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #3 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #3 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #3 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #3 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(748, 427, 0) ;Move to ID scroll #4
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 3777920305 ;Make sure Nef rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #4
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #4 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #4 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #4 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #4 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(750, 456, 0) ;Move to ID scroll #5
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 2737076461 ;Make sure Eth rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #5
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #5 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #5 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #5 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #5 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(747, 484, 0) ;Move to ID scroll #6
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 2412346989 ;Make sure Ith rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #6
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #6 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #6 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #6 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #6 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(749, 514, 0) ;Move to ID scroll #7
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 1966373137 ;Make sure Tal rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #7
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #7 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #7 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #7 is in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #7 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(720, 428, 0) ;Move to ID scroll #8
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 2728227533 ;Make sure Ral rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #8
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #8 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #8 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #8 is in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #8 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(722, 456, 0) ;Move to ID scroll #9
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 1942844001 ;Make sure Ort rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #9
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #9 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #9 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #9 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #9 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(719, 485, 0) ;Move to ID scroll #10
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 1092253645 ;Make sure Thul rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #10
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #10 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #10 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #10 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #10 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)
MouseMove(719, 514, 0) ;Move to ID scroll #11
Do
    Sleep(100)
Until PixelChecksum(478, 387, 489, 396) = 775658153 ;Make sure Amn rune is in cube
Sleep(500)
MouseClick("left") ;Pickup ID scroll #11
Sleep(500)
MouseMove(484, 362, 0) ;Move ID scroll #11 to cube
Do
    Sleep(100)
Until PixelChecksum(770, 477, 784, 492) = 4202762069 ;Make sure ID scroll #11 has been moved
Sleep(500)
MouseClick("left") ;Put ID scroll #11 in cube
Sleep(500)
MouseMove(352, 435, 0) ;Move to transmute button
Do
    Sleep(100)
Until PixelChecksum(479, 355, 490, 368) = 284074349 ;Make sure ID scroll #11 is in cube
Sleep(500)
MouseClick("left") ;Transmute
Sleep(500)

Thanks in advance. <_<


My scripts: Random Painter

Share this post


Link to post
Share on other sites



If you ran the game at a different resolution, wouldn't it break all of your checksums?

Share this post


Link to post
Share on other sites

For repeating actions use Function:

instead of

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) = 2291709728;Wait until El rune is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #1
Do
    Sleep(100)
Until PixelChecksum(796, 476, 816, 493) = 2195706521 ;Wait until TP scroll #1 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #2
Do
    Sleep(100)
Until PixelChecksum(768, 506, 783, 521) = 3332747689 ;Wait until TP scroll #2 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #3
Do
    Sleep(100)
Until PixelChecksum(770, 475, 781, 491) = 1837407101 ;Wait until TP scroll #3 is in inventory
...oÝ÷ Úëjëh×6WinActivate("Diablo II")
WinWaitActive("Diablo II")

DoAction(1000, 455, 352, 796, 505, 815, 525, 2291709728) ;Buy El rune
DoAction(500, 483, 350, 796, 476, 816, 493, 2195706521) ;Buy TP scroll #1
DoAction(500, 483, 350, 768, 506, 783, 521, 3332747689) ;Buy TP scroll #2
DoAction(500, 483, 350, 770, 475, 781, 491, 1837407101) ;Buy TP scroll #3
...


Func DoAction($sleep_time, $ClickX, $ClickY, $X1, $Y1, $X2, $Y2, $checksum)
    Sleep($sleep_time)
    MouseClick("right", $ClickX, $ClickY, 1, 0)
    Do
        Sleep(100)
    Until PixelChecksum($X1, $Y1, $X2, $Y2) = $checksum
EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If you ran the game at a different resolution, wouldn't it break all of your checksums?

Yes, it would, the script has to have some setup, it's not entirely automated yet. This is just my first try at it.

MouseMove() is unnecessary. Just put X,Y directly into MouseClick()

I had to move the mouse to another spot then use PixelChecksum on the spot it came from to make sure that the item was picked up, this was to make sure that if i lagged it wouldnt mess up.

For repeating actions use Function:

instead of

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) = 2291709728;Wait until El rune is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #1
Do
    Sleep(100)
Until PixelChecksum(796, 476, 816, 493) = 2195706521 ;Wait until TP scroll #1 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #2
Do
    Sleep(100)
Until PixelChecksum(768, 506, 783, 521) = 3332747689 ;Wait until TP scroll #2 is in inventory
Sleep(500)
MouseClick("right", 483, 350, 1, 0) ;Buy TP scroll #3
Do
    Sleep(100)
Until PixelChecksum(770, 475, 781, 491) = 1837407101 ;Wait until TP scroll #3 is in inventory
...ƒoÝŠ÷ ÚëjëhŠ×6WinActivate("Diablo II")
WinWaitActive("Diablo II")

DoAction(1000, 455, 352, 796, 505, 815, 525, 2291709728) ;Buy El rune
DoAction(500, 483, 350, 796, 476, 816, 493, 2195706521) ;Buy TP scroll #1
DoAction(500, 483, 350, 768, 506, 783, 521, 3332747689) ;Buy TP scroll #2
DoAction(500, 483, 350, 770, 475, 781, 491, 1837407101) ;Buy TP scroll #3
...
Func DoAction($sleep_time, $ClickX, $ClickY, $X1, $Y1, $X2, $Y2, $checksum)
    Sleep($sleep_time)
    MouseClick("right", $ClickX, $ClickY, 1, 0)
    Do
        Sleep(100)
    Until PixelChecksum($X1, $Y1, $X2, $Y2) = $checksum
EndFuncoÝ÷ Ûú®¢×®±æ®¶­sevä7FfFRgV÷C´F&ÆògV÷C²¥våvD7FfRgV÷C´F&ÆògV÷C² ¤Fô7FöâÂCSRÂ3S"ÂsbÂSRÂRÂS#RÂ##ss#´'WVÂ'VæP¤Fô7FöâSÂC2Â3SÂsbÂCsbÂbÂC2Â#SscS#´'WE67&öÆÂ3¤Fô7FöâSÂC2Â3SÂscÂSbÂs2ÂS#Â333#sCsc´'WE67&öÆÂ3 ¤Fô7FöâSÂC2Â3SÂssÂCsRÂsÂCÂ3sCs´'WE67&öÆÂ30¢ââà  ¤gVæ2Fô7Föâb33c·6ÆVW÷FÖRÂb33c´6Æ6µÂb33c´6Æ6µÂb33cµÂb33cµÂb33cµ"Âb33cµ"Âb33c¶6V6·7VÒ¢6ÆVWb33c·6ÆVW÷FÖR¢Ö÷W6T6Æ6²gV÷C·&vBgV÷C²Âb33c´6Æ6µÂb33c´6Æ6µÂ¢Fð¢6ÆVW¢VçFÂVÄ6V6·7VÒb33cµÂb33cµÂb33cµ"Âb33cµ"Òb33c¶6V6·7VФVæDgVæ0

I'll start working on that right now, looks like a very good way to clean up the code, thanks. <_<

Edited by CyNDeR

My scripts: Random Painter

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