KawaiiXXKendra Posted January 26, 2010 Share Posted January 26, 2010 okay working on something here's my code (its still in setup phase) expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> ;initialization crap Opt("MouseCoordMode", 0) ;DO NOT CHANGE!!!! will break _MouseClickPlus() $ini = "countrylife.ini" Dim $go = 0 $pause = 0 $resetting = 0 $farm = 0 Dim $plot = 0 dim $cow = 0 dim $cheese_maker = 0 ;below commented out for testing of INI writing ;$setup_done = IniRead($ini, "Setup_Done", "0_1", "Not found") ;if $setup_done = 0 then _Setup() ;HotKeySet("{F1}", "StartMine") ;HotKeySet("{F2}", "SetPause") ;HotKeySet("{F3}", "StopMine") ;HotKeySet("{F4}", "ResetMine") ;====================================================================== ;reads into an array each section from the ini file (preps the array) Global $plot_array = IniReadSection($ini, "plots") Global $cow_array = IniReadSection($ini, "coww") Global $cheese_array = IniReadSection($ini, "cheese_maker") ;====================================================================== ;====================================================================== ;.ini reading $plot = IniRead($ini, "setup", "plots", "0") $plot_done = IniRead($ini, "setup", "plots", "0") ;Global $plot_array[$plot] $cow = IniRead($ini, "setup", "cow", "0") $cow_feed = IniRead($ini, "setup", "cow_feed", "0") $cow_done = IniRead($ini, "setup", "cow_done", "0") ;Global $cow_array[$cow] $cheese_maker = IniRead($ini, "setup", "cheese_maker", "0") $cheese_maker_feed = IniRead($ini, "setup", "cheese_maker_feed", "0") ;Global $cheeze_array[$cheese_maker] $cheese_maker_done = IniRead($ini, "setup", "cheese_maker_done", "0") ;end .ini reading ;====================================================================== ;====================================================================== ;debug section $debug_mode = IniRead($ini,"debug","debug_mode","not found") $debug_mode = 0 ;0 won't show 1 will show dialog's verifying locations and other debugging information ;====================================================================== ;make program create and read in positions from .ini file (make dynamic so it changes as the amount of plots ect... changes ;program flow Main_Execution() ;main execution of the program ;end program flow ;ini creation for setup func Main_Execution() WinWaitActive("Country Life on Facebook") Setup() ;setup functions/routines Prep_Work() ;ini file reads, doublechecks for proper information and that variables have obtained correct data. Prepare_Screen() ;zooms out screen Check_Plots() ;checks plots to see if they are ready to harvest Harvest_Plots() ;harvests plots Check_Cows() ;checks cows for harvest Harvest_Cows() ;harvests cows Check_Cheese() ;checks cheese for harvest Harvest_Cheese() ;harvests cheese EndFunc Func Setup() MouseClick("left", 974, 731) Sleep(500) MouseClick("left", 974, 731) Sleep(500) MouseClick("left", 974, 731) Sleep(500) MouseClick("left", 974, 731) Sleep(500) if $plot = 0 then $plot= InputBox("Crop Amount", "How many crop plots do you have?.", "", " M3") INIWrite($ini, "setup", "plot", $plot) EndIf if $cow = 0 then $cow = InputBox("Cow Amount", "How many cows do you have?.", "", " M3") $cow_feed = $cow INIWrite($ini, "setup", "cow", $cow) IniWrite($ini, "setup", "cow_feed", $cow) EndIf if $cheese_maker = 0 then $cheese_maker = InputBox("Cheese Makers", "How many cheese makers do you have?.", "", " M3") $cheese_maker_feed = $cheese_maker INIWrite($ini, "setup", "cheese_maker", $cheese_maker) IniWrite($ini, "setup", "cheese_maker_feed", $cheese_maker) EndIf if $plot_done = 0 Then Plot_Setup() EndIf if $cow_done = 0 Then Cow_Setup() EndIf if $cheese_maker_done = 0 Then Cheese_Maker_Setup() EndIf EndFunc ;plot setup Func Plot_Setup() $current = 0 while $current <= $plot ;plot location setup Global $spot1 = 0;reset position indicator HotKeySet("{ENTER}", "getSpot1");set ENTER hotkey While $spot1 = 0;does the loop while the coordinates have not been set ToolTip("Move mouse to plot location and press ENTER. Continue till all plots have been clicked!!!!") Sleep(50) WEnd ToolTip("");remove the tooltip HotKeySet("{ENTER}");turn off the hotkey If $debug_mode = 1 Then MsgBox("", "Spot 1", 'X:'&$spot1[0]&' Y:'&$spot1[1]) EndIf IniWrite($ini,"plotsX",$current,$spot1[0]) IniWrite($ini,"plotsY",$current,$spot1[1]) if $current = $plot Then ToolTip("All plot locations recorded!!!") IniWrite($ini,"setup","plot_done", "1") $plot_done = 1 Sleep(5000) Else $current = $current + 1 EndIf WEnd EndFunc Func Cow_Setup() $current =0 while $current <= $cow ;cow location setup Global $spot1 = 0;reset position indicator HotKeySet("{ENTER}", "getSpot1");set ENTER hotkey While $spot1 = 0;does the loop while the coordinates have not been set ToolTip("Move mouse to the location of a cow and press ENTER.") Sleep(50) WEnd ToolTip("");remove the tooltip HotKeySet("{ENTER}");turn off the hotkey if $debug_mode = 1 Then MsgBox("", "Spot 1", 'X:'&$spot1[0]&' Y:'&$spot1[1]) EndIf IniWrite($ini,"cowX",$current,$spot1[0]) IniWrite($ini,"cowY",$current,$spot1[1]) while $current <= $cow_feed ;cow location setup Global $spot1 = 0;reset position indicator HotKeySet("{ENTER}", "getSpot1");set ENTER hotkey While $spot1 = 0;does the loop while the coordinates have not been set ToolTip("Move mouse to the location of where you feed the cow and press ENTER.") Sleep(50) WEnd ToolTip("");remove the tooltip HotKeySet("{ENTER}");turn off the hotkey if $debug_mode = 1 Then MsgBox("", "Spot 1", 'X:'&$spot1[0]&' Y:'&$spot1[1]) EndIf IniWrite($ini,"cow_feedX",$current,$spot1[0]) IniWrite($ini,"cow_feedY",$current,$spot1[1]) if $current = $cow_feed Then ToolTip("All cow feed locations recorded!!!") Sleep(5000) EndIf WEnd If $current = $cow Then ToolTip("All cow locations recorded!!!") IniWrite($ini,"setup","cow_done", "1") Sleep(5000) $cow_done=1 Else $current = $current + 1 EndIf WEnd EndFunc Func Cheese_Maker_Setup() $current =0 While $current <= $cheese_maker ;cheese maker location setup Global $spot1 = 0;reset position indicator HotKeySet("{ENTER}", "getSpot1");set ENTER hotkey While $spot1 = 0;does the loop while the coordinates have not been set ToolTip("Move mouse to the location of a cheese maker and press ENTER.") Sleep(50) WEnd ToolTip("");remove the tooltip HotKeySet("{ENTER}");turn off the hotkey if $debug_mode = 1 Then MsgBox("", "Spot 1", 'X:'&$spot1[0]&' Y:'&$spot1[1]) EndIf IniWrite($ini,"cheese_makerX",$current,$spot1[0]) IniWrite($ini,"cheese_makerY",$current,$spot1[1]) while $current <= $cheese_maker_feed ;cheese maker feed location setup Global $spot1 = 0;reset position indicator HotKeySet("{ENTER}", "getSpot1");set ENTER hotkey While $spot1 = 0;does the loop while the coordinates have not been set ToolTip("Move mouse to the location of where you feed the cheese maker and press ENTER.") Sleep(50) WEnd ToolTip("");remove the tooltip HotKeySet("{ENTER}");turn off the hotkey if $debug_mode = 1 Then MsgBox("", "Spot 1", 'X:'&$spot1[0]&' Y:'&$spot1[1]) EndIf IniWrite($ini,"cheese_maker_feedX",$current,$spot1[0]) IniWrite($ini,"cheese_maker_feedY",$current,$spot1[1]) if $current = $cheese_maker_feed Then ToolTip("All cheese maker feed locations recorded!!!") Sleep(5000) EndIf If $current = $cheese_maker Then ToolTip("All cheese maker locations recorded!!!") IniWrite($ini,"setup","cow_done", "1") Sleep(5000) $cheese_maker_done = 1 Else $current = $current + 1 EndIf WEnd WEnd EndFunc func Prep_Work() EndFunc func Prepare_Screen() EndFunc func Check_Plots() EndFunc func Harvest_Plots() EndFunc func Check_Cows() EndFunc func Harvest_Cows() EndFunc func Check_Cheese() EndFunc func Harvest_Cheese() EndFunc func Clean_Up() EndFunc func getSpot1();get mining spot 1 $spot1 = MouseGetPos() EndFunc ;Tray Control Functions (start/stop/pause bot operations) Func StartMine() $go = 1 $pause = 0 $farm = 1 ;MsgBox("", "Current Stats", '$go:'&$go&' Pause:'&$pause) EndFunc Func End() Exit EndFunc func SetPause() $pause = 1 $farm = 0 EndFunc func PauseMine() sleep (10) EndFunc func StopMine() $farm = 0 EndFunc Func ExitScript() Exit EndFunc Func _MouseClick($hWnd, $button, $x, $y, $times = 1, $delay = 0) Local $ret, $ix $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y)) If $ret[0] = 0 Then SetError(-1) Return EndIf $button = StringLower($button) If $button = "left" Then For $ix = 1 To $times $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", _MakeLong($x, $y)) If $ret[0] = 0 Then SetError(-2) Return Else $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y)) If $ret[0] = 0 Then SetError(-3) Return EndIf EndIf Sleep($delay) Next ElseIf $button = "right" Then For $ix = 1 To $times $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", _MakeLong($x, $y)) If $ret[0] = 0 Then SetError(-4) Return Else $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", _MakeLong($x, $y)) If $ret[0] = 0 Then SetError(-5) Return EndIf EndIf Sleep($delay) Next Else SetError(-6) Return EndIf EndFunc Func _MakeLong($LoWord, $HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc ;==>_MakeLong now its looping thru the Setup_Plot() function and its not going to the Setup_Cow() function its seeing that its reached the pre-set (thru dialog box) amount of locations, but not leaving the function..... (I apologize if this is a noob question but I can't see why it won't leave the function and just keeps looping) 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