Skip to content

Commit

Permalink
Midwork through Tippy2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Nov 7, 2023
1 parent 7406c90 commit a963189
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 5 deletions.
6 changes: 6 additions & 0 deletions AutoHotkey64.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ InstallMouseHook
; TraySetIcon "shell32.dll", 44 ; change tray icon to a yellow star
TraySetIcon("resources/blueStar.ico")

CoordMode("Mouse", "Screen")

; I removed `n and `t from hotstring trigger chars
; https://www.autohotkey.com/docs/v2/Hotstrings.htm#EndChars
#Hotstring EndChars -()[]{}:;'"/\,.?!`s

;; rest of everything
#Include lib/Tippy.ahk
Expand All @@ -34,6 +39,7 @@ TraySetIcon("resources/blueStar.ico")

#Include *i Private.ahk

#Include lib/_JXON.ahk


;-------------------------------------------------
Expand Down
90 changes: 87 additions & 3 deletions lib/Tippy2.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class T
; offset from the previous tooltip (tooltip above)
y += currentTooltipsHeights

; if tooltip is at right side of screen
;TODO
if(!tt.IsAlreadyShown())
{
Tooltip( k . dbg(tt) " " currentTooltipsHeights, x, y, k)
Expand Down Expand Up @@ -133,14 +135,52 @@ class T

}

;GetMouseCoordinates?????
GetLocalScreenMouseCoordsAndBounds() {
screens := GetAllScreenCoordinates()

CoordMode("Mouse", "Screen")
MouseGetPos(&X, &Y)

for s in screens {
if (X >= s.Left && X <= s.Right && Y >= s.Bottom && Y <= s.Top) {
return {x: X - s.Left, y: Y - s.Top, screenHeight: s.Bottom, screenWidth: s.Right}
}
}
}

dbg(obj)
{
return JxonEncode(obj, 1)
GetAllScreenCoordinates() {
static monitorCount := 0
static screens := 0

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

screens := []
Loop MonitorCount {
MonitorGet A_Index, &L, &T, &R, &B
if (L > R) {
tmp := L
L := R
R := tmp
}

if (B > T) {
tmp := B
B := T
T := tmp
}
screens.Push({Top: T, Bottom: B, Left: L, Right: R})
}
}
return screens
}





^j::
{
Tippy("10 " A_Now, 1000000, 10)
Expand All @@ -156,3 +196,47 @@ Tippy(text := "", durationMs := 3333, whichTooltip := 1) {

T(text, durationMs, whichTooltip)
}


^k::
{
MonitorCount := MonitorGetCount()
MonitorPrimary := MonitorGetPrimary()
MsgBox "Monitor Count:`t" MonitorCount "`nPrimary Monitor:`t" MonitorPrimary
Loop MonitorCount
{
MonitorGet(1, &L, &T, &R, &B)
MonitorGetWorkArea A_Index, &WL, &WT, &WR, &WB
MsgBox
(
"Monitor:`t#" A_Index "
Name:`t" MonitorGetName(A_Index) "
Left:`t" L " (" WL " work)
Top:`t" T " (" WT " work)
Right:`t" R " (" WR " work)
Bottom:`t" B " (" WB " work)"
)
}
}



class BB
{
static v := 6

__New()
{
v := 1 ; ❌ assumes local variable, not the static
this.v := 1 ; ❌ assumes instance variable, not the static
BB.v := 1 ;
%this.__Class%.v :=1
}

showV()
{
Tooltip(v) ; ❌ Error: Warning: This variable appears to never be assigned a value.
Tooltip(BB.v) ; ✅ this works
Tooltip(this.V) ; ✅ this also works! 🎉
}
}
59 changes: 57 additions & 2 deletions lib/libdebug.ahk
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
#include <Tippy>
#Include _JXON.ahk

dbg(obj)
{
return JxonEncode(obj, 1)
}

;------------------------------------------------
; CapsLock + /: Toggle Mouse debugging mode
CapsLock & /:: {
static toggle := 0
MouseDebugging()
Tippy(dbg(GetAllMonitorsDimensions()), 1000000)
SetTimer(MouseDebugging, (toggle := !toggle) ? 500 : 0)
}

MouseDebugging() {
MouseGetPos(&X, &Y)
Tippy("Mouse Pos: " x " x " y " (global)",, 18)

VirtualScreenWidth := SysGet(78)
VirtualScreenHeight := SysGet(79)
Tippy("Screen Size: " VirtualScreenWidth " x " VirtualScreenHeight,, 19)


m := GetAllMonitorsDimensions()
Tippy(dbg(m),, 20)
for k, v in m {
if (X >= v.Left && X <= v.Right && Y >= v.Bottom && Y <= v.Top) {
return {x: X - v.Left, y: Y - v.Top}
}
}
}

GetMouseCoordinatesInLocalScreen() {
MouseGetPos(&X, &Y)
m := GetAllMonitorsDimensions()

for k, v in m {
if (X >= v.Left && X <= v.Right && Y >= v.Bottom && Y <= v.Top) {
return {x: X - v.Left, y: Y - v.Top}
}
}
}

class LocalScreenMouseCoords {
x := ""
y := ""

}

MouseDebuggingOld() {
CoordMode("Mouse", "Screen")
MouseGetPos(&X, &Y)
Tippy("Mouse Pos: " x " x " y " (global)", , 19)
Expand All @@ -19,8 +60,9 @@ MouseDebugging() {
Tippy("Screen Size: " VirtualScreenWidth " x " VirtualScreenHeight,, 18)

localPos := GetLocalMonitorMouseCoords()
Tippy("Mouse Pos: " localPos.x " x " localPos.y " (local)",, 20)

try {
Tippy("Mouse Pos: " localPos.x " x " localPos.y " (local)",, 20)
}
}

GetAllMonitorsDimensions() {
Expand All @@ -34,6 +76,19 @@ GetAllMonitorsDimensions() {
screens := []
Loop MonitorCount {
MonitorGet A_Index, &L, &T, &R, &B

if (L > R) {
tmp := L
L := R
R := tmp
}

if (B > T) {
tmp := B
B := T
T := tmp
}

screens.Push({Top: T, Bottom: B, Left: L, Right: R})
}
}
Expand Down

0 comments on commit a963189

Please sign in to comment.