From 5f185a5b9bc3493f92e18555fe572c253293aea4 Mon Sep 17 00:00:00 2001 From: 3stadt <3stadt@users.noreply.github.com> Date: Fri, 15 Dec 2017 11:34:11 +0100 Subject: [PATCH] add second, smaller resolution --- AutoICBING.ahk | 73 +++++++++++++++++++++++++++++++++++++++++--------- README.md | 2 +- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/AutoICBING.ahk b/AutoICBING.ahk index d2dceaa..697b52f 100644 --- a/AutoICBING.ahk +++ b/AutoICBING.ahk @@ -40,7 +40,8 @@ GuiControlGet, RunCount ; First check if game is running and the right size WinGet, hwnd,,%GameWindowTitle% -if (GameIsAccessible(GameWindowTitle) == false) { +GameRes := GetGameRes(GameWindowTitle) +if (GameRes == 0) { return } @@ -70,13 +71,19 @@ if (BreakLoop = 1) { break } +GameRes := GetGameRes(GameWindowTitle) + ; Make sure the game wasn't closed since last loop -if (GameIsAccessible(GameWindowTitle) == false) { +if (GameRes == 0) { break } ; Open one box -OpenBox(hwnd, KeepHasPrio) +if(GameRes == 1) { + OpenBoxInLowRes(hwnd, KeepHasPrio) +} else { + OpenBoxInHiRes(hwnd, KeepHasPrio) +} ; Update the form Current-- @@ -100,27 +107,67 @@ GetClientSize(hwnd, ByRef cWidth, ByRef cHeight) cHeight := NumGet(rc, 12, "int") } -; Returns false if the game is not running or the wrong size, true otherwise +; Returns 0 if the game is not running or the wrong size, 1 if running in LowRes, 2 if running in HiRes ; Used to set BreakLoop variable -; will show a message box with error -GameIsAccessible(WinTitle) { +; Will show a message box on error +GetGameRes(WinTitle) { IfWinNotExist, %WinTitle% { MsgBox,,Error, Please start "I can't believe it's not gambling" first - return false + return 0 } WinGet, currentHwnd,,%WinTitle% GetClientSize(currentHwnd, cWidth, cHeight) - if (cWidth != 1600 || cHeight != 900) { - MsgBox,,Error, Your game is running at %w%x%h% - Please set resolution to 1600x900 - return false + if (cWidth == 1360 && cHeight == 768) { + return 1 } - return true + if (cWidth == 1600 && cHeight == 900) { + return 2 + } + MsgBox,,Error, Your game is running at %cWidth%x%cHeight%`nPlease set resolution to 1600x900 or 1360x768 + return 0 +} + +; Main work for 1360x768 +OpenBoxInLowRes(hwnd, KeepHasPrio) { + Click, 490 660 ; Click yellow "open loot box" button + Sleep 5700 ; Wait loot box to open + + ; Click all keep buttons first, then remaining sell buttons + if (KeepHasPrio = 1) { + Click, 1070 515 ; Keep loot, if possible + Sleep 400 ; Wait for the game to register the last click + + ; Same for the other three loot boxes: + + Click, 800 520 + Sleep 400 + + Click 500 515 + Sleep 400 + + Click 200 520 + Sleep 400 + } + + Click, 1070 545 ; Sell loot, if possible + Sleep 400 ; Wait for the game to register the last click + + ; Same for the other three loot boxes: + + Click, 800 555 + Sleep 400 + + Click, 505 550 + Sleep 400 + + Click, 180 555 + Sleep 400 } -; Main work -OpenBox(hwnd, KeepHasPrio) { +; Main work for 1600x900 +OpenBoxInHiRes(hwnd, KeepHasPrio) { Click, 570 780 ; Click yellow "open loot box" button Sleep 5700 ; Wait loot box to open diff --git a/README.md b/README.md index f007a6b..5c3e897 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Use the ahk script or download a compiled exe from [release page](https://github # How? - You either start the exe or the ahk script if autohotkey is installed -- You start the [game](http://store.steampowered.com/app/733990/I_Cant_Believe_Its_Not_Gambling/). Windowed, resolution set to 1600x900. +- You start the [game](http://store.steampowered.com/app/733990/I_Cant_Believe_Its_Not_Gambling/). Windowed, resolution set to either 1600x900 or 1360x768. - You set a number of boxes to open. - You press "Run" - You wait