Guest Forgaria Posted June 27, 2005 Share Posted June 27, 2005 (edited) Hello ! As the title says, I'm totally new in AutoIT. I have found this little piece of code which seems quiet close to what I wanna do : $top = 415 $left = 500 $bottom = 420 $right = 505 Func waitForTrade($left,$top,$right,$bottom) $checksum = PixelChecksum($left,$top,$right,$bottom) while $checksum = PixelChecksum($left,$top,$right,$bottom) Sleep(100) WEnd if $tradeOn = 1 then enterTrade($left,$top) else waitForTrade($left,$top,$right,$bottom) endif EndFunc Func enterTrade($x,$y) MouseClick("left",$x,$y, 1, 0) SellCommons() EndFunc 1. Why is there variables in the Func WaitForTrade ? Are they really useful ? It seems to me that only the position variables inside PixelChecksum are necessary... 2. Why is there variables ($left,$stop) in the first EnterTrade ? 3. What is WEnd ? 4. What is endif ? 5. What are these $x,$y variables ? Thanks ! Edited June 27, 2005 by Forgaria Link to comment Share on other sites More sharing options...
blindwig Posted June 28, 2005 Share Posted June 28, 2005 (edited) Check the help file (default location is in "C:\Program Files\AutoIt3\AutoIt.chm") for info on AutoIt script syntax. Edited June 28, 2005 by blindwig My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
Guest Forgaria Posted June 28, 2005 Share Posted June 28, 2005 Done ! I have understand what WEnd and endif are... But 1, 2 and 5 are still unclear for me... Link to comment Share on other sites More sharing options...
FuryCell Posted June 28, 2005 Share Posted June 28, 2005 (edited) Done !I have understand what WEnd and endif are...But 1, 2 and 5 are still unclear for me...<{POST_SNAPBACK}>Here are the answers to your questions.1. The $left,$top,$right, and $bottom are parameters that are passed to _WaitForTrade() and are used for PixelCheckSum(). The other variables i need to see the whole script for to tell you if they are used.2. They are parameters passed to enterTrade() that specify where to click.5.They are parimeters passed to _EnterTrade() that specify where the mouse should click. Edited June 28, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Guest Forgaria Posted June 28, 2005 Share Posted June 28, 2005 Here is the whole script. It's a bot for Magic Online.;StandingReserve's commonBot;Version: 0.11$tradeOn = 1$maxtime = 600000$greetMessage = "Hello, this is StandingReserve's commonBot. I sell 32 commons for 1 ticket. You have 10 minutes to complete your trade. If you encounter any problems please PM standingreserve."$noTicket = "You have no tickets tradeable. Please make a ticket tradeable or exit the trade"$iniFileLines = 8$os = "2000"$resolutionX = 1024$resolutionY = 768$colordepth = 24;Variables for screen locations;Variables for checksum location for looking for beginning of trade$top = 415$left = 500$bottom = 420$right = 505;Variables for checking for withdrawing from trade;PixelGetColor(639,329) = 3356477 then$withdrawX = 639$withdrawY = 329$withdrawColor = 3356477;Variable to recognize 32 cards;80,280,100,300$CardTarget = 490423324$cardTakenX1 = 80$cardTakenY1 = 280$cardTakenX2 = 100$cardTakenY2 = 300;Location of ticket already taken;MouseClick("left",185,155,1,10)$myTicketX = 185$myTicketY = 155;Variables for narrowing our search down to just tickets;MouseClick("left",80,62,1,10);MouseClick("left",240,144,1,0);MouseClick("left",160,200,1,10)$searchX = 80$searchY = 62$dropX = 240$dropY = 144$boosterX = 160$boosterY = 200;Ticket to take location;if PixelGetColor(420,155) <> 9185056 then$ticketX = 420$ticketY = 155$ticketColor = 9185056;Tradebutton Location;MouseClick("left",195,60,1,10)$tradeButtonX = 195$tradeButtonY = 60;Make sure they don't cheat the bot$cheatCheckX = 195$cheatCheckY = 140$myTicketsBackground = 2969133;Variables for confirming the trade$confirmDropX = 240$confirmDropY = 330$confirmClickX = 170$confirmClickY = 345;Variables to determine if they have confirmed$theirConfirmX1 = 45$theirConfirmY1 = 325$theirConfirmX2 = 60$theirConfirmY2 = 330$theirConfirmChecksum = 518491551;Final trade confirmation$performThisTradeX = 715$performThisTradeY = 600$performThisTradeWaitX1 = 300$performThisTradeWaitY1 = 460$performThisTradeWaitX2 = 305$performThisTradeWaitY2 = 465;Checking for completed Trade$tradeCompletedX = 500$tradeCompletedY = 400$tradeCompletedColor = 3290940$tradeCompletedCheckX = 614$tradeCompletedCheckY = 424$completedDragStartX = 525$completedDragStartY = 60$completedDragFinishX = 800$completedDragFinishY = 60$completedDragClickX = 1000$completedDragClickY = 55;Canceling Trade Variables$cancelTradeX = 775$cancelTradeY = 600;reset from withdrawel variables$resetX = 606$resetY = 418;Chat location$chatX = 285$chatY = 710loadINI()waitForTrade($left,$top,$right,$bottom);This function loads up the .ini configuration fileFunc loadINI() $loadWorked = 1 $file = FileOpen("commonBot.ini", 0) If $file = -1 Then MsgBox(0, "ERROR", "No initialization file!") Exit endIf $lineCounter = 0 while $lineCounter < 8 $theLine = FileReadLine($file) $currentLine = StringSplit($theLine, "-") if $currentLine[0]< 2 then msgBox(0, "ERROR", "Line " & $lineCounter + 1 & " is wrong") $loadWorked = 0 exitLoop endIf Select Case $lineCounter = 0  if StringIsDigit($currentLine[2]) = 0 then  MsgBox(0, "ERROR", "tradeOn variable incorrect")  $loadWorked = 0  exitLoop  endif  $tradeOn = $currentLine[2] Case $lineCounter = 1  if StringIsDigit($currentLine[2]) = 0 then  MsgBox(0, "ERROR", "maxtime variable incorrect")  $loadWorked = 0  exitLoop  endif  $maxtime = $currentLine[2] Case $lineCounter = 2  if $currentLine[2] = "2000" OR $currentLine[2] = "XP" then  $os = $currentLine[2]  else  MsgBox(0, "ERROR", "OS variable incorrect")  $loadWorked = 0  exitLoop  endif Case $lineCounter = 3  if StringIsDigit($currentLine[2]) = 0 then  MsgBox(0, "ERROR", "ResolutionX variable incorrect")  $loadWorked = 0  exitLoop  endif  if $currentLine[2] = "1024" then  $resolutionX = $currentLine[2]  else  MsgBox(0, "ERROR", "Your resolution is unsupported")  $loadWorked = 0  exitLoop  endif Case $lineCounter = 4  if StringIsDigit($currentLine[2]) = 0 then  MsgBox(0, "ERROR", "resolutionY variable incorrect")  $loadWorked = 0  exitLoop  endif  if $currentLine[2] = "768" then  $resolutionY = $currentLine[2]  else  MsgBox(0, "ERROR", "Your resolution is unsupported")  $loadWorked = 0  exitLoop  endif Case $lineCounter = 5  if StringIsDigit($currentLine[2]) = 0 then  MsgBox(0, "ERROR", "colordepth variable incorrect")  $loadWorked = 0  exitLoop  endif  if $currentLine[2] = "24" then  $colordepth = $currentLine[2]  else  MsgBox(0, "ERROR", "Your colordepth is unsupported")  $loadWorked = 0  exitLoop  endif Case $lineCounter = 6  $greetMessage = $currentLine[2] Case $lineCounter = 7  $noTicket = $currentLine[2] EndSelect $lineCounter = $lineCounter + 1 Wend if $loadWorked = 0 then MsgBox(0, "ERROR IN COMMONBOT.INI", "There were errors in your commonBot.ini file. Please correct them then restart the program") Exit endif if $os = "2000" then if $resolutionX = 1024 AND $resolutionY = 768 then if $colordepth = 24 then  $top = 415  $left = 500  $bottom = 420  $right = 505  $withdrawX = 639  $withdrawY = 329  $withdrawColor = 3356477  $CardTarget = 490423324  $cardTakenX1 = 80  $cardTakenY1 = 280  $cardTakenX2 = 100  $cardTakenY2 = 300  $myTicketX = 185  $myTicketY = 155  $searchX = 80  $searchY = 62  $dropX = 240  $dropY = 144  $boosterX = 160  $boosterY = 200  $ticketX = 420  $ticketY = 155  $ticketColor = 9185056  $tradeButtonX = 195  $tradeButtonY = 60  $cheatCheckX = 195  $cheatCheckY = 140  $myTicketsBackground = 2969133  $confirmDropX = 240  $confirmDropY = 330  $confirmClickX = 170  $confirmClickY = 345  $theirConfirmX1 = 45  $theirConfirmY1 = 325  $theirConfirmX2 = 60  $theirConfirmY2 = 330  $theirConfirmChecksum = 518491551  $performThisTradeX = 715  $performThisTradeY = 600  $performThisTradeWaitX1 = 300  $performThisTradeWaitY1 = 460  $performThisTradeWaitX2 = 305  $performThisTradeWaitY2 = 465  $tradeCompletedX = 500  $tradeCompletedY = 400  $tradeCompletedColor = 3290940  $tradeCompletedCheckX = 614  $tradeCompletedCheckY = 424  $completedDragStartX = 525  $completedDragStartY = 60  $completedDragFinishX = 800  $completedDragFinishY = 60  $completedDragClickX = 1000  $completedDragClickY = 55  $cancelTradeX = 775  $cancelTradeY = 600  $resetX = 606  $resetY = 418  $chatX = 285  $chatY = 710 EndIF EndIF EndIfEndFunc;This function waits until the trade window pops up at a specific point.Func waitForTrade($left,$top,$right,$bottom) $checksum = PixelChecksum($left,$top,$right,$bottom) while $checksum = PixelChecksum($left,$top,$right,$bottom) Sleep(100) WEnd if $tradeOn = 1 then enterTrade($left,$top) else waitForTrade($left,$top,$right,$bottom) endifEndFuncFunc enterTrade($x,$y) MouseClick("left",$x,$y, 1, 0) SellCommons()EndFuncFunc SellCommons() sendMessage($greetMessage) sendMessage("I am running StandingReserve's commonBot version 0.11") $startTime = TimerInit() $ticketTaken = 0 $temp = 1 $confirmed = 0 mouseClick("left",$myTicketX, $myTicketY, 1,10) while $temp = 1 ;First check if they have withdrawn from trade if PixelGetColor($withdrawX, $withdrawY) = $withdrawColor then ResetFromWithdraw() endif ;The checksum changes when a card has been added or subtracted $checksum = PixelChecksum($cardTakenX1, $cardTakenY1, $cardTakenX2 , $cardTakenY2) ;msgBox(1,"foo",$checksum) if $checksum <> $CardTarget then if $ticketTaken = 1 then  MouseClick("left", $myTicketX, $myTicketY,1,10)  $ticketTaken = 0  $confirmed = 0 endif else if $ticketTaken = 0 then  ;Find a ticket  MouseClick("left",$searchX , $searchY,1,10)  Sleep(100)  MouseClick("left",$dropX,$dropY,1,0)  Sleep(100)  MouseClick("left",$boosterX,$boosterY,1,10)  Sleep(6000)  if PixelGetColor($ticketX, $ticketY) <> $ticketColor then  ;They don't have a ticket up for trade  sendMessage($noTicket)  Sleep(20)  MouseClick("left", $tradeButtonX, $tradeButtonY,1,10)  else  MouseClick("left",$ticketX, $ticketY,1,10)  Sleep(20)  MouseClick("left",$tradeButtonX, $tradeButtonY,1,10)  $ticketTaken = 1  $confirmed = 0  endif endif endif  if $ticketTaken = 1 then ;Make sure that they don't remove their ticket $safetyChecksum = PixelGetColor($cheatCheckX, $cheatCheckY) if $safetyChecksum = $myTicketsBackground then  $ticketTaken = 0  SendMessage("Please do not try and cheat the bot") else  if $confirmed = 0 then  MouseClick("left",$confirmDropX, $confirmDropY,1,10)  Sleep(50)  MouseClick("left",$confirmClickX, $confirmClickY,1,10)  $confirmed = 1  endif    if PixelGetColor($withdrawX, $withdrawY) = $withdrawColor then  ResetFromWithdraw()  endif  $confirmchecksum = PixelChecksum($theirConfirmX1, $theirConfirmY1, $theirConfirmX2, $theirConfirmY2)  if $confirmchecksum = $TheirConfirmChecksum then  sleep(2000)  if PixelGetColor($withdrawX, $withdrawY) = $withdrawColor then   ResetFromWithdraw()  endif  performThisTrade()  endif endif endif if TimerDiff($startTime) > $maxtime then abortTrade() endif  ;Slow down the bot some sleep(500) wend EndFuncFunc performThisTrade() MouseClick("left",$performThisTradeX, $performThisTradeY) $waitchecksum = PixelChecksum($performThisTradeWaitX1,$performThisTradeWaitY1,$performThisTradeWaitX2,$performThisTradeWaitY2) while $waitchecksum = PixelChecksum($performThisTradeWaitX1,$performThisTradeWaitY1,$performThisTradeWaitX2,$performThisTradeWaitY2) sleep(20) wend ;see if they confirmed if pixelGetColor($tradeCompletedX, $tradeCompletedY) = $tradeCompletedColor then MouseClick("left",$tradeCompletedCheckX, $tradeCompletedCheckY) sleep(10) MouseClickDrag("left",$completedDragStartX, $completedDragStartY, $completedDragFinishX, $completedDragFinishY) MouseClick("left",$completedDragClickX,$completedDragClickY) waitForTrade($left,$top,$right,$bottom) else ;they canceled, we need to recover MouseClick("left",$tradeButtonX, $tradeButtonY) SellCommons() endifEndFuncFunc abortTrade() MouseClick("left",$cancelTradeX ,$cancelTradeY) sleep(500) waitForTrade($left,$top,$right,$bottom) EndFuncFunc resetFromWithdraw() MouseClick("left",$resetX,$resetY) waitForTrade($left,$top,$right,$bottom)EndFuncFunc sendMessage($messageString) MouseClick("left",$chatX, $chatY) Send($messageString) Send("{ENTER}")EndFunc ;These are values for checking the numbers of cards being transfered;1: 3679399253;2: 1426267079;3: 4173342256;4: 1439835295;5: 1724459089;6: 2880646084 ;7: 1121135944 ;8: 1938694045 ;9: 3701681956;10: 493890957;11: 1740194342;12: 2902536487;13: 476855108;14: 1477851429;15: 1764179205;16: 1983987807;17: 4997678;18: 1694577754;19: 387007444;20: 3295953430;21: 193285263;22: 1355627408;23: 3223930285;24: 4224926606;25: 217270126;26: 437078728;27: 2752072855;28: 147668675;29: 3134082621;30: 1749044351;31: 1753762558;32: 2916104703 OR 490423324;Unconfirmed: 406357036;Confirmed: 518491551;Binder Ring: 16382453 (x:639 y:329);MessageWindow Background: 33564771. I don't understand the reason why you have to specify it in the function if they are to be used only in the PixelChecksum.... I mean, if we remove them, it will still work no ?5. Ok, but I don't see where are the values for $x & $y...6. What do you mean by "passed" ?Thanks ! Link to comment Share on other sites More sharing options...
Guest Forgaria Posted June 28, 2005 Share Posted June 28, 2005 Bump ! Link to comment Share on other sites More sharing options...
blindwig Posted June 28, 2005 Share Posted June 28, 2005 Here is the whole script. It's a bot for Magic Online.1. I don't understand the reason why you have to specify it in the function if they are to be used only in the PixelChecksum.... I mean, if we remove them, it will still work no ?5. Ok, but I don't see where are the values for $x & $y...6. What do you mean by "passed" ?Thanks !<{POST_SNAPBACK}>1. You can take it out and hard-code it, but then the function caller has no way to control what it's waiting for.5. the values of $x and $y in enterTrade() are passed from $left and $top (respectively) from the waitForTrade() function.6. If you don't understand the concept of passing variables to functions, you really need to pick up a "beginners guide to programming" book and go through it. There are no (that I know of at this moment) beginner books on AutoIt, but a book on vbscript should be close enough to get you through the basics. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
FuryCell Posted June 28, 2005 Share Posted June 28, 2005 (edited) Here is the whole script. It's a bot for Magic Online.1. I don't understand the reason why you have to specify it in the function if they are to be used only in the PixelChecksum.... I mean, if we remove them, it will still work no ?5. Ok, but I don't see where are the values for $x & $y...6. What do you mean by "passed" ?Thanks !<{POST_SNAPBACK}>Yes all the variables from your first post appear to be used in the script.Also did Tidy+Doc and the variables are all used on 2 or more lines.1. they appear to be used in other places too5. & 6. Look up Func.... EndFunc in the manual Edited June 28, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now