ravenette Posted September 7, 2009 Share Posted September 7, 2009 Ok so I've only been using autoit for three days, and I've been mostly looking at other people's scripts to see what to do etc. I did go to http://www.mpcforum.com/showthread.php?t=108933 and I read all of his info. I am trying to make a script that will look at the pixel colors (health of my character) and hit one (drink a pot) if the health goes down. I already made a script to check pixel colors for a follow bot and it seems to be working ok this is it: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: myName Script Function: Template AutoIt script. #ce -----------pp----------------------------------------------------------------- ; Script Start - Add your code below here Opt("MouseCoordMode", 0) $Party = "\" $TP = ";" $EndGame = "z" $EnterChat = "=" $gamename = "run qw-" $gamevariable = 00 $gamepass = "qa" $JoinGame = "/" hotkeyset($JoinGame, "JoinGame") $ClearScreen = "]" hotkeyset($ClearScreen, "ClearScreen") hotkeyset($EnterChat, "EnterChat") hotkeyset($Party, "Party") hotkeyset($EndGame, "EndGame") hotkeyset($TP, "TP") idle() ;----------------------------------------VARS END------------------------------ Func ClearScreen () Send("{ENTER}" & "Clearing Screen" & "{ENTER}") Sleep (300) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) Send("{ENTER}" & "." & "{ENTER}") Sleep (500) EndFunc Func Party () Send("{p}") Sleep (300) MouseMove(217,110,10) Sleep (300) MouseClick("left", 217, 110, 1, 10) Sleep (300) Send("{p}") Sleep (300) ClearScreen () TP () EndFunc Func TP () Send("{NUMLOCK ON}") Send("{NUMPAD0}") Send ("{M}") Sleep (15000) $coord = PixelSearch( 10, 89, 637, 264, 0x0CC41C, 10 ) While @error = 1 $coord = PixelSearch( 10, 89, 637, 264, 0x0CC41C, 10 ) $coor = PixelSearch( 10, 89, 637, 264, 0x0CC41C, 10, 2 ) WEnd IF @error = 0 Then Send ("{M}") Sleep (20000) MouseMove(323,183,10) Sleep (500) MouseClick("left", 323, 183, 1, 10) MouseMove(323,183,10) Sleep (500) MouseClick("left", 323, 183, 1, 10) Sleep (1000) MouseMove(579,158,10) Sleep (1000) MouseClick("left", 579, 158, 1, 10) Sleep (1000) ;MouseClick("left", 579, 158, 1, 10) ;Sleep (1000) MouseClickDrag ( "left", 579, 158, 492, 178 , 10 ) Potion() ClearScreen () Sleep (1000) EndIf EndGame () EndFunc Func EndGame () Sleep (1000) Send ("{M}") Sleep (1000) $coord = PixelSearch( 10, 89, 637, 264, 0x0CC41C, 10 ) While @error = 1 $coord = PixelSearch( 10, 89, 637, 264, 0x0CC41C, 10 ) $coor = PixelSearch( 10, 89, 637, 264, 0x0CC41C, 10, 2 ) WEnd IF @error = 0 Then Sleep (1000) Send ("{M}") Sleep (2000) Send ("{ESCAPE}") Sleep (1000) MouseMove(315,229,10) Sleep (1000) MouseClick("left", 315, 229, 1, 10) Send ("{ENTER}") Sleep (5000) EndIf EnterChat () EndFunc Func EnterChat () ;Always put in Chat First Sleep (10000) $coord = PixelSearch( 25, 135, 387, 401, 0x18FC00, 10 ) While @error = 1 $coord = PixelSearch( 25, 135, 387, 401, 0x18FC00, 10 ) $coor = PixelSearch( 25, 135, 387, 401, 0x18FC00, 10, 2 ) WEnd IF @error = 0 Then JoinGame () EndIf idle () EndFunc func idle() While 1 Sleep(1400) WEnd endfunc Func JoinGame () Sleep(2000) MouseMove(708,489,10) Sleep (1000) MouseClick("left", 708, 489, 1, 10) Sleep (1000) $gamevariable += 1 if $gamevariable >= 1 Then Send ($gamename & "{0}" & $gamevariable) Else Send($gamename & $gamevariable) Sleep(100) EndIf Send("{TAB}") Sleep(100) Send($gamepass) Sleep(3000) Send("{ENTER}") Send("{ENTER}") Send("{ENTER}") Sleep (5000) Potion() Party () EndFunc I made another script based on the same principle (I think) to check for the life area this is it: expandcollapse popupOpt("MouseCoordMode", 0) Opt("PixelCoordMode", 0) $idle = "x" hotkeyset($idle, "idle") idle() func idle() Sleep(10000) Life() endfunc Func Life() $coord = PixelSearch( 39, 423, 111, 450, 0x5C0000 ) While @error = 0 $coord = PixelSearch( 39, 423, 111, 450, 0x5C0000 ) $coor = PixelSearch( 39, 423, 111, 450, 0x5C0000, 2 ) Sleep(1000) WEnd If @error = 1 Then $coord = PixelSearch( 39, 423, 111, 450, 0x5C0000, 10 ) $coor = PixelSearch( 39, 423, 111, 450, 0x5C0000, 10, 2 ) Sleep(2000) if @error = 0 Then Sleep(500) Send("{ENTER}" & "Need a Pot" & "{ENTER}") Sleep(1000) Potion1() EndIf EndIf idle() EndFunc Func Potion1() ;$varpotcount = 16 ;$varpotdrunk = $varpotcount - 1 ;Select ;Case ;$varpotdrunk > 12 Send("{1}") ;$varpotdrunk -= 1 Sleep(1000) Send("{ENTER}" & "One" & "{ENTER}") idle() ;Case $varpotdrunk > 8 and $varpotdrunk <= 12 ;Send("{2}") ;$varpotdrunk -= 1 ;Send("{ENTER}" & "Two" & "{ENTER}") ;Sleep(1000) ; Case $varpotdrunk > 4 and $varpotdrunk <= 8 ;Send("{3}") ;$varpotdrunk -= 1 ;Life() ;Case $varpotdrunk > 1 and $varpotdrunk <= 4 ; Send("{4}") ; $varpotdrunk -= 1 ; Life() ;Case $varpotdrunk = 0 ; Send("{Out of Pots}") ; EndSelect EndFunc ; Func Potion2() ; $coord = PixelSearch( 381, 477, 395, 495, 0xe07070, 10 ) ; $coor = PixelSearch( 381, 477, 395, 495, 0xe07070, 10,2 ) ; If @error = 1 Then ; Send("{2}") ; If @error = 0 Then ; $coord = PixelSearch( 381, 477, 395, 495, 0xe07070, 10 ) ; $coor = PixelSearch( 381, 477, 395, 495, 0xe07070, 10,2 ) ; EndIf ; EndIf ;EndFunc Ignore the lines with ; before them in this one...I was trying to get it to count down the number of potions it had starting from 16 but that didn't work and the bottom function potion2() I was trying to get it to look for the color of the potions if the 1st row of potions was missing.... My first script checks the pixel color and when it sees the green color it executes it's next step....the second script won't drink more than once...and if it's life is already full it won't check again...can anyone help with this? Link to comment Share on other sites More sharing options...
JohnOne Posted September 7, 2009 Share Posted September 7, 2009 (edited) You could use pixelchecksum to check if a region of the screen has changed colour, then.. do Edited September 7, 2009 by JohnOne AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ravenette Posted September 7, 2009 Author Share Posted September 7, 2009 You could use pixelchecksum to check if a region of the screen has changed colour, then.. dokk lemme research/try this out I'll repost to say how it goes thanks! Link to comment Share on other sites More sharing options...
ravenette Posted September 8, 2009 Author Share Posted September 8, 2009 You could use pixelchecksum to check if a region of the screen has changed colour, then.. do You're awesome! That works perfectly! Now I have another question...I'm trying to get it to subtract the number of pots it drinks from the total number and to drink from a different row when the first one is empty. FYI: The drinks are in 4 rows and 4 columns so pressing "1" gives it a drink out of row one and there are four pots in each row expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Opt("MouseCoordMode", 0) Opt("PixelCoordMode", 0) #include <EventLog.au3> $idle = "x" hotkeyset($idle, "idle") idle() func idle() Sleep(10000) Life() endfunc Func Life() $checksum = PixelChecksum( 74, 438, 74, 438) While $checksum = PixelChecksum( 74, 438, 74, 438) Sleep(1000) WEnd Do Sleep(500) Send("{ENTER}" & "Need a Pot" & "{ENTER}") Sleep(1000) potion1() Until Send("{ENTER}" & "Drank" & "{ENTER}") EndFunc Func Potion1() $varpotcount = 16 $varpotdrunk = $varpotcount - 1 Select Case $varpotdrunk > 12 Send("{1}") $varpotdrunk -= 1 Sleep(1000) Send("{ENTER}" & "One" & "{ENTER}") Sleep(200) Send("{ENTER}" & "Drank" & "{ENTER}") idle() Case $varpotdrunk > 8 and $varpotdrunk <= 12 Send("{2}") $varpotdrunk -= 1 Send("{ENTER}" & "Two" & "{ENTER}") Sleep(1000) Case $varpotdrunk > 4 and $varpotdrunk <= 8 Send("{3}") $varpotdrunk -= 1 Life() Case $varpotdrunk > 1 and $varpotdrunk <= 4 Send("{4}") $varpotdrunk -= 1 Life() Case $varpotdrunk = 0 Send("{Out of Pots}") EndSelect EndFunc I am not sure on my logic here or if I'm using the variables correctly...if you can understand what I'm trying to do can you assist? Thanks! Link to comment Share on other sites More sharing options...
ravenette Posted September 8, 2009 Author Share Posted September 8, 2009 I got it working! Thanks again JohnOne, your advice was great! Topic Closed...I'm now only about 98% noob 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