-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nam Nguyen
committed
Sep 3, 2021
0 parents
commit fcd8b53
Showing
6 changed files
with
412 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
temp** | ||
*.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
$inputPath = './input.ini' | ||
|
||
$bagCloseButtonColorRed = dec('C33222') | ||
$bagCloseButtonColorWhite = dec('FFFFFF') | ||
|
||
$screenscale = @DesktopWidth/1920 | ||
|
||
$buttonUseRodX = $screenscale * 1532 | ||
$buttonUseRodY = $screenscale * 653 | ||
|
||
$buttonWithdrawRodX = $screenscale * 1670 | ||
$buttonWithdrawRodY = $screenscale * 850 | ||
|
||
$buttonOpenBagX = $screenscale * 1818 | ||
$buttonOpenBagY = $screenscale * 553 | ||
$buttonOpenBagColor = dec('E44142') | ||
|
||
$buttonStoreFishX = $screenscale * 1267 | ||
$buttonStoreFishY = $screenscale * 853 | ||
$buttonStoreFishColor = dec('41C5F3') | ||
|
||
$buttonStoreTrashX = $screenscale * 1546 | ||
$buttonStoreTrashY = $screenscale * 894 | ||
$buttonStoreTrashColor = dec('41C5F3') | ||
|
||
$bagOpenedX = $screenscale * 1317 | ||
$bagOpenedY = $screenscale * 549 | ||
$bagOpenedColor = dec('E85D3C') | ||
|
||
$buttonCloseBag1X = $screenscale * 1838 | ||
$buttonCloseBag1Y = $screenscale * 91 | ||
$buttonCloseBag1Color = dec('FFFFFF') | ||
|
||
$buttonCloseBag2X = $screenscale * 1859 | ||
$buttonCloseBag2Y = $screenscale * 109 | ||
$buttonCloseBag2Color = dec('C33222') | ||
|
||
$buttonCloseBag3X = $screenscale * 245 | ||
$buttonCloseBag3Y = $screenscale * 158 | ||
|
||
$buttonTabTool1X = $screenscale * 1367 | ||
$buttonTabTool1Y = $screenscale * 120 | ||
$buttonTabTool1Color = dec('F46644') | ||
|
||
$buttonTabTool2X = $screenscale * 1385 | ||
$buttonTabTool2Y = $screenscale * 117 | ||
$buttonTabTool2Color = dec('FFB3A2') | ||
|
||
$buttonTabTool3X = $screenscale * 1407 | ||
$buttonTabTool3Y = $screenscale * 134 | ||
$buttonTabTool3Color = dec('FFFFFF') | ||
|
||
global $rodCheckMarkX = [1086, 1377, 1672, 1086, 1377, 1672] | ||
global $rodCheckMarkY = [326, 326, 326, 705, 705, 705] | ||
$rodCheckMarkColor = dec('82FB28') | ||
|
||
global $bagItemX = [1163, 1456, 1757, 1163, 1456, 1757] | ||
global $bagItemY = [382, 382, 382, 764, 764, 764] | ||
|
||
global $buttonFixRodX = [1162, 1461, 1755, 1162, 1456, 1755] | ||
global $buttonFixRodY = [525, 525, 525, 903, 903, 903] | ||
$buttonFixRodColor = dec('F15E4E') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
AutoItSetOption('GUIOnEventMode', 1) | ||
|
||
local const $title="randomtitleabcxyzakdsjhfdfailgherw9ioutnbroi" | ||
|
||
SplashTextOn($title, 'aaa',"350","35","0","0",37,"","","") | ||
|
||
func _log($msg) | ||
ControlSetText($title, '', 'Static1', $msg) | ||
$currentmsg = $msg | ||
EndFunc | ||
|
||
func clickClose() | ||
Exit | ||
EndFunc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <ButtonConstants.au3> | ||
#include <GUIConstantsEx.au3> | ||
#include <StaticConstants.au3> | ||
#include <WindowsConstants.au3> | ||
#include <WinAPIMisc.au3> | ||
|
||
#include <const.au3> | ||
|
||
AutoItSetOption('GUIOnEventMode', 1) | ||
|
||
local $X1 = 0 | ||
local $Y1 = 0 | ||
local $X2 = 0 | ||
local $Y2 = 0 | ||
local $labelUpdated = false | ||
local $isdone = false | ||
local $isexit = false | ||
|
||
func genLabel() | ||
return 'Current position:' & @CRLF & _ | ||
'X = ' & $X1 & @CRLF & _ | ||
'Y = ' & $Y1 & @CRLF & _ | ||
@CRLF & _ | ||
"Press F2 to capture current position:" & @CRLF & _ | ||
"X = " & $X2 & @CRLF & _ | ||
"Y = " & $Y2 | ||
endfunc | ||
|
||
func Capture() | ||
$X2 = $X1 | ||
$Y2 = $Y1 | ||
$labelUpdated = true | ||
EndFunc | ||
|
||
Func _Cancel() | ||
$isexit = true | ||
EndFunc | ||
|
||
Func _Generate() | ||
IniWrite($inputPath, "Exclaimation Mark", "exclaimationX", $X2) | ||
IniWrite($inputPath, "Exclaimation Mark", "exclaimationY", $Y2) | ||
IniWrite($inputPath, "General", "RodPosition", 1) | ||
$isdone = true | ||
EndFunc | ||
|
||
func generateInput() | ||
local const $Form1 = GUICreate("Capture ! position", 280, 208) | ||
local const $Label1 = GUICtrlCreateLabel(genLabel(), 12, 12, 255, 150) | ||
GUICtrlSetFont($Label1, 12) | ||
GUISetOnEvent($GUI_EVENT_CLOSE, "_Cancel", $Form1) | ||
|
||
|
||
local const $ButtonGenerate = GUICtrlCreateButton("Generate", 48, 168, 75, 25) | ||
local const $ButtonCancel = GUICtrlCreateButton("Cancel", 144, 168, 75, 25) | ||
GUICtrlSetOnEvent($ButtonGenerate, '_Generate') | ||
GUICtrlSetOnEvent($ButtonCancel, '_Cancel') | ||
HotKeySet("{F2}", "Capture") | ||
|
||
GUISetState(@SW_SHOW) | ||
|
||
While not $isdone and not $isexit | ||
$mousepos = _WinAPI_GetMousePos() | ||
$X1_new = DllStructGetData($mousepos, "X") | ||
$Y1_new = DllStructGetData($mousepos, "Y") | ||
if $X1_new <> $X1 or $Y1_new <> $Y1 then | ||
$X1 = $X1_new | ||
$Y1 = $Y1_new | ||
$labelUpdated = true | ||
endif | ||
if $labelUpdated then | ||
GUICtrlSetData($Label1, genLabel()) | ||
$labelUpdated = false | ||
endif | ||
$nMsg = GUIGetMsg() | ||
Switch $nMsg | ||
Case $GUI_EVENT_CLOSE | ||
isexit = true | ||
|
||
EndSwitch | ||
;~ GUICtrlSetData($Label1, 'a') | ||
WEnd | ||
GUIDelete($Form1) | ||
if $isexit then exit | ||
EndFunc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#include <AutoItConstants.au3> | ||
;~ #include <WinAPIGdi.au3> | ||
;~ #include <WinAPIGdiDC.au3> | ||
;~ #include <WinAPIHObj.au3> | ||
;~ #include <WinAPISysWin.au3> | ||
;~ #include <WindowsConstants.au3> | ||
|
||
#include <const.au3> | ||
#include <generateInput.au3> | ||
|
||
global $exclaimationX | ||
global $exclaimationY | ||
global $rodPosition | ||
|
||
func getInput() | ||
_log('Reading exclaimation position') | ||
if FileExists($inputPath) then | ||
$exclaimationX = IniRead($inputPath, "Exclaimation Mark", "exclaimationX", "") | ||
$exclaimationY = IniRead($inputPath, "Exclaimation Mark", "exclaimationY", "") | ||
$rodPosition = IniRead($inputPath, "General", "RodPosition", 1) | ||
else | ||
_log('Capturing exclaimation position') | ||
generateInput() | ||
getInput() | ||
endif | ||
endfunc | ||
|
||
func getCurrentExclaimationColor() | ||
return PixelGetColor($exclaimationX, $exclaimationY) | ||
EndFunc | ||
|
||
func alert($msg) | ||
MsgBox($MB_SYSTEMMODAL, "Alert", $msg) | ||
EndFunc | ||
|
||
;~ $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) | ||
;~ $hPen = _WinAPI_CreatePen($PS_SOLID, 5, 0) | ||
;~ $o_Orig = _WinAPI_SelectObject($hDC, $hPen) | ||
|
||
func drawCross() | ||
$length=30 | ||
_WinAPI_DrawLine($hDC, $exclaimationX - $length/2, $exclaimationY, $exclaimationX + $length/2, $exclaimationY) | ||
_WinAPI_DrawLine($hDC, $exclaimationX, $exclaimationY - $length/2, $exclaimationX, $exclaimationY + $length/2) | ||
_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0) | ||
_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_ERASE) | ||
_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) | ||
|
||
EndFunc | ||
|
||
#region Button clicking | ||
func click($x, $y, $clicks = 1, $speed = 100, $clickspeed = 2) | ||
MouseClick ($MOUSE_CLICK_LEFT, $x, $y, $clicks, $clickspeed) | ||
sleep($speed) | ||
EndFunc | ||
|
||
func clickUseRod() | ||
click($buttonUseRodX, $buttonUseRodY, 1, 200) | ||
EndFunc | ||
|
||
func clickWithdrawRod() | ||
click($buttonWithdrawRodX, $buttonWithdrawRodY, 10, 10, 0) | ||
EndFunc | ||
|
||
func clickOpenBag() | ||
click($buttonOpenBagX, $buttonOpenBagY, 1, 0) ;100 trở lên thì sleep vô tận cmnl, wtf? | ||
EndFunc | ||
|
||
func clickTabTool() | ||
click($buttonTabTool1X, $buttonTabTool1Y, 1, 200) | ||
EndFunc | ||
|
||
func clickCloseBag() | ||
click($buttonCloseBag3X, $buttonCloseBag3Y, 1, 200) | ||
EndFunc | ||
|
||
func clickStoreFish() | ||
click($buttonStoreFishX, $buttonStoreFishY, 1, 200) | ||
EndFunc | ||
|
||
func clickStoreTrash() | ||
click($buttonStoreTrashX, $buttonStoreTrashY, 1, 200) | ||
EndFunc | ||
|
||
func clickSelectRod() | ||
click($bagItemX[$rodPosition - 1] * $screenscale, $bagItemY[$rodPosition - 1] * $screenscale, 1, 200) | ||
EndFunc | ||
#endregion | ||
|
||
#region Detecting | ||
func isOpenBagButtonShown() | ||
return PixelGetColor($buttonOpenBagX, $buttonOpenBagY) == $buttonOpenBagColor | ||
EndFunc | ||
|
||
func isBagOpened() | ||
return not isOpenBagButtonShown() _ | ||
And isCloseBagButtonShown() _ | ||
And PixelGetColor($bagOpenedX, $bagOpenedY) == $bagOpenedColor | ||
EndFunc | ||
|
||
func isTabToolNotSelected() | ||
return isBagOpened() _ | ||
And PixelGetColor($buttonTabTool1X, $buttonTabTool1Y) == $buttonTabTool1Color _ | ||
And PixelGetColor($buttonTabTool2X, $buttonTabTool2Y) == $buttonTabTool2Color _ | ||
And PixelGetColor($buttonTabTool3X, $buttonTabTool3Y) <> $buttonTabTool3Color | ||
EndFunc | ||
|
||
func isCloseBagButtonShown() | ||
return PixelGetColor($buttonCloseBag1X, $buttonCloseBag1Y) == $buttonCloseBag1Color _ | ||
And PixelGetColor($buttonCloseBag2X, $buttonCloseBag2Y) == $buttonCloseBag2Color | ||
EndFunc | ||
|
||
func isStoreFishButtonShown() | ||
return PixelGetColor($buttonStoreFishX, $buttonStoreFishY) == $buttonStoreFishColor | ||
EndFunc | ||
|
||
func isStoreTrashButtonShown() | ||
return PixelGetColor($buttonStoreTrashX, $buttonStoreTrashY) == $buttonStoreTrashColor | ||
EndFunc | ||
|
||
func rodCheckMarkExits() | ||
return PixelGetColor($rodCheckMarkX[$rodPosition - 1] * $screenscale, $rodCheckMarkY[$rodPosition - 1] * $screenscale) == $rodCheckMarkColor | ||
endfunc | ||
#endregion | ||
|
||
#region complex select | ||
func doBagStuff() | ||
while isTabToolNotSelected() | ||
clickTabTool() | ||
wend | ||
|
||
while isBagOpened() and not isOpenBagButtonShown() | ||
if rodCheckMarkExits() then | ||
clickCloseBag() | ||
Else | ||
clickSelectRod() | ||
endif | ||
wend | ||
Sleep(200) | ||
endfunc | ||
|
||
#endregion |
Oops, something went wrong.