From da6da78e34aae39c37315c09b3808fa2966f62f9 Mon Sep 17 00:00:00 2001 From: TheBestPessimist Date: Sun, 25 Dec 2022 16:23:04 +0200 Subject: [PATCH] Libdebug --- AutoHotkey64.ahk | 4 ++-- CapsLockToggle.ahk | 4 ++-- lib/Tippy.ahk | 19 ++++++++----------- lib/libdebug.ahk | 45 ++++++++++++++++++++------------------------- 4 files changed, 32 insertions(+), 40 deletions(-) diff --git a/AutoHotkey64.ahk b/AutoHotkey64.ahk index 4d79fe3..5c6d2e4 100644 --- a/AutoHotkey64.ahk +++ b/AutoHotkey64.ahk @@ -19,8 +19,8 @@ TraySetIcon("resources/blueStar.ico") ;; rest of everything -;#Include lib/Tippy.ahk -;#Include lib/libdebug.ahk +#Include lib/Tippy.ahk +#Include lib/libdebug.ahk #Include app_handling.ahk #Include lib/ReloadScript.ahk #Include CapsLockToggle.ahk diff --git a/CapsLockToggle.ahk b/CapsLockToggle.ahk index 2143e91..6600cb9 100644 --- a/CapsLockToggle.ahk +++ b/CapsLockToggle.ahk @@ -7,10 +7,10 @@ CapsLock & Alt:: { state := !state if state { SetCapsLockState("AlwaysOn") - Tippy("CapsLock is: ON", 99999999999999) + Tippy("CapsLock is: ON", 99999999999999, 15) } else { SetCapsLockState("AlwaysOff") - Tippy("CapsLock is: off") + Tippy("CapsLock is: off",, 15) } } diff --git a/lib/Tippy.ahk b/lib/Tippy.ahk index c4011d3..d646058 100644 --- a/lib/Tippy.ahk +++ b/lib/Tippy.ahk @@ -113,6 +113,8 @@ class TT { ttData.WhichToolTip := whichToolTip ttData.extraOffsetY := extraOffsetY ttData.Hwnd := "" + ttData.ToolTipHeight := 0 + ttData.YOffset := "" Sleep 2 } @@ -120,25 +122,21 @@ class TT { GetUnusedToolTip(text) { ; firstly go through all tooltips to check if this one is not already shown - For whichToolTip, ttData in this.ToolTipData - { - if(ttData.CurrentText == text) - { + For whichToolTip, ttData in this.ToolTipData { + if(ttData.CurrentText == text) { return whichToolTip } } ; if no tooltips with same text is shown, then return a new one whichToolTip := 2 - While (whichToolTip <= this.MaxWhichToolTip) - { - if(!this.ToolTipData[whichToolTip]) - { + While (whichToolTip <= this.MaxWhichToolTip) { + if(!this.ToolTipData.Has(whichToolTip)) { return whichToolTip } whichToolTip++ } - Return this.DefaultWhichToolTip + return this.DefaultWhichToolTip } @@ -311,8 +309,7 @@ class TT { static screens := 0 newMonitorCount := MonitorGetCount() - if (monitorCount != newMonitorCount) - { + if (monitorCount != newMonitorCount) { monitorCount := newMonitorCount screens := [] diff --git a/lib/libdebug.ahk b/lib/libdebug.ahk index 36d6972..e3ad6f5 100644 --- a/lib/libdebug.ahk +++ b/lib/libdebug.ahk @@ -3,23 +3,20 @@ ;------------------------------------------------ ; CapsLock + /: Toggle Mouse debugging mode -CapsLock & /::ToggleMouseDebugging() - -ToggleMouseDebugging() -{ - static toggle +CapsLock & /:: { + static toggle := 0 MouseDebugging() - SetTimer MouseDebugging, % (toggle := !toggle) ? 500 : "Off" + SetTimer(MouseDebugging, (toggle := !toggle) ? 500 : 0) } MouseDebugging() { - CoordMode, Mouse, Screen - MouseGetPos, x, y + CoordMode("Mouse", "Screen") + MouseGetPos(&X, &Y) Tippy("Mouse Pos: " x " x " y " (global)", , 19) - SysGet, virtualScreenWidth, 78 - SysGet, virtualScreenHeight, 79 - Tippy("Screen Size: " virtualScreenWidth " x " virtualScreenHeight,, 18) + VirtualScreenWidth := SysGet(78) + VirtualScreenHeight := SysGet(79) + Tippy("Screen Size: " VirtualScreenWidth " x " VirtualScreenHeight,, 18) localPos := GetLocalMonitorMouseCoords() Tippy("Mouse Pos: " localPos.x " x " localPos.y " (local)",, 20) @@ -27,34 +24,32 @@ MouseDebugging() { } GetAllMonitorsDimensions() { - static monitorCount - static monitors + static monitorCount := 0 + static screens := 0 - SysGet, newMonitorCount, MonitorCount - if (monitorCount != newMonitorCount) - { + newMonitorCount := MonitorGetCount() + if (monitorCount != newMonitorCount) { monitorCount := newMonitorCount - monitors := [] - loop, % MonitorCount - { - SysGet, BoundingBox, Monitor, % A_Index - monitors.Push({"Top": BoundingBoxTop, "Bottom": BoundingBoxBottom, "Left": BoundingBoxLeft, "Right": BoundingBoxRight}) + screens := [] + Loop MonitorCount { + MonitorGet A_Index, &L, &T, &R, &B + screens.Push({Top: T, Bottom: B, Left: L, Right: R}) } } - return monitors + return screens } GetLocalMonitorMouseCoords() { monitors := GetAllMonitorsDimensions() - CoordMode, Mouse, Screen - MouseGetPos, X, Y + CoordMode("Mouse", "Screen") + MouseGetPos(&X, &Y) for k, v in monitors { if (X >= v.Left && X <= v.Right && Y <= v.Bottom && Y >= v.Top) { - return {"x": X - v.Left, "y": Y - v.Top} + return {x: X - v.Left, y: Y - v.Top} } } }