aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts.ahk10
-rw-r--r--tt.doubleclick.ahk90
-rw-r--r--tt.jump.ahk32
-rw-r--r--tt.layout.ahk50
-rw-r--r--tt.programs.ahk18
-rw-r--r--tt.programs.explorer.ahk154
-rw-r--r--tt.scroll.ahk8
-rw-r--r--tt.volume.ahk92
-rw-r--r--tt.windows.ahk82
-rw-r--r--tt.windowselect.ahk296
10 files changed, 416 insertions, 416 deletions
diff --git a/scripts.ahk b/scripts.ahk
index 797668e..45d4cbe 100644
--- a/scripts.ahk
+++ b/scripts.ahk
@@ -76,9 +76,9 @@ return
WindowMessage(wParam, lParam)
{
- global WindowMessageHandlers
- for k, v in WindowMessageHandlers
- {
- %v%(wParam, lParam)
- }
+ global WindowMessageHandlers
+ for k, v in WindowMessageHandlers
+ {
+ %v%(wParam, lParam)
+ }
}
diff --git a/tt.doubleclick.ahk b/tt.doubleclick.ahk
index 0b2454b..58d83f4 100644
--- a/tt.doubleclick.ahk
+++ b/tt.doubleclick.ahk
@@ -15,14 +15,14 @@
DoubleClick(alternate := false)
{
-
+
;; A bunch of global variables are needed to determine whether a double click
;; has been performed:
-
- global DoubleClickClicked
- global DoubleClickPriorX
- global DoubleClickPriorY
- global DoubleClickLast
+
+ global DoubleClickClicked
+ global DoubleClickPriorX
+ global DoubleClickPriorY
+ global DoubleClickLast
;; The DoubleClickClicked variable should be set to false in the beginning of
;; the script: -> init
@@ -34,16 +34,16 @@ DoubleClickClicked := false
;; The maximum double click area (x * y) and time (in milliseconds) are
;; retrieved from Windows:
- SysGet, SM_CXDOUBLECLK, 36
- SysGet, SM_CYDOUBLECLK, 37
- max := DllCall("User32\GetDoubleClickTime")
+ SysGet, SM_CXDOUBLECLK, 36
+ SysGet, SM_CYDOUBLECLK, 37
+ max := DllCall("User32\GetDoubleClickTime")
;; The current absolute position of the mouse is retrieved:
-
- tmp := A_CoordModeMouse
- CoordMode, Mouse, Screen
- MouseGetPos, x, y
- CoordMode, Mouse, %tmp%
+
+ tmp := A_CoordModeMouse
+ CoordMode, Mouse, Screen
+ MouseGetPos, x, y
+ CoordMode, Mouse, %tmp%
;; The DoubleClickClicked variable, if true, signifies that a first click has
;; already been performed. If false, a double click has not been initiated.
@@ -52,43 +52,43 @@ DoubleClickClicked := false
;; The first click should be allowed to pass through, but the function takes
;; note of the click and sets the global variables against which to compare
;; the next click:
-
- if (not DoubleClickClicked)
- {
- if (alternate)
- SendInput, {Click, right}
- else
- SendInput, {Click}
- DoubleClickPriorX := x
- DoubleClickPriorY := y
- DoubleClickLast := A_TickCount
- DoubleClickClicked := true
- return false
- }
+
+ if (not DoubleClickClicked)
+ {
+ if (alternate)
+ SendInput, {Click, right}
+ else
+ SendInput, {Click}
+ DoubleClickPriorX := x
+ DoubleClickPriorY := y
+ DoubleClickLast := A_TickCount
+ DoubleClickClicked := true
+ return false
+ }
;; At this point, the function has been called for the second time, signifying
;; a second click. Now, it checks whether the two clicks meet the operating
;; system's requirements for a double click; if not, then this click is treated
;; as yet another first click:
-
- if (A_TickCount - DoubleClickLast > max
- || abs(x - DoubleClickPriorX) > SM_CXDOUBLECLK
- || abs(y - DoubleClickPriorY) > SM_CYDOUBLECLK)
- {
- if (alternate)
- SendInput, {Click, right}
- else
- SendInput, {Click}
- DoubleClickPriorX := x
- DoubleClickPriorY := y
- DoubleClickLast := A_TickCount
- DoubleClickClicked := true
- return false
- }
+
+ if (A_TickCount - DoubleClickLast > max
+ || abs(x - DoubleClickPriorX) > SM_CXDOUBLECLK
+ || abs(y - DoubleClickPriorY) > SM_CYDOUBLECLK)
+ {
+ if (alternate)
+ SendInput, {Click, right}
+ else
+ SendInput, {Click}
+ DoubleClickPriorX := x
+ DoubleClickPriorY := y
+ DoubleClickLast := A_TickCount
+ DoubleClickClicked := true
+ return false
+ }
;; At this point, a double click has successfully been performed. The variable
;; signifying a first click is reset to false, and the function returns true:
-
- DoubleClickClicked := false
- return true
+
+ DoubleClickClicked := false
+ return true
}
diff --git a/tt.jump.ahk b/tt.jump.ahk
index 0a1fe3c..35b6022 100644
--- a/tt.jump.ahk
+++ b/tt.jump.ahk
@@ -1,12 +1,12 @@
;; -> init
JumpPaths := { s: env("Sync")
- , w: env("Sync") "\Projekt\john.ankarstrom.se\htdocs"
- , g: env("Sync") "\Projekt\git"
- , e: env("Personal")
- , d: env("Personal") "\Downloads"
- , m: env("Personal") "\MP3"
- , p: env("Personal") "\My Pictures" }
+ , w: env("Sync") "\Projekt\john.ankarstrom.se\htdocs"
+ , g: env("Sync") "\Projekt\git"
+ , e: env("Personal")
+ , d: env("Personal") "\Downloads"
+ , m: env("Personal") "\MP3"
+ , p: env("Personal") "\My Pictures" }
;; -> body
@@ -18,10 +18,10 @@ SendInput, {Blind}{LWin Up}
Input, k, C L1
if (JumpPaths[k] != "")
{
- if (InStr(FileExist(JumpPaths[k]), "D"))
- Run, % "explorer /n, """ JumpPaths[k] """"
- else
- Run, % """" JumpPaths[k] """"
+ if (InStr(FileExist(JumpPaths[k]), "D"))
+ Run, % "explorer /n, """ JumpPaths[k] """"
+ else
+ Run, % """" JumpPaths[k] """"
}
ToolTip
return
@@ -33,10 +33,10 @@ ToolTip, ...
SendInput, {Blind}{LWin Up}
Input, k, L1
if (JumpPaths[k] != "")
- if ((e := Explorer()) != -1) ; (see tt.programs.explorer.ahk)
- e.Navigate(JumpPaths[k])
- else
- Run, % "explorer """ JumpPaths[k] """"
+ if ((e := Explorer()) != -1) ; (see tt.programs.explorer.ahk)
+ e.Navigate(JumpPaths[k])
+ else
+ Run, % "explorer """ JumpPaths[k] """"
ToolTip
return
@@ -44,6 +44,6 @@ return
env(name)
{
- EnvGet, r, %name%
- return r
+ EnvGet, r, %name%
+ return r
}
diff --git a/tt.layout.ahk b/tt.layout.ahk
index 4ce61b0..700afa4 100644
--- a/tt.layout.ahk
+++ b/tt.layout.ahk
@@ -14,30 +14,30 @@ return
;; -> init
layouts := { ru: DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1)
- , sv: DllCall("LoadKeyboardLayout", "Str", "0000041D", "Int", 1) }
+ , sv: DllCall("LoadKeyboardLayout", "Str", "0000041D", "Int", 1) }
ShowLayout()
;; -> library
ShowLayout(hwnd := "")
{
- global layouts
- f := A_FormatInteger
- SetFormat, Integer, H
- if (hwnd = "")
- WinGet, hwnd, id, A
- thread := DllCall("GetWindowThreadProcessId", "UInt",hwnd, "UInt",0)
- layout := DllCall("user32.dll\GetKeyboardLayout", "UInt",thread, "UInt")
- for k, v in layouts
- {
- if (layout = v)
- {
- if (FileExist(k ".ico"))
- Menu, Tray, Icon, %k%.ico
- break
- }
- }
- SetFormat, Integer, %f%
+ global layouts
+ f := A_FormatInteger
+ SetFormat, Integer, H
+ if (hwnd = "")
+ WinGet, hwnd, id, A
+ thread := DllCall("GetWindowThreadProcessId", "UInt",hwnd, "UInt",0)
+ layout := DllCall("user32.dll\GetKeyboardLayout", "UInt",thread, "UInt")
+ for k, v in layouts
+ {
+ if (layout = v)
+ {
+ if (FileExist(k ".ico"))
+ Menu, Tray, Icon, %k%.ico
+ break
+ }
+ }
+ SetFormat, Integer, %f%
}
;; Update layout display on window change -------------------------------------
@@ -46,11 +46,11 @@ ShowLayout(hwnd := "")
LayoutWindowMessage(wParam, lParam)
{
- if (wParam = 4 or wParam = 32772) ; HSHELL_WINDOW_ACTIVATED | HSHELL_RUDEAPPACTIVATED
- {
- ShowLayout(lParam)
- WinSet, AlwaysOnTop, On, OSD
- }
+ if (wParam = 4 or wParam = 32772) ; HSHELL_WINDOW_ACTIVATED | HSHELL_RUDEAPPACTIVATED
+ {
+ ShowLayout(lParam)
+ WinSet, AlwaysOnTop, On, OSD
+ }
}
;; -> init
@@ -67,6 +67,6 @@ OnMessage(0x404, "NotifyIcon")
NotifyIcon(wParam, lParam)
{
- if (lParam = 0x202) ; WM_LBUTTONUP
- Run, % "Rundll32 Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}"
+ if (lParam = 0x202) ; WM_LBUTTONUP
+ Run, % "Rundll32 Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}"
}
diff --git a/tt.programs.ahk b/tt.programs.ahk
index 1dd4e03..b4aa039 100644
--- a/tt.programs.ahk
+++ b/tt.programs.ahk
@@ -18,12 +18,12 @@ XButton1::SendInput, +{F5} ; cycle cursor position backwards
+WheelUp::
Loop, 30
- SendInput, ^+{Left}
+ SendInput, ^+{Left}
return
+WheelDown::
Loop, 30
- SendInput, ^+{Right}
+ SendInput, ^+{Right}
return
#IfWinActive ahk_class EVERYTHING
@@ -46,11 +46,11 @@ F4::SendInput, !{Right}
!F2::SendInput, {WheelDown}
F1::
Loop, 5
- SendInput, {WheelUp}
+ SendInput, {WheelUp}
return
F2::
Loop, 5
- SendInput, {WheelDown}
+ SendInput, {WheelDown}
return
#IfWinActive ahk_class KMeleon Browser Window
@@ -61,11 +61,11 @@ F4::SendInput, !{Right}
!F2::SendInput, {LAlt Up}{Down}
F1::
Loop, 5
- SendInput, {WheelUp}
+ SendInput, {WheelUp}
return
F2::
Loop, 5
- SendInput, {WheelDown}
+ SendInput, {WheelDown}
return
#IfWinActive ahk_class MediaPlayerClassicW
@@ -73,13 +73,13 @@ return
Esc::
WinGetPos, x, y, w, h
if (x = 0 and y = 0 and w = A_ScreenWidth and h = A_ScreenHeight)
- SendInput, {F11}
+ SendInput, {F11}
return
~RShift::
WinGetPos, x, y, w, h, A
if not (x = 0 and y = 0 and w = A_ScreenWidth and h = A_ScreenHeight)
- return
+ return
MouseGetPos, mx, my
MouseMove, % A_ScreenWidth, % A_ScreenHeight, 0
KeyWait, RShift
@@ -91,7 +91,7 @@ WinGetPos, x, y, w, h, A
MouseGetPos, mx, my
SendInput, {LCtrl Down}7{LCtrl Up}
if (x = 0 and y = 0 and w = A_ScreenWidth and h = A_ScreenHeight)
- MouseMove, % A_ScreenWidth, 0, 0
+ MouseMove, % A_ScreenWidth, 0, 0
KeyWait, LShift
MouseMove, % mx, % my, 0
SendInput, {LCtrl Down}7{LCtrl Up}
diff --git a/tt.programs.explorer.ahk b/tt.programs.explorer.ahk
index 4c4276e..0d31034 100644
--- a/tt.programs.explorer.ahk
+++ b/tt.programs.explorer.ahk
@@ -14,22 +14,22 @@ GroupAdd, ExplorerDesktop, ahk_class WorkerW
Explorer(hwnd := "")
{
- global ShellApp
- if (hwnd = "")
- WinGet, hwnd, id, A
- for window in ShellApp.Windows
- if (window.hwnd = hwnd)
- return window
- return -1
+ global ShellApp
+ if (hwnd = "")
+ WinGet, hwnd, id, A
+ for window in ShellApp.Windows
+ if (window.hwnd = hwnd)
+ return window
+ return -1
}
ExplorerPath()
{
- WinGetClass, cls, A
- if (cls = "Progman" or cls = "WorkerW")
- return %A_Desktop%
- else
- return Explorer().Document.Folder.Self.path
+ WinGetClass, cls, A
+ if (cls = "Progman" or cls = "WorkerW")
+ return %A_Desktop%
+ else
+ return Explorer().Document.Folder.Self.path
}
;; -> body
@@ -72,11 +72,11 @@ LWin & LButton::
MouseGetPos,,, hwnd
DllCall("SetForegroundWindow", "UInt", hwnd)
if (not DoubleClick()) ; see tt.doubleclick.ahk
- return
+ return
if (not WinActive("ahk_group Explorer"))
{
- SendInput, {Click}
- return
+ SendInput, {Click}
+ return
}
; fall through to next hotkey
@@ -86,7 +86,7 @@ if (not WinActive("ahk_group Explorer"))
#Enter::
i := Explorer().Document.FocusedItem
if (i.IsFolder)
- return
+ return
ShellApp.ShellExecute(i.path, "", "", "Edit", 1)
return
@@ -97,14 +97,14 @@ RAlt & Up::
e := Explorer()
path := e.Document.Folder.Self.path
if (InStr(path, "::{") = 1)
- return
+ return
slash := InStr(path, "\", 0, 0)
if (slash = StrLen(path))
- slash := InStr(path, "\", 0, 0, 2)
+ slash := InStr(path, "\", 0, 0, 2)
if (slash = 0)
- parent = ::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ; My Computer
+ parent = ::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ; My Computer
else
- parent := SubStr(path, 1, slash)
+ parent := SubStr(path, 1, slash)
e.Navigate(parent)
return
@@ -112,7 +112,7 @@ LAlt & Down::
RAlt & Down::
path := ExplorerPath()
if (InStr(path, "::{") = 1)
- return
+ return
Explorer().Navigate(path) ; go to real path of folder
return
@@ -126,7 +126,7 @@ NumPut(NumGet(SHELLSTATE) ^ (1 << 0), SHELLSTATE,, "Int")
DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", SSF_SHOWALLOBJECTS, "Int", true)
WinGet, win, List, ahk_group Explorer
Loop, % win
- PostMessage, 0x111, 41504,,, % "ahk_id " win%A_Index% ; refresh
+ PostMessage, 0x111, 41504,,, % "ahk_id " win%A_Index% ; refresh
return
; Sort and display options
@@ -159,41 +159,41 @@ return
ExplorerFolderView(view, children := false)
{
- if (view = "name")
- n := {m: 30210, d: -1}
- else if (view = "modified")
- n := {m: 30213, d: -1}
- else if (view = "type")
- n := {m: 30212, d: -1}
- else if (view = "created")
- n := {m: 30214, d: -1}
- else if (view = "groups")
- n := {m: 30209, d: -1}
- else if (view = "tiles")
- n := {m: 28718, d: 6}
- else if (view = "icons")
- n := {m: 28713, d: 1}
- else if (view = "thumbnails")
- n := {m: 28717, d: 5}
- else if (view = "details")
- n := {m: 28716, d: 4}
- else if (view = "list")
- n := {m: 28715, d: 3}
-
- PostMessage, 0x111, % n.m, 0,, A ; change current folder
- return
- if (not children or m.d = -1)
- return
-
- old := A_BatchLines
- SetBatchLines, -1
-
- Loop, Files, % ExplorerPath() "\*", D
- {
- MsgBox, % A_LoopFileFullPath
- }
-
- SetBatchLines, % old
+ if (view = "name")
+ n := {m: 30210, d: -1}
+ else if (view = "modified")
+ n := {m: 30213, d: -1}
+ else if (view = "type")
+ n := {m: 30212, d: -1}
+ else if (view = "created")
+ n := {m: 30214, d: -1}
+ else if (view = "groups")
+ n := {m: 30209, d: -1}
+ else if (view = "tiles")
+ n := {m: 28718, d: 6}
+ else if (view = "icons")
+ n := {m: 28713, d: 1}
+ else if (view = "thumbnails")
+ n := {m: 28717, d: 5}
+ else if (view = "details")
+ n := {m: 28716, d: 4}
+ else if (view = "list")
+ n := {m: 28715, d: 3}
+
+ PostMessage, 0x111, % n.m, 0,, A ; change current folder
+ return
+ if (not children or m.d = -1)
+ return
+
+ old := A_BatchLines
+ SetBatchLines, -1
+
+ Loop, Files, % ExplorerPath() "\*", D
+ {
+ MsgBox, % A_LoopFileFullPath
+ }
+
+ SetBatchLines, % old
}
;; Git hotkeys ----------------------------------------------------------------
@@ -202,26 +202,26 @@ ExplorerFolderView(view, children := false)
q(s)
{
- return """" s """"
+ return """" s """"
}
qp()
{
- return """" Explorer().Document.Folder.Self.path """"
+ return """" Explorer().Document.Folder.Self.path """"
}
qip()
{
- r := ""
- for item in Explorer().Document.SelectedItems
- r .= """" item.path """ "
- return r
+ r := ""
+ for item in Explorer().Document.SelectedItems
+ r .= """" item.path """ "
+ return r
}
basename(s)
{
- slash := InStr(path, "\", 0, 0)
- return SubStr(path, slash + 1)
+ slash := InStr(path, "\", 0, 0)
+ return SubStr(path, slash + 1)
}
;; -> body
@@ -237,49 +237,49 @@ basename(s)
!a::
qip := qip()
if (qip = "")
- Run, % "cmd /c cd "qp()" & git add . && git status & pause"
+ Run, % "cmd /c cd "qp()" & git add . && git status & pause"
else
- Run, % "cmd /c cd "qp()" & git add " qip " && git status & pause"
+ Run, % "cmd /c cd "qp()" & git add " qip " && git status & pause"
return
!+a::
qip := qip()
if (qip = "")
- Run, % "cmd /c cd "qp()" & git add -p . && git status & pause"
+ Run, % "cmd /c cd "qp()" & git add -p . && git status & pause"
else
- Run, % "cmd /c cd "qp()" & git add -p " qip " && git status & pause"
+ Run, % "cmd /c cd "qp()" & git add -p " qip " && git status & pause"
return
!f::
qip := qip()
if (qip = "")
- Run, % "cmd /c cd "qp()" & git diff & pause"
+ Run, % "cmd /c cd "qp()" & git diff & pause"
else
- Run, % "cmd /c cd "qp()" & git diff " qip " & pause"
+ Run, % "cmd /c cd "qp()" & git diff " qip " & pause"
return
!i::
qip := qip()
if (qip = "")
- Run, % "cmd /c cd "qp()" & git diff HEAD~1 HEAD & pause"
+ Run, % "cmd /c cd "qp()" & git diff HEAD~1 HEAD & pause"
else
- Run, % "cmd /c cd "qp()" & git diff HEAD~1 HEAD " qip " & pause"
+ Run, % "cmd /c cd "qp()" & git diff HEAD~1 HEAD " qip " & pause"
return
!l::
qip := qip()
if (qip = "")
- Run, % "cmd /c cd "qp()" & git log & pause"
+ Run, % "cmd /c cd "qp()" & git log & pause"
else
- Run, % "cmd /c cd "qp()" & git log " qip " & pause"
+ Run, % "cmd /c cd "qp()" & git log " qip " & pause"
return
!r::
qip := qip()
if (qip = "")
- Run, % "cmd /c cd "qp()" & git reset . && git status & pause"
+ Run, % "cmd /c cd "qp()" & git reset . && git status & pause"
else
- Run, % "cmd /c cd "qp()" & git reset " qip " && git status & pause"
+ Run, % "cmd /c cd "qp()" & git reset " qip " && git status & pause"
return
#IfWinActive
diff --git a/tt.scroll.ahk b/tt.scroll.ahk
index 44e1a26..e553317 100644
--- a/tt.scroll.ahk
+++ b/tt.scroll.ahk
@@ -12,12 +12,12 @@
PgUp::
Loop, 5
- SendInput, ^{PgUp}
+ SendInput, ^{PgUp}
return
PgDn::
Loop, 5
- SendInput, ^{PgDn}
+ SendInput, ^{PgDn}
return
#IfWinActive ahk_class SUMATRA_PDF_FRAME
@@ -34,12 +34,12 @@ PgDn::SendInput, {PgDn}
PgUp::
Loop, 5
- SendInput, {WheelUp}
+ SendInput, {WheelUp}
return
PgDn::
Loop, 5
- SendInput, {WheelDown}
+ SendInput, {WheelDown}
return
<^>!PgUp::SendInput, {PgUp}
diff --git a/tt.volume.ahk b/tt.volume.ahk
index 59d16a7..e01be7d 100644
--- a/tt.volume.ahk
+++ b/tt.volume.ahk
@@ -13,53 +13,53 @@ RAlt & F5::SetVolume(GetKeyState("Shift") ? -2 : -1)
SetVolume(n)
{
- SoundGet, w, WAVE
- SoundSet, 15
- w := round(w) + n
- if (w > 100)
- w := 100
- if (w < 0)
- w := 0
- SoundSet, %w%, WAVE
- OSD(w)
+ SoundGet, w, WAVE
+ SoundSet, 15
+ w := round(w) + n
+ if (w > 100)
+ w := 100
+ if (w < 0)
+ w := 0
+ SoundSet, %w%, WAVE
+ OSD(w)
}
/*
SetVolume(n)
{
- global wMax
- static vMin := 4
-
- SoundGet, s
- SoundGet, w, WAVE
- s := round(s)
- w := round(w)
-
- if (s > vMin or w > wMax)
- wMax := w
- else if (wMax = "")
- wMax := 100
-
- v := s + w - wMax + n
-
- if (v > 100)
- v := 100
-
- if (v >= vMin)
- {
- s := v
- w := wMax
- }
- else
- {
- s := vMin
- w := wMax - vMin + v
- }
-
- SoundSet, %s%
- SoundSet, %w%, WAVE
- OSD(v) ; display volume on screen
+ global wMax
+ static vMin := 4
+
+ SoundGet, s
+ SoundGet, w, WAVE
+ s := round(s)
+ w := round(w)
+
+ if (s > vMin or w > wMax)
+ wMax := w
+ else if (wMax = "")
+ wMax := 100
+
+ v := s + w - wMax + n
+
+ if (v > 100)
+ v := 100
+
+ if (v >= vMin)
+ {
+ s := v
+ w := wMax
+ }
+ else
+ {
+ s := vMin
+ w := wMax - vMin + v
+ }
+
+ SoundSet, %s%
+ SoundSet, %w%, WAVE
+ OSD(v) ; display volume on screen
}
*/
@@ -80,11 +80,11 @@ Gui, OSD:Show, x0 y%y% AutoSize NA, OSD
OSD(text)
{
- SetTimer, RemoveOSD, Off
- WinSet, AlwaysOnTop, On, OSD
- GuiControl, OSD:Text, OSD, %text%
- SetTimer, RemoveOSD, 3000
- return
+ SetTimer, RemoveOSD, Off
+ WinSet, AlwaysOnTop, On, OSD
+ GuiControl, OSD:Text, OSD, %text%
+ SetTimer, RemoveOSD, 3000
+ return
}
RemoveOSD:
diff --git a/tt.windows.ahk b/tt.windows.ahk
index b8eb857..ec6532c 100644
--- a/tt.windows.ahk
+++ b/tt.windows.ahk
@@ -18,9 +18,9 @@ Gui, FakeWindow:Show, x0 y%y% AutoSize NA, FakeWindow
#y::
WinGet, t, Transparent, A
if (t = OFF)
- WinSet, Transparent, 180, A
+ WinSet, Transparent, 180, A
else
- WinSet, Transparent, OFF, A
+ WinSet, Transparent, OFF, A
return
#b::WinSet, Bottom,, A
#!m::WinMove, A,, 0, 0
@@ -29,9 +29,9 @@ return
#v::
WinGet, mm, MinMax, A
if (mm = 1)
- WinRestore, A
+ WinRestore, A
else
- WinMaximize, A
+ WinMaximize, A
return
#x:: ; minimize all except current
@@ -44,7 +44,7 @@ WinSet, Style, % s, ahk_id %hwnd%
WinActivate, ahk_id %hwnd%
WinGet, mm, MinMax, ahk_id %hwnd%
if (mm = -1)
- WinRestore, ahk_id %hwnd%
+ WinRestore, ahk_id %hwnd%
return
#c:: ; minimize last window
@@ -78,14 +78,14 @@ return
$!Tab::
HandleAltTab:
if (WindowDisabled)
- WinSet, Disable,, ahk_id %WindowDisabled%
+ WinSet, Disable,, ahk_id %WindowDisabled%
SendInput, {LAlt Down}{Tab}
Hotkey, $!Tab, HandleAltTab, Off
Hotkey, $!+Tab, HandleAltShiftTab, Off
while (GetKeyState("LAlt", "P") and not esc := GetKeyState("Esc", "P"))
- Sleep, 1
+ Sleep, 1
if (esc)
- SendInput, {Esc}
+ SendInput, {Esc}
SendInput, {LAlt Up}
Hotkey, $!Tab, HandleAltTab, On
Hotkey, $!+Tab, HandleAltShiftTab, On
@@ -95,17 +95,17 @@ return
$!+Tab::
HandleAltShiftTab:
if (WindowDisabled)
- WinSet, Disable,, ahk_id %WindowDisabled%
+ WinSet, Disable,, ahk_id %WindowDisabled%
if (WinActive("A") = WindowDisabled)
- SendInput, {LAlt Down}{LShift Down}{Tab}{LShift Up}{Tab}
+ SendInput, {LAlt Down}{LShift Down}{Tab}{LShift Up}{Tab}
else
- SendInput, {LAlt Down}{LShift Down}{Tab}{LShift Up}
+ SendInput, {LAlt Down}{LShift Down}{Tab}{LShift Up}
Hotkey, $!Tab, HandleAltTab, Off
Hotkey, $!+Tab, HandleAltShiftTab, Off
while (GetKeyState("LAlt", "P") and not esc := GetKeyState("Esc", "P"))
- Sleep, 1
+ Sleep, 1
if (esc)
- SendInput, {Esc}
+ SendInput, {Esc}
SendInput, {LAlt Up}
Hotkey, $!Tab, HandleAltTab, On
Hotkey, $!+Tab, HandleAltShiftTab, On
@@ -118,8 +118,8 @@ hwndp := WinActive("A")
MouseGetPos,,, hwnd
if (hwnd = hwndp)
{
- WinSet, Top,, A
- return
+ WinSet, Top,, A
+ return
}
DllCall("SetForegroundWindow", "UInt", hwnd)
WinSet, AlwaysOnTop, On, ahk_id %hwndp%
@@ -132,15 +132,15 @@ return
WindowsWindowMessage(wParam, lParam)
{
- static HSHELL_GETMINRECT := 5
- ; The active window is 0 during minimization (if animated)
- if (wParam = HSHELL_GETMINRECT and WinActive("A") = 0)
- {
- hwnd := NumGet(lParam + 0)
- WinWaitNotActive, ahk_id 0
- Sleep, 20
- InsertAfter(hwnd, "BOTTOM")
- }
+ static HSHELL_GETMINRECT := 5
+ ; The active window is 0 during minimization (if animated)
+ if (wParam = HSHELL_GETMINRECT and WinActive("A") = 0)
+ {
+ hwnd := NumGet(lParam + 0)
+ WinWaitNotActive, ahk_id 0
+ Sleep, 20
+ InsertAfter(hwnd, "BOTTOM")
+ }
}
;; -> init
@@ -153,21 +153,21 @@ WindowMessageHandlers.Push("WindowsWindowMessage")
InsertAfter(hwnd = "", position = "BOTTOM")
{
- static SWP_NOSIZE := 0x0001
- static SWP_NOMOVE := 0x0002
- static SWP_ASYNCWINDOWPOS := 0x4000
- static HWND_BOTTOM := 1
- static HWND_NOTOPMOST := -2
- static HWND_TOP := 0
- static HWND_TOPMOST := -1
- if (hwnd = "")
- WinGet, hwnd, id, A
- DllCall("SetWindowPos"
- , "UInt", hwnd
- , "UInt", HWND_%position%
- , "Int", 0
- , "Int", 0
- , "Int", 0
- , "Int", 0
- , "UInt", SWP_NOSIZE | SWP_NOMOVE | SWP_ASYNCWINDOWPOS)
+ static SWP_NOSIZE := 0x0001
+ static SWP_NOMOVE := 0x0002
+ static SWP_ASYNCWINDOWPOS := 0x4000
+ static HWND_BOTTOM := 1
+ static HWND_NOTOPMOST := -2
+ static HWND_TOP := 0
+ static HWND_TOPMOST := -1
+ if (hwnd = "")
+ WinGet, hwnd, id, A
+ DllCall("SetWindowPos"
+ , "UInt", hwnd
+ , "UInt", HWND_%position%
+ , "Int", 0
+ , "Int", 0
+ , "Int", 0
+ , "Int", 0
+ , "UInt", SWP_NOSIZE | SWP_NOMOVE | SWP_ASYNCWINDOWPOS)
}
diff --git a/tt.windowselect.ahk b/tt.windowselect.ahk
index ba9abb5..0914004 100644
--- a/tt.windowselect.ahk
+++ b/tt.windowselect.ahk
@@ -19,184 +19,184 @@
Add_hWndToArray(gi, hWnd)
{
- global
- g_bundleSize%gi% := g_bundleSize%gi% + 1
- local wi := g_bundleSize%gi%
- g_hWnd%gi%_%wi% := hWnd
+ global
+ g_bundleSize%gi% := g_bundleSize%gi% + 1
+ local wi := g_bundleSize%gi%
+ g_hWnd%gi%_%wi% := hWnd
}
AddBundle(gi)
{
- global
- g_bundleSize%gi% := 0
+ global
+ g_bundleSize%gi% := 0
}
BundleSize(gi)
{
- global
- return g_bundleSize%gi%
+ global
+ return g_bundleSize%gi%
}
Get_hWndFromArray(gi, wi)
{
- global
- return g_hWnd%gi%_%wi%
+ global
+ return g_hWnd%gi%_%wi%
}
SetButtonTopLeftLoc(gi, x, y)
{
- global
- g_xs%gi% := x
- g_ys%gi% := y
+ global
+ g_xs%gi% := x
+ g_ys%gi% := y
}
Build_hWndArray(maxBundleCount)
{
- global g_bundleCount
-
- WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
- hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
- pProc := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
- idxTB := GetTaskSwBar()
- SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_BUTTONCOUNT
- buttonCount := ErrorLevel
-
- g_bundleCount := 0
-
- Loop, %buttonCount%
- {
- SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETBUTTON
-
- VarSetCapacity(btn, 32, 0)
- DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
-
- idn := NumGet(btn, 4)
- Statyle := NumGet(btn, 8, "Char")
- dwData := NumGet(btn, 12)
- If Not dwData
- dwData := NumGet(btn, 16, "int64")
-
- DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "int64P", hWnd:=0, "Uint", NumGet(btn,12) ? 4:8, "Uint", 0)
-
- If Not hWnd ; group button, indicates the start of a group
- {
- If g_bundleCount >= %maxBundleCount%
- Break
-
- hidden := Statyle & 0x08 ; TBSTATE_HIDDEN
- If Not hidden
- {
- grpCollapsed := true
- g_bundleCount := g_bundleCount + 1
- AddBundle(g_bundleCount)
-
- GetTaskbarButtonTopLeft(idn, x, y)
- SetButtonTopLeftLoc(g_bundleCount, x, y)
- }
- Else
- grpCollapsed := false
- }
- else ; actual window button
- {
- If grpCollapsed
- {
- Add_hWndToArray(g_bundleCount, hWnd)
- }
- Else
- {
- g_bundleCount := g_bundleCount + 1
- AddBundle(g_bundleCount)
- Add_hWndToArray(g_bundleCount, hWnd)
-
- GetTaskbarButtonTopLeft(idn, x, y)
- SetButtonTopLeftLoc(g_bundleCount, x, y)
- }
- }
- }
-
- DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
- DllCall("CloseHandle", "Uint", hProc)
+ global g_bundleCount
+
+ WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
+ hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
+ pProc := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
+ idxTB := GetTaskSwBar()
+ SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_BUTTONCOUNT
+ buttonCount := ErrorLevel
+
+ g_bundleCount := 0
+
+ Loop, %buttonCount%
+ {
+ SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETBUTTON
+
+ VarSetCapacity(btn, 32, 0)
+ DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
+
+ idn := NumGet(btn, 4)
+ Statyle := NumGet(btn, 8, "Char")
+ dwData := NumGet(btn, 12)
+ If Not dwData
+ dwData := NumGet(btn, 16, "int64")
+
+ DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "int64P", hWnd:=0, "Uint", NumGet(btn,12) ? 4:8, "Uint", 0)
+
+ If Not hWnd ; group button, indicates the start of a group
+ {
+ If g_bundleCount >= %maxBundleCount%
+ Break
+
+ hidden := Statyle & 0x08 ; TBSTATE_HIDDEN
+ If Not hidden
+ {
+ grpCollapsed := true
+ g_bundleCount := g_bundleCount + 1
+ AddBundle(g_bundleCount)
+
+ GetTaskbarButtonTopLeft(idn, x, y)
+ SetButtonTopLeftLoc(g_bundleCount, x, y)
+ }
+ Else
+ grpCollapsed := false
+ }
+ else ; actual window button
+ {
+ If grpCollapsed
+ {
+ Add_hWndToArray(g_bundleCount, hWnd)
+ }
+ Else
+ {
+ g_bundleCount := g_bundleCount + 1
+ AddBundle(g_bundleCount)
+ Add_hWndToArray(g_bundleCount, hWnd)
+
+ GetTaskbarButtonTopLeft(idn, x, y)
+ SetButtonTopLeftLoc(g_bundleCount, x, y)
+ }
+ }
+ }
+
+ DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
+ DllCall("CloseHandle", "Uint", hProc)
}
FocusButton(n)
{
- global g_bundleCount
-
- ; these static variables can become inaccurate if windows are created or closed
- ; inbetween pressing of hotkeys, but in practice, we can safely ignore the
- ; inaccuracy
- static prevBundleIndex := 0
- static prevWindowIndex := 0
-
- Build_hWndArray(n)
-
- if (g_bundleCount >= n)
- {
- bundleSize := BundleSize(n)
-
- if n = %prevBundleIndex%
- windowIndex := Mod(prevWindowIndex, bundleSize) + 1
- else
- windowIndex := 1
-
- hWnd := Get_hWndFromArray(n, windowIndex)
-
- If bundleSize > 1 ; cycle through windows in the same bundle
- WinActivate, ahk_id %hWnd%
- Else ; single-window bundle; toggles between activating (restoring) and minimizing the window
- IfWinActive, ahk_id %hWnd%
- WinMinimize, ahk_id %hWnd%
- Else
- WinActivate, ahk_id %hWnd%
-
- prevBundleIndex := n
- prevWindowIndex := windowIndex
- }
+ global g_bundleCount
+
+ ; these static variables can become inaccurate if windows are created or closed
+ ; inbetween pressing of hotkeys, but in practice, we can safely ignore the
+ ; inaccuracy
+ static prevBundleIndex := 0
+ static prevWindowIndex := 0
+
+ Build_hWndArray(n)
+
+ if (g_bundleCount >= n)
+ {
+ bundleSize := BundleSize(n)
+
+ if n = %prevBundleIndex%
+ windowIndex := Mod(prevWindowIndex, bundleSize) + 1
+ else
+ windowIndex := 1
+
+ hWnd := Get_hWndFromArray(n, windowIndex)
+
+ If bundleSize > 1 ; cycle through windows in the same bundle
+ WinActivate, ahk_id %hWnd%
+ Else ; single-window bundle; toggles between activating (restoring) and minimizing the window
+ IfWinActive, ahk_id %hWnd%
+ WinMinimize, ahk_id %hWnd%
+ Else
+ WinActivate, ahk_id %hWnd%
+
+ prevBundleIndex := n
+ prevWindowIndex := windowIndex
+ }
}
GetTaskSwBar()
{
- ControlGet, hParent, hWnd,, MSTaskSwWClass1 , ahk_class Shell_TrayWnd
- ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
- Loop
- {
- ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
- If Not hWnd
- Break
- Else If hWnd = %hChild%
- {
- idxTB := A_Index
- Break
- }
- }
- Return idxTB
+ ControlGet, hParent, hWnd,, MSTaskSwWClass1 , ahk_class Shell_TrayWnd
+ ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
+ Loop
+ {
+ ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
+ If Not hWnd
+ Break
+ Else If hWnd = %hChild%
+ {
+ idxTB := A_Index
+ Break
+ }
+ }
+ Return idxTB
}
GetTaskbarButtonTopLeft(id, ByRef x, ByRef y)
{
- idxTB := GetTaskSwBar()
- WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
- hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
- pProc := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
- idxTB := GetTaskSwBar()
-
- SendMessage, 0x433, id, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETRECT
- ;IfEqual, ErrorLevel, 0, return "Err: can't get rect"
-
- VarSetCapacity(rect, 32, 0)
- DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &rect, "Uint", 32, "Uint", 0)
-
- DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
- DllCall("CloseHandle", "Uint", hProc)
-
- ControlGet, hWnd, hWnd,, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd
- WinGetPos, x, y, w, h, ahk_id %hWnd%
-
- left := NumGet(rect, 0)
- top := NumGet(rect, 4)
- right := NumGet(rect, 8)
- bottom := NumGet(rect, 12)
-
- x := x + left
- y := y + top
+ idxTB := GetTaskSwBar()
+ WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
+ hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
+ pProc := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
+ idxTB := GetTaskSwBar()
+
+ SendMessage, 0x433, id, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETRECT
+ ;IfEqual, ErrorLevel, 0, return "Err: can't get rect"
+
+ VarSetCapacity(rect, 32, 0)
+ DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &rect, "Uint", 32, "Uint", 0)
+
+ DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
+ DllCall("CloseHandle", "Uint", hProc)
+
+ ControlGet, hWnd, hWnd,, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd
+ WinGetPos, x, y, w, h, ahk_id %hWnd%
+
+ left := NumGet(rect, 0)
+ top := NumGet(rect, 4)
+ right := NumGet(rect, 8)
+ bottom := NumGet(rect, 12)
+
+ x := x + left
+ y := y + top
}