Sniperwolf Posted August 10, 2007 Share Posted August 10, 2007 Hi all! I am trying to make a macro for a game. I know some people are against macros cause they feel like it is cheating. But who says I am going to use it, its just the challenge of making it that I am after and all the new stuff I learn. I am very new to AutoIT and code so please be very clear in explaining things. I have read the help file so many times now and I still dont get what I should do to make the macro do the things I want.Basically I have made a bunch of functions and a GUI but now I really dont know what to do next.Here is how the GUI looks, you can see the code further down.As you can see I have some check boxes and some buttons and stuff. If you want to mine ice with combat drones and you want to mine to station and shield tank for example I need the script to recognise that theese boxes are checked and preform a action out of that. But I really dont know how I should build the structure of this macro, I feel like I am digging myself in deaper and deaper . I know what I want the macro to do but I dont understand How.for example: If shieldtank, armortank is booth unchecked then the macro shouldnt look at the Hp bars to see if HP is getting low and start repairing. If the shieldtank button is checked I need it to do this for shield. Can you build it like the macro is programming itself from the info it gets in the GUI? I dont know if you understood that really, maybe I didnt quite understood that either . Or should I make many different macros? for example one for icemining with combatdrones whilst shieldtanking and one for icemining with combatdrones whilst armortanking and many many more for all the different options on the GUI. If I do it like this I need to make VERY MANY macros.If I want to Icemine with combat drones to station I could write a macro for that thing using the functions but how should I make it so the macro does that by itself using the info it got in the GUI screen.I hope someone gets what I am looking for here, maybe I just started with a too big project as a first one. There are loads of lines here but all the functions work so that isnt really a problem its just how I should do to make them work with the GUI aswell, the problem is not only that the macro should run certain functions if certain boxes is checked in the GUI part, it also has to do them in the right order.expandcollapse popupDim $Form1_1, $Start, $progressbar, $Mine2CH, $IceMine, $Mine, $Ratt, $Combatdrones, $Miningdrones, $Mine2station, $Mine2can, $Mine2RA, $Shieldtank, $Armortank, $Ammo, $TankAlways, $Mine2BM, $login, $password, $Avoid, $Help Opt("CaretCoordMode", 0) ;1=absolute, 0=relative, 2=client Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client Opt("PixelCoordMode", 0) ;1=absolute, 0=relative, 2=client Opt("GUIOnEventMode", 1) #include <GUIConstants.au3> #region $form1_1 = GUICreate("ROBOEVE", 801, 101, 14, 863) GUISetBkColor(0x716F64) $start = GUICtrlCreateButton("Start", 720, 70, 50, 20, 0) GUICtrlSetTip(-1, "click to start the bot") GUICtrlSetOnEvent($start, "detection") ;this was just for test if I could make something happen when clicking the button GUICtrlCreatePic("C:\Documents and Settings\Sniperwolf\Skrivbord\ROBOEVE\roboeve.jpg", 20, 6, 183, 15, BitOR($SS_NOTIFY,$WS_GROUP)) $progressbar = GUICtrlCreateProgress(16, 85, 195, 9) GUICtrlSetData(-1, 25) $mine2ch = GUICtrlCreateCheckbox("Mine2CH", 384, 25, 70, 25) GUICtrlSetBkColor(-1, 0x716F64) GUICtrlSetOnEvent($mine2ch,"detection") GUICtrlCreatePic("C:\Documents and Settings\Sniperwolf\Skrivbord\ROBOEVE\background.jpg", 20, 28, 185, 49, BitOR($SS_NOTIFY,$WS_GROUP)) $icemine = GUICtrlCreateRadio("IceMine", 224, 5, 60, 25) GUICtrlSetBkColor(-1, 0x716F64) $mine = GUICtrlCreateRadio("Mine", 224, 25, 60, 25) GUICtrlSetBkColor(-1, 0x716F64) $ratt = GUICtrlCreateRadio("Ratt", 224, 45, 60, 25) GUICtrlSetBkColor(-1, 0x716F64) $combatdrones = GUICtrlCreateCheckbox("Combatdrones", 288, 5, 90, 25) GUICtrlSetBkColor(-1, 0x716F64) $miningdrones = GUICtrlCreateCheckbox("Miningdrones", 288, 25, 90, 25) GUICtrlSetBkColor(-1, 0x716F64) $mine2station = GUICtrlCreateCheckbox("Mine2station", 288, 45, 90, 25) GUICtrlSetBkColor(-1, 0x716F64) $mine2can = GUICtrlCreateCheckbox("Mine2can", 384, 5, 70, 25) GUICtrlSetBkColor(-1, 0x716F64) $mine2ra = GUICtrlCreateCheckbox("Mine2RA", 384, 45, 70, 25) GUICtrlSetBkColor(-1, 0x716F64) $shieldtank = GUICtrlCreateCheckbox("Shieldtank", 544, 5, 70, 25) GUICtrlSetBkColor(-1, 0x716F64) $armortank = GUICtrlCreateCheckbox("Armortank", 544, 25, 70, 25) GUICtrlSetBkColor(-1, 0x716F64) $ammo = GUICtrlCreateCheckbox("Ammo", 456, 45, 70, 25) GUICtrlSetBkColor(-1, 0x716F64) $tankalways = GUICtrlCreateCheckbox("TankAlways", 544, 45, 89, 25) GUICtrlSetBkColor(-1, 0x716F64) $mine2bm = GUICtrlCreateCheckbox("Mine2BM", 456, 5, 73, 25) GUICtrlSetBkColor(-1, 0x716F64) $login = GUICtrlCreateInput("LOGIN", 640, 8, 137, 21) $password = GUICtrlCreateInput("PASSWORD", 640, 40, 137, 21) $avoid = GUICtrlCreateCheckbox("Avoid", 456, 25, 73, 25) GUICtrlSetBkColor(-1, 0x716F64) $help = GUICtrlCreateButton("Help", 648, 70, 50, 20, 0) GUICtrlSetOnEvent($help, "detection") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd #EndRegion func mousemovereal ($x,$y,$speed,$steps,$Auto) ; The mousemover dim $q[2] $q[0] = $x $q[1] = $y $p = MouseGetpos() $len = Sqrt(($p[0]+$q[0])*($p[0]+$q[0]))+(($p[1]+$q[1])*($p[1]+$q[1])) $x=$x+Random(-2,2) $y=$y+Random(-2,2) if $Auto = 0 Then $steps = Random(50,250) endif $mousestart = MouseGetpos() for $i = 1 to $steps mousemove(($p[0]+($i*($q[0]-$p[0])/$steps))+random(random(-2,0),random(0,2)),$p[1]+($i*($q[1]-$p[1])/$steps)+random(random(-2,0),random(0,2)),$speed) $Secondmove = MouseGetPos() next mousemove($x,$y,$speed) if $speed = 0 Then $speed = Random(50,100) endif endfunc func mousedownreal($button) ;Mouseclick with move $pos = MouseGetPos() mousemove($pos[0]-random(random(-2,0),random(0,2)),$pos[1]-random(random(-2,0),random(0,2)),1) mousedown($button) EndFunc func mouseupreal($button) ;mouseclick with move $pos = MouseGetPos() mousemove($pos[0]-random(random(-2,0),random(0,2)),$pos[1]-random(random(-2,0),random(0,2)),1) mouseup($button) EndFunc Func logintoeve () If WinExists ("EVE") Then WinActivate("EVE","") WinWaitActive("EVE","") Do $srch = PixelSearch( 297, 360, 297, 360, 12698307) Until Not @error And $srch[0] == 297 And $srch[1] == 360 Sleep(514) mousemovereal(164,344,0,0,0) Sleepfor() mousedownreal("left") mouseupreal("left") sleepfor() Send("^a") ;That means ctrl+a Sleepfor() Send("^a") Sleepfor() Send("^a") Sleepfor() Send($login) Sleepfor() mousemovereal(128,365,0,0,0) Sleepfor() mousedownreal("left") mouseupreal("left") Sleepfor() Send($password) mousemovereal(363,436,0,0,0) Sleepfor() mousedownreal("left") mouseupreal("left") Else starteve() logintoeve() EndIf EndFunc Func starteve () If WinExists("EVE") Then WinActivate("EVE","") WinWaitActive("EVE","") sleep(2124) Else Run("C:\Program\CCP\EVE\eve.exe") Sleep (15124) EndIf EndFunc Func character () WinActivate("EVE") Do $srch = PixelSearch( 60, 708, 60, 708, 16777215) Until Not @error And $srch[0] == 60 And $srch[1] == 708 sleepforlong() mousemovereal(350,302,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") Do $srch = PixelSearch( 297, 360, 297, 360, 000000) Until Not @error And $srch[0] == 297 And $srch[1] == 360 Do $srch = PixelSearch( 297, 360, 297, 360, 000000) Until @error Sleepforlong() EndFunc Func instation() If $rat = 1 Then MsgBox(0,"MESSAGE","TIME TO KICK SOME PIRATE BUTS") EndIf If $mine = 1 Then MsgBox(0,"MESSAGE","TIME TO MINE SOME MINS") EndIf If $icemine = 1 Then MsgBox(0,"MESSAGE","ICE ICE BABY LET MINE") EndIf EndFunc Func inspace() If $ratpos = 1 Then MsgBox(0,"MESSAGE","TIME TO KICK SOME PIRATE BUTS") EndIf If $minepos = 1 Then MsgBox(0,"MESSAGE","TIME TO MINE SOME MINS") EndIf If $iceminepos = 1 Then MsgBox(0,"MESSAGE","ICE ICE BABY LET MINE") EndIf EndFunc Func where() $pix = PixelGetColor(191,345) If $pix=15724527 Then logintoeve() EndIf $pix = PixelGetColor(60,708) If $pix=16777215 Then character() EndIf $pix = PixelGetColor(13,769) If $pix=16765762 Then instation() EndIf $pix = PixelGetColor(817,70) If $pix=15132390 Then inspace() EndIf EndFunc Func checkitems() $pix = PixelGetColor(238,443) If $pix=16777215 Then ;nothing Else WinActivate("EVE","") WinWaitActive("EVE","") mousemovereal(20,689,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") EndIf EndFunc Func checkcargohold() $pix = PixelGetColor(238,623) If $pix=16777215 Then ;nothing Else WinActivate("EVE","") WinWaitActive("EVE","") mousemovereal(390,708,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") mousedownreal("left") mouseupreal("left") EndIf EndFunc Func checkpp() $pix = PixelGetColor(302,35) If $pix=16777215 Then ;nothing Else WinActivate("EVE","") WinWaitActive("EVE","") mousemovereal(22,195,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") EndIf EndFunc Func unloadcargo() mousemovereal(84,714,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") sleepfor() mousedownreal("right") mouseupreal("right") sleepfor() mousemovereal(132,782,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") sleepfor() mousemovereal(91,714,0,0,0) sleepfor() mousedownreal("right") mouseupreal("right") sleepfor() mousemovereal(129,743,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") sleepfor() mousemovereal(86,721,0,0,0) sleepfor() mousedownreal("left") sleepfor() mousemovereal(82,544,0,0,0) sleepfor() mouseupreal("left") EndFunc Func sleepfor() Sleep(Random(200,500)) EndFunc Func sleepforlong() Sleep(Random(500,1500)) EndFunc Func loadammo() mousemovereal(85,536,0,0,0) sleepfor() mousedownreal("left") mouseupreal("left") Sleepfor() mousemovereal(81,534,0,0,0) Sleepfor() mousedownreal("left") Sleepfor() mousemovereal(104,709,0,0,0) Sleepfor() mouseupreal("left") mousemovereal(490,433,0,0,0) sleepforlong() mousedownreal("left") mouseupreal("left") EndFunc Func undock() WinActivate("EVE") MouseMove(21,768) sleepfor() MouseDown("left") MouseUp("left") Do $srch = PixelSearch( 297, 360, 297, 360, 000000) Until Not @error And $srch[0] == 297 And $srch[1] == 360 Do $srch = PixelSearch( 297, 360, 297, 360, 000000) Until @error Sleepforlong() EndFunc Func detection() MsgBox(0,"MESSAGE","VALUE CHANGE DETECTED") EndFuncAlso I would like to say that I dont assume that someone should just do it for me or something like that, I just need experienced people to tell me if I am doing something wrong (probably I am ) and push me in the right direction instead. And maybe to help me with what I should do next. Maybe I got something wrong and is heading in the wrong direction, then I would like some new directions before i go to far Million thanks to anyone that could give me a hand in this. Link to comment Share on other sites More sharing options...
Generator Posted August 10, 2007 Share Posted August 10, 2007 For the state of checkbox, you can add if a checkbox is checked then a boolean is set to true of false. I am not familiar with MsgLoop mode so i cannot provide information on checking if the checkbox is checked. Not to create many Marcos? Put your marco in a functions, if checkbox is checked and some other checkbox is checked perform these two functions, otherwise perform one. You get the idea. Link to comment Share on other sites More sharing options...
Sniperwolf Posted August 10, 2007 Author Share Posted August 10, 2007 For the state of checkbox, you can add if a checkbox is checked then a boolean is set to true of false. I am not familiar with MsgLoop mode so i cannot provide information on checking if the checkbox is checked. Not to create many Marcos? Put your marco in a functions, if checkbox is checked and some other checkbox is checked perform these two functions, otherwise perform one. You get the idea. Well, I have already lost you mate . I dont understand all thoose words. If I should take in my language then I need the macro to see if the box is checked or not. If it is I need to get one value and if it isnt I should get another one, correct? Well how do I get that value on for example this box? $combatdrones = GUICtrlCreateCheckbox("Combatdrones", 288, 5, 90, 25) GUICtrlSetBkColor(-1, 0x716F64) If I write $combatdrones = GUICtrlCreateCheckbox("Combatdrones", 288, 5, 90, 25) GUICtrlSetBkColor(-1, 0x716F64) GUICtrlRead ($combatdrones) then I should get some sort of value right? It says in help file that using this on a checkbox will give me the state of the button. Then there is a state table where there are two lines like $GUI_UNCHECKED $GUI_CHECKED are theese the values I get? Then could I write like this? $combatdrones = GUICtrlCreateCheckbox("Combatdrones", 288, 5, 90, 25) GUICtrlSetBkColor(-1, 0x716F64) GUICtrlRead ($combatdrones) IF GUICtrlRead ($combatdrones)=$GUI_CHECKED Then ;and here the stuff I want it to do EndIF Or am I on the wrong track again. Link to comment Share on other sites More sharing options...
Generator Posted August 10, 2007 Share Posted August 10, 2007 Personally i suggest you change to OnEventMode because it's easier to manage and i can help you on it. This is an example code, which probably won't work, it will give you the idea, this is for OnEventMode Global $Checkbox=0 Func _CheckBox() $CheckBox=Not $CheckBox EndFunc Func _StartMarco() If $CheckBox Then Else EndIf EndFunc Link to comment Share on other sites More sharing options...
Sniperwolf Posted August 10, 2007 Author Share Posted August 10, 2007 Personally i suggest you change to OnEventMode because it's easier to manage and i can help you on it. This is an example code, which probably won't work, it will give you the idea, this is for OnEventMode Global $Checkbox=0 Func _CheckBox() $CheckBox=Not $CheckBox EndFunc Func _StartMarco() If $CheckBox Then Else EndIf EndFunc Thank you very much, it works great now. But do you know why I cant close the GUI when hitting the close button up in the right corner? And I was wondering if you knew where I should read up if I want a function that pauses the script when you move the mouse for example. Could be anoying if you cant stop it somehow So thought I add a button in the GUI that starts the macro again after it has been paused if this is possible. So if you know where I should read feel free to let me know... Link to comment Share on other sites More sharing options...
Generator Posted August 10, 2007 Share Posted August 10, 2007 MsgLoop: Case $Msg=$GUI_EVENT_CLOSE Exit OnEventMode: GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit") Func _Exit() Exit EndFunc 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