Skip to content

Commit

Permalink
Libdebug
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Dec 25, 2022
1 parent 9746a22 commit da6da78
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 40 deletions.
4 changes: 2 additions & 2 deletions AutoHotkey64.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions CapsLockToggle.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
19 changes: 8 additions & 11 deletions lib/Tippy.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,30 @@ class TT {
ttData.WhichToolTip := whichToolTip
ttData.extraOffsetY := extraOffsetY
ttData.Hwnd := ""
ttData.ToolTipHeight := 0
ttData.YOffset := ""

Sleep 2
}


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
}


Expand Down Expand Up @@ -311,8 +309,7 @@ class TT {
static screens := 0

newMonitorCount := MonitorGetCount()
if (monitorCount != newMonitorCount)
{
if (monitorCount != newMonitorCount) {
monitorCount := newMonitorCount

screens := []
Expand Down
45 changes: 20 additions & 25 deletions lib/libdebug.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,53 @@

;------------------------------------------------
; 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)

}

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}
}
}
}

0 comments on commit da6da78

Please sign in to comment.