Jump to content

New function every 10 minutes while looping the previous function


Recommended Posts

hi guys im trying to get this for days now! dont flame me on this i searched lots of tutorials for this

the original script is this

########### 
; Globals 
;########### 
$title = "Fisherman's Friend" 
$win_title = "World of Warcraft" 

; Sets up the Borders to fish in 
$top_border_height = 23 
$left_border_width = 4 

; Sets up the Screen resolution $ make shure its in windowed mode 
$screen_width = 800 
$screen_height = 600 

; Just a simple Timer 
$time_to_wait = 30000 
dim $start_time 


;######################################################################### 
;                  Hot Keys Section 
; 
; Set up a Hot key to be used later to end the script 
;######################################################################### 

HotKeySet("{PAUSE}", "request_end") 



;######################################################################### 
;                    Fish Bot View Paremeters 
; 
;  Sets up the boundaries of the fishbot on the screen and returns 
;  some visual confirmation by moving the mouse in a square showing 
;  where the bot will be searching for the fishing bobber 
;######################################################################### 

if not WinExists($win_title, "") then 
    msg($win_title & " window must be open.") 
    Exit 
endif 

WinActivate($win_title, "") 
WinSetOnTop($win_title, "", 0) 
Sleep(500) 

check_window() 

$win_pos = WinGetPos($win_title, "") 
$win_x = $win_pos[0] + $left_border_width 
$win_y = $win_pos[1] + $top_border_height 

$top = $win_y + (.25 * $screen_height) 
$bottom = $top + (.35 * $screen_height) - 1 
$left = $win_x + (.15 * $screen_width) 
$right = $left + $screen_width - (.15 * 2.0 * $screen_width) - 1 

Start_Bot() 


;########################### 
; Visual confirmation 
; Area scanned for bobber 
;########################### 

MouseMove($left, $top, 2) 
MouseMove($right, $top, 2) 
MouseMove($right, $bottom, 2) 
MouseMove($left, $bottom, 2) 

cast_pole() 
find_float() 

;######################################################################### 
; 
;                      Function find_float 
; 
;  Once bobber has been cast the bobber needs to be found via colors 
;  The most prominent color is the red so by default that is enabled 
;  More colors have been defined and you may switch them if you want 
;  The only reason to switch them is when fishing in Stormwind or at 
;  night when colors are all very diffrent. 
;######################################################################### 

func find_float() 

  ;##################### 
  ; Color Definitions 
  ;##################### 

   $color_dark_purple = 0x463B4D 
   $color_dark_blue = 0x283A64 
   $color_red = 0xA72C0B 
   $color_stormwind_daylight_blue = 0x2B3254 
   $color_stormwind_daylight_red = 0x6B1F0C 
   $color_beige = 0xBB9B3D 
   $color_night_blue = 0x0B1931 
   $color_wc = 0x210B04 

  ;######################################################### 
  ; This is the color used to pixelsearch for the bobber. 
  ; Change the color to a good color 
  ; on the bobber that is prominent on the screen 
  ;######################################################### 

   $color_to_use =  $color_red
  ;################################################################## 
  ; This is the search tolerance. In areas where the bobber 
  ; colors really stand out, you can use a fairly high threshold. 
  ; In areas where the bobber colors are fairly muted in with 
  ; the background, you will have to lower the values considerably. 
  ;################################################################## 

   $bobber_search_tolerance = 20 

  ;######################################################################## 
  ; It's better to use lower values here in favor of accurate searching. 
  ; This will take more time for it to detect the bobber, but usually 
  ; the splash doesn't occur until at least 30% of the time has run out, 
  ; and by that time, it should have detected the bobber (assuming the 
  ; color values and tolerance are correct). 
  ;######################################################################## 

   $bobber_search_step = 2 

  ;######################################################################### 
  ; Search for float. In certain lighting, the part of the float may look 
  ; more purple than blue. In this case, using $color_red tends to work 
  ; the best with a tolerance of 20. 
  ;######################################################################### 

   while 1 
      if TimerDiff($start_time) >= $time_to_wait then 
         cast_pole() 
      endif 

      $pos = PixelSearch($left, $top, $right, $bottom, $color_to_use, $bobber_search_tolerance, $bobber_search_step) 
         if @error then 
            SetError(0) 
         else 
            MouseMove($pos[0], $pos[1], 2) 
            find_splash($pos[0], $pos[1] ) 
         endif 
         Sleep(10) 
      wend 
endfunc 

; ############################################################################ 
func find_splash($float_x, $float_y) 
    $search_left = $float_x - 32 
    $search_right = $search_left + 52 
    $search_top = $float_y - 32 
    $search_bottom = $search_top + 64 

   ; Usually you do not have to modify the search color for the splash, as the pixels 
   ; have a very distinctive, bright color. 
    $splash_color = 0xF6F6F6 

   ; Sometimes 30 tolerance works well, sometimes 20 is better in lit areas to avoid catching highlights 
   ; in other things. 
    $splash_tolerance = 20 

   ; The search step can be pretty small here (1 to 3) without worries because the search area is 
   ; so small once it has been narrowed down - speed isn't much of an issue. 
    $splash_search_step = 2 

   ; Search for splash 
    while TimerDiff($start_time) < $time_to_wait 
        $pos = PixelSearch($search_left, $search_top, $search_right, $search_bottom, $splash_color, $splash_tolerance, $splash_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the splash 
            send("{SHIFTDOWN}") 
            MouseClick("right");, $pos[0], $pos[1], 1, 2) 
            send("{ShiftUP}") 
            Sleep(5500) 

            ExitLoop 
        endif 
        Sleep(10) 
    wend 

   ; Cast pole and start all over again. 
    cast_pole() 
endfunc 

; ############################################################################## 
func cast_pole() 
    $start_time = TimerInit() 
    Send("1") 
    Sleep(1000) 
endfunc 

; ############################################################################## 
func check_window() 
    $dimensions = WinGetClientSize($win_title, "") 
    if $dimensions[0] <> $screen_width or $dimensions[1] <> $screen_height then 
        msg("Invalid window size. You must use " & $screen_width & "x" & $screen_height & " resolution in window mode.") 
        Exit 
    endif 
endfunc 

; ############################################################################## 
func msg($text) 
    MsgBox(0, $title, $text) 
endfunc 

; ############################################################################## 
func msg_array($title, $array, $num_elements) 
    dim $text 
    $text = $array[0] 

    for $j = 1 to $num_elements - 1 
        $text = $text & ", " & $array[$j] 
    next 

    MsgBox(0, $title, $text) 
endfunc 


; ########################################################## 
func request_end() 
    $MB_YESNO = 4 
    $MB_YES = 6 

    if MsgBox($MB_YESNO, $title, "End script?") == $MB_YES then 
        Exit 
    endif 
endfunc 

;########################################################### 
func Start_Bot() 
 $MB_YESNO = 4 
    $MB_YES = 6 

    if MsgBox($MB_YESNO, $title, "Do you want to start the Bot?") == $MB_Yes then 

    else 
       Exit 
    endif 
endfunc 

; ########################################################## 
func drain_timer() 
    Msg("Restart") 
    $start_time = $start_time - $time_to_wait 
endfunc 

;##########################################################

I want the script to add a lure to my fishing rod every 10 minutes. BUT the big but is that it should continue fishing....

i let the program work to fish that worked and also to let it put on a lure but it wont work alongside eachother =[

this is the code ive been trying to fix my problem with for days now

########### 
; Globals 
;########### 
$title = "Fisherman's Friend" 
$win_title = "World of Warcraft" 

; Sets up the Borders to fish in 
$top_border_height = 23 
$left_border_width = 4 

; Sets up the Screen resolution $ make shure its in windowed mode 
$screen_width = 800 
$screen_height = 600 

; Just a simple Timer 
$time_to_wait = 30000
; Cast lure Timer
$wait_for_lure = 605000
dim $start_time 


;######################################################################### 
;                  Hot Keys Section 
; 
; Set up a Hot key to be used later to end the script 
;######################################################################### 

HotKeySet("{PAUSE}", "request_end") 



;######################################################################### 
;                    Fish Bot View Paremeters 
; 
;  Sets up the boundaries of the fishbot on the screen and returns 
;  some visual confirmation by moving the mouse in a square showing 
;  where the bot will be searching for the fishing bobber 
;######################################################################### 

if not WinExists($win_title, "") then 
    msg($win_title & " window must be open.") 
    Exit 
endif 

WinActivate($win_title, "") 
WinSetOnTop($win_title, "", 0) 
Sleep(500) 

check_window() 

$win_pos = WinGetPos($win_title, "") 
$win_x = $win_pos[0] + $left_border_width 
$win_y = $win_pos[1] + $top_border_height 

$top = $win_y + (.25 * $screen_height) 
$bottom = $top + (.35 * $screen_height) - 1 
$left = $win_x + (.15 * $screen_width) 
$right = $left + $screen_width - (.15 * 2.0 * $screen_width) - 1 

Start_Bot() 


;########################### 
; Visual confirmation 
; Area scanned for bobber 
;########################### 

MouseMove($left, $top, 2) 
MouseMove($right, $top, 2) 
MouseMove($right, $bottom, 2) 
MouseMove($left, $bottom, 2) 

cast_pole() 
find_float() 


;######################################################################### 
; 
;                      Function find_float 
; 
;  Once bobber has been cast the bobber needs to be found via colors 
;  The most prominent color is the red so by default that is enabled 
;  More colors have been defined and you may switch them if you want 
;  The only reason to switch them is when fishing in Stormwind or at 
;  night when colors are all very diffrent. 
;######################################################################### 

func find_float() 

  ;##################### 
  ; Color Definitions 
  ;##################### 

   $color_dark_purple = 0x463B4D 
   $color_dark_blue = 0x283A64 
   $color_red = 0xA72C0B 
   $color_stormwind_daylight_blue = 0x2B3254 
   $color_stormwind_daylight_red = 0x6B1F0C 
   $color_beige = 0xBB9B3D 
   $color_night_blue = 0x0B1931 
   $color_wc = 0x210B04 

  ;######################################################### 
  ; This is the color used to pixelsearch for the bobber. 
  ; Change the color to a good color 
  ; on the bobber that is prominent on the screen 
  ;######################################################### 

   $color_to_use =  $color_red
  ;################################################################## 
  ; This is the search tolerance. In areas where the bobber 
  ; colors really stand out, you can use a fairly high threshold. 
  ; In areas where the bobber colors are fairly muted in with 
  ; the background, you will have to lower the values considerably. 
  ;################################################################## 

   $bobber_search_tolerance = 20 

  ;######################################################################## 
  ; It's better to use lower values here in favor of accurate searching. 
  ; This will take more time for it to detect the bobber, but usually 
  ; the splash doesn't occur until at least 30% of the time has run out, 
  ; and by that time, it should have detected the bobber (assuming the 
  ; color values and tolerance are correct). 
  ;######################################################################## 

   $bobber_search_step = 2 

  ;######################################################################### 
  ; Search for float. In certain lighting, the part of the float may look 
  ; more purple than blue. In this case, using $color_red tends to work 
  ; the best with a tolerance of 20. 
  ;######################################################################### 

   while 1 
      if TimerDiff($start_time) >= $time_to_wait then 
         cast_pole() 
         cast_lure()
      endif 

      $pos = PixelSearch($left, $top, $right, $bottom, $color_to_use, $bobber_search_tolerance, $bobber_search_step) 
         if @error then 
            SetError(0) 
         else 
            MouseMove($pos[0], $pos[1], 2) 
            find_splash($pos[0], $pos[1] ) 
         endif 
         Sleep(10) 
      wend 
endfunc 

; ############################################################################ 
func find_splash($float_x, $float_y) 
    $search_left = $float_x - 32 
    $search_right = $search_left + 52 
    $search_top = $float_y - 32 
    $search_bottom = $search_top + 64 

   ; Usually you do not have to modify the search color for the splash, as the pixels 
   ; have a very distinctive, bright color. 
    $splash_color = 0xF6F6F6 

   ; Sometimes 30 tolerance works well, sometimes 20 is better in lit areas to avoid catching highlights 
   ; in other things. 
    $splash_tolerance = 20 

   ; The search step can be pretty small here (1 to 3) without worries because the search area is 
   ; so small once it has been narrowed down - speed isn't much of an issue. 
    $splash_search_step = 2 

   ; Search for splash 
    while TimerDiff($start_time) < $time_to_wait 
        $pos = PixelSearch($search_left, $search_top, $search_right, $search_bottom, $splash_color, $splash_tolerance, $splash_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the splash 
            send("{SHIFTDOWN}") 
            MouseClick("right");, $pos[0], $pos[1], 1, 2) 
            send("{ShiftUP}") 
            Sleep(5500) 

            ExitLoop 
        endif 
        Sleep(10) 
    wend 
    
   ; Cast pole and start all over again. 
    cast_pole() 
endfunc 


    

; ############################################################################## 
func cast_pole() 
    $start_time = TimerInit() 
    Send("1") 
    Sleep(1000) 
endfunc 

; ############################################################################## 
func cast_lure() 
    $start_time = TimerInit() 
    Send("2") 
    Sleep(605000) 
    if TimerDiff($start_time) >= $wait_for_lure then 
         cast_lure() 
    EndIf
endfunc 

; ############################################################################## 
func check_window() 
    $dimensions = WinGetClientSize($win_title, "") 
    if $dimensions[0] <> $screen_width or $dimensions[1] <> $screen_height then 
        msg("Invalid window size. You must use " & $screen_width & "x" & $screen_height & " resolution in window mode.") 
        Exit 
    endif 
endfunc 

; ############################################################################## 
func msg($text) 
    MsgBox(0, $title, $text) 
endfunc 

; ############################################################################## 
func msg_array($title, $array, $num_elements) 
    dim $text 
    $text = $array[0] 

    for $j = 1 to $num_elements - 1 
        $text = $text & ", " & $array[$j] 
    next 

    MsgBox(0, $title, $text) 
endfunc 


; ########################################################## 
func request_end() 
    $MB_YESNO = 4 
    $MB_YES = 6 

    if MsgBox($MB_YESNO, $title, "End script?") == $MB_YES then 
        Exit 
    endif 
endfunc 

;########################################################### 
func Start_Bot() 
 $MB_YESNO = 4 
    $MB_YES = 6 

    if MsgBox($MB_YESNO, $title, "Do you want to start the Bot?") == $MB_Yes then 

    else 
       Exit 
    endif 
endfunc 

; ########################################################## 
func drain_timer() 
    Msg("Restart") 
    $start_time = $start_time - $time_to_wait 
endfunc 

;##########################################################

i really hope some1 can help me out on this...

thanks in advance =]

Link to comment
Share on other sites

i really hope some1 can help me out on this...

Help in what? :)

If you need to call some function every N seconds, check AdlibEnable() or TimerInit()/TimerDiff().

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

ok thanks guys for the replies =]

i tried to make a sentence that would press the "2" on my keyboard every 10 minutes and continue with pressing "1" and waiting and clicking in the code above

but it gives an error if i play the code the line i made with AdlibEnable isnt correct i guess

how do i suppose to make that line?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...