Advertisement
NJ5SkwAg

Fish clicking with troubleshooting

Sep 28th, 2015
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SetControlDelay -1
  2. #InstallKeybdHook
  3. CoordMode Pixel, Screen
  4.  
  5. ; fish area needs to be visible (that is to say not minimized or covered by another window) but not necessarily selected or active (it can be)
  6. ; be very careful that the Fish_File_Name matches and that it's in the same folder as the script
  7. ; make sure that when you take the screenshot you're in low quality mode
  8.  
  9. Fish_File_Name := "UniqueSnippetOfTheFishInLowQualityMode.png"
  10.  
  11. f9:: ; press f9 with your game selected for the script to know where to look
  12. WinGet, actWin, ID, A
  13. loop {
  14.     WinGetPos X_Offset, Y_Offset, Width, Height, ahk_id %actWin%
  15.     ImageSearch X, Y, X_Offset, Y_Offset, Width + X_Offset, Height + Y_Offset, *30 %Fish_File_Name%
  16.     if ErrorLevel = 0
  17.         ControlClick % "x" X - X_Offset " y" Y - Y_Offset, ahk_id %actWin%,,,, NA
  18.     sleep 10000
  19. }
  20. f10:: reload ; f10 to stop
  21.  
  22.  
  23. ; for troubleshooting purposes:
  24.  
  25. f8:: ; press f8 with your game selected to test if it can find the fish without clicking on it
  26. WinGet, actWin, ID, A
  27. WinGetPos X_Offset, Y_Offset, Width, Height, ahk_id %actWin%
  28. ImageSearch X, Y, X_Offset, Y_Offset, Width + X_Offset, Height + Y_Offset, *30 %Fish_File_Name%
  29. if ErrorLevel = 0
  30. {
  31.     MouseMove X - X_Offset, Y - Y_Offset, 0
  32.     MsgBox Fish Found
  33. }
  34. else
  35.     MsgBox X:%X% Y:%Y% ErrorLevel:%ErrorLevel% actWin:%actWin% X_Offset:%X_Offset% Y_Offset:%Y_Offset%
  36. return
  37.  
  38. ; if ErrorLevel is 1 when there's a fish on screen it means it was too different from the screenshot
  39. ; if ErrorLevel is 2 it means it couldn't find the screenshot file
  40. ; if ErrorLevel is 0 and it's moused over something other then the fish it means the allowed variation (*30 by default) is too high and/or the dimensions of the screenshot are too small
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement