From f877ecf77c05f5f849bdfa495b104e09ef58562c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 24 Aug 2021 23:27:32 +0200 Subject: programs: Add Victoria 2 hotkeys and cursor clipping --- tt.programs.ahk | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tt.programs.ahk b/tt.programs.ahk index ee1df2f..0459825 100644 --- a/tt.programs.ahk +++ b/tt.programs.ahk @@ -164,4 +164,49 @@ return !d::SendInput, {LCtrl Down}l{LCtrl Up} +/* +#IfWinActive ahk_class Notepad2 + +F5:: + +return +*/ + +#If WinActive("ahk_exe v2game.exe") + +MButton::RButton +RButton::MButton + +;; -> library + +ClipCursor(Confines := True, Left := 100, Top := 200, Right := 800, Bottom := 900) +{ + if !(Confines) + return DllCall("user32.dll\ClipCursor") + static RECT, init := VarSetCapacity(RECT, 16, 0) + NumPut(Left, RECT, 0, "Int"), NumPut(Top, RECT, 4, "Int"), NumPut(Right, RECT, 8, "Int"), NumPut(Bottom, RECT, 12, "Int") + if !(DllCall("user32.dll\ClipCursor", "Ptr", &RECT)) + return DllCall("kernel32.dll\GetLastError") + return 1 +} + +VictoriaWindowMessage(wParam, lParam) +{ + if (wParam = 4 or wParam = 32772) ; HSHELL_WINDOW_ACTIVATED | HSHELL_RUDEAPPACTIVATED + { + WinGet, exe, ProcessName, A + if (exe = "v2game.exe") + { + Sleep, 1500 + ClipCursor(True, 6, 6, A_ScreenWidth-5, A_ScreenHeight-5) + } + } +} + +;; -> init + +WindowMessageHandlers.Push("VictoriaWindowMessage") + +;; -> body + #IfWinActive -- cgit v1.2.3