diff options
-rw-r--r-- | !tt.scrollbar.ahk | 220 | ||||
-rw-r--r-- | arrowdown.bmp | bin | 0 -> 938 bytes | |||
-rw-r--r-- | arrowup.bmp | bin | 0 -> 938 bytes | |||
-rw-r--r-- | bluesection.bmp | bin | 0 -> 158 bytes | |||
-rw-r--r-- | build.bat | 8 | ||||
-rw-r--r-- | lib/Acc.ahk | 198 | ||||
-rw-r--r-- | lib/AccViewer.ahk | 839 | ||||
-rw-r--r-- | lib/Anchor.ahk | 76 | ||||
-rw-r--r-- | out/arrowdown.bmp | bin | 0 -> 938 bytes | |||
-rw-r--r-- | out/arrowup.bmp | bin | 0 -> 938 bytes | |||
-rw-r--r-- | out/bluesection.bmp | bin | 0 -> 158 bytes | |||
-rw-r--r-- | out/db.sqlite3 | bin | 0 -> 28672 bytes | |||
-rw-r--r-- | out/ru.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | out/scripts.ahk | 864 | ||||
-rw-r--r-- | out/sv.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | out/whitesection.bmp | bin | 0 -> 158 bytes | |||
-rw-r--r-- | ru.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | scripts.ahk | 62 | ||||
-rw-r--r-- | sv.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | tt.doubleclick.ahk | 94 | ||||
-rw-r--r-- | tt.exe | bin | 0 -> 62464 bytes | |||
-rw-r--r-- | tt.jump.ahk | 48 | ||||
-rw-r--r-- | tt.layout.ahk | 72 | ||||
-rw-r--r-- | tt.programs.ahk | 100 | ||||
-rw-r--r-- | tt.programs.explorer.ahk | 197 | ||||
-rw-r--r-- | tt.scroll.ahk | 46 | ||||
-rw-r--r-- | tt.traymenu.ahk | 29 | ||||
-rw-r--r-- | tt.volume.ahk | 93 | ||||
-rw-r--r-- | tt.windows.ahk | 173 | ||||
-rw-r--r-- | tt.windowselect.ahk | 202 | ||||
-rw-r--r-- | whitesection.bmp | bin | 0 -> 158 bytes |
31 files changed, 3321 insertions, 0 deletions
diff --git a/!tt.scrollbar.ahk b/!tt.scrollbar.ahk new file mode 100644 index 0000000..c88f451 --- /dev/null +++ b/!tt.scrollbar.ahk @@ -0,0 +1,220 @@ +;; Plan 9-like scrollbar for Windows XP --------------------------------------- + +;; The following rules apply: + +;; * Press/hold left mouse button to scroll down. +;; * Press/hold right mouse button to scroll up. +;; * The closer to the top of the scrollbar, the slower the speed. +;; * The closer to the bottom of the scrollbar, the faster the speed. + +;; The scrolling is achieved by simulating the mouse wheel. +;; Windows without mousewheel support do not work. + +;; To use the scrollbar normally, hold any modifier key while clicking the +;; mouse. Ctrl works well, as Ctrl-clicking a scrollbar does nothing special. + +;; -> init + +GroupAdd, ScrollbarExceptions, ahk_class Shell_TrayWnd +GroupAdd, ScrollbarExceptions, ahk_class #32768 + +;; -> body + +#If (ScrollbarClip or WinActive("ahk_class MozillaWindowClass")) and (ScrollbarCurrent := CurrentScrollbar()) + +LButton:: +MouseGetPos,, my +s := ScrollbarCurrent +r := ceil((my - s.a) / (s.b - s.a) * 10) +ScrollbarAmount := r +if (WinActive("ahk_class PuTTY")) + ScrollbarDown = ^{PgDn} +else + ScrollbarDown = {WheelDown} +ScrollbarNew := true +if (not ScrollbarScrolling) + SetTimer, ScrollbarScroll, 0 +return + +RButton:: +MouseGetPos,, my +s := ScrollbarCurrent +r := ceil((my - s.a) / (s.b - s.a) * 10) +ScrollbarAmount := -r +if (WinActive("ahk_class PuTTY")) + ScrollbarUp = ^{PgUp} +else + ScrollbarUp = {WheelUp} +ScrollbarNew := true +if (not ScrollbarScrolling) + SetTimer, ScrollbarScroll, 0 +return + +#If + +<^>!§::SendInput, {Text}§ + +§:: +global ScrollbarClip +DllCall("ClipCursor", "Ptr", &0) +WinGetPos, x,, w,, A +MouseGetPos, mx, my +s := CurrentScrollbar(w - 12, my) +ScrollbarClip := !ScrollbarClip +if (not ScrollbarClip or not s) + return +WinGetPos, x, y +VarSetCapacity(r, 12, 0) +NumPut(x + s.aa + 6, &r + 0) +NumPut(y + s.a + 1, &r + 4) +NumPut(x + s.bb + 6, &r + 8) +NumPut(y + s.b, &r + 12) +DllCall("ClipCursor", "UInt", &R) +r = "" +return + +;; -> library + +ScrollbarScroll: +SetTimer, ScrollbarScroll, Off +ScrollbarScrolling := true +ScrollbarNew := false +i := 0 +j := abs(ScrollbarAmount) +while (i < j or GetKeyState(ScrollbarAmount > 0 ? "LButton" : "RButton", "P")) +{ + i += 1 + if (ScrollbarNew) + { + i := 0 + j := abs(ScrollbarAmount) + ScrollbarNew := false + } + MouseGetPos,, my + s := ScrollbarCurrent + if (my < s.a) + r := 1 + else + r := ceil((my - s.a) / (s.b - s.a) * 10) + ScrollbarAmount := ScrollbarAmount > 0 ? r : -r + if (ScrollbarAmount > 0) + SendInput, %ScrollbarDown% + else + SendInput, %ScrollbarUp% + Sleep, % 100 / abs(ScrollbarAmount) + if (not (i < j or GetKeyState(ScrollbarAmount > 0 ? "LButton" : "RButton", "P"))) + break + if (i = j) + Sleep, 150 +} +ScrollbarScrolling := false +return + +CurrentScrollbar(mx = "", my = "") +{ + static size := 17 + static GA_ROOT := 2 + + old := A_BatchLines + SetBatchLines, -1 + goto begin +end: + SetBatchLines, % A_BatchLines + return false +begin: + + ;; Because this function is run whenever the left mouse button is pressed, it + ;; is important to return false as early as possible. + + CoordMode, Mouse, Window + if (mx = "" and my = "") + MouseGetPos, mx, my, hwnd + if (mx = "" and my != "") + MouseGetPos,, my, hwnd + if (mx != "" and my = "") + MouseGetPos, mx,, hwnd + if (mx != "" and my != "") + MouseGetPos,,, hwnd + WinGet, id, id, ahk_id %hwnd% ahk_group ScrollbarExceptions + if (hwnd = id) + goto end + if (not ScrollbarScrolling and hwnd != WinActive("A")) + goto end + + tmp := A_CoordModePixel + CoordMode, Pixel, Window + + ImageSearch,, wy, % mx - size, % my - size, % mx + size, % my + size, whitesection.bmp + ImageSearch,, by, % mx - size, % my - size, % mx + size, % my + size, *50 bluesection.bmp + if (wy = "" and by = "") + goto end + + WinGetPos,,,, h, A + quit := false + + if (my > h / 2) + { + gosub ScrollbarFindDownBelow + if (quit) + goto end + gosub ScrollbarFindUpAbove + if (quit) + goto end + } else { + gosub ScrollbarFindUpAbove + if (quit) + goto end + gosub ScrollbarFindDownBelow + if (quit) + goto end + } + goto ScrollbarFindRest + +ScrollbarFindUpAbove: + y := 20 + Loop + { + ImageSearch, uax, uay, % mx - size, % my - y, % mx + size, % my, arrowup.bmp + y += 20 + } until (uay != "" or my - y <= 0) + + if (uay = "") + { + CoordMode, Pixel, % tmp + quit := true + } + return + +ScrollbarFindDownBelow: + ImageSearch, dbx, dby, % mx - size, % my, % mx + size, % h, arrowdown.bmp + + if (dby = "") + { + CoordMode, Pixel, % tmp + quit := true + } + return + +ScrollbarFindRest: + y := 20 + ; Find down arrow above + Loop + { + ImageSearch, dax, day, % mx - size, 0, % mx + size, % h, arrowdown.bmp ; above + y += 20 + } until (day != "" or my - y <= 0) + + ; Find up arrow below + ImageSearch, ubx, uby, % mx - size, % my, % mx + size, % h, arrowup.bmp + + ; In the middle of two scrollbars + if (day != "" and uby != "" and day > uay and uby < dby) + { + CoordMode, Pixel, % tmp + goto end + } + + CoordMode, Pixel, % tmp + SetBatchLines, % A_BatchLines + return { a: uay + size + 1, b: dby - 1, aa: uax, bb: dbx } +} diff --git a/arrowdown.bmp b/arrowdown.bmp Binary files differnew file mode 100644 index 0000000..83848f0 --- /dev/null +++ b/arrowdown.bmp diff --git a/arrowup.bmp b/arrowup.bmp Binary files differnew file mode 100644 index 0000000..f83122f --- /dev/null +++ b/arrowup.bmp diff --git a/bluesection.bmp b/bluesection.bmp Binary files differnew file mode 100644 index 0000000..e7e940a --- /dev/null +++ b/bluesection.bmp diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..c7e141e --- /dev/null +++ b/build.bat @@ -0,0 +1,8 @@ +@echo off +setlocal +cd /d %~dp0 +set out=out +if not exist %out%\ md %out% || exit /b 1 +for %%f in ("*.ico") do if not exist %out%\%%f copy /y "%%f" %out% +for %%f in ("*.bmp") do if not exist %out%\%%f copy /y "%%f" %out% +type tt.*.ahk 2>nul | tt -c"" -d";;" -o%out%/ scripts.ahk || pause
\ No newline at end of file diff --git a/lib/Acc.ahk b/lib/Acc.ahk new file mode 100644 index 0000000..19fc83a --- /dev/null +++ b/lib/Acc.ahk @@ -0,0 +1,198 @@ +; http://www.autohotkey.com/board/topic/77303-acc-library-ahk-l-updated-09272012/ +; https://dl.dropbox.com/u/47573473/Web%20Server/AHK_L/Acc.ahk +;------------------------------------------------------------------------------ +; Acc.ahk Standard Library +; by Sean +; Updated by jethrow: +; Modified ComObjEnwrap params from (9,pacc) --> (9,pacc,1) +; Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs) +; Added Acc_GetRoleText & Acc_GetStateText +; Added additional functions - commented below +; Removed original Acc_Children function +; last updated 2/25/2010 +;------------------------------------------------------------------------------ + +Acc_Init() +{ + Static h + If Not h + h:=DllCall("LoadLibrary","Str","oleacc","Ptr") +} +Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild) +{ + Acc_Init() + If DllCall("oleacc\AccessibleObjectFromEvent", "Ptr", hWnd, "UInt", idObject, "UInt", idChild, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0 + Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt") +} + +Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "") +{ + Acc_Init() + If DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0 + Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt") +} + +Acc_ObjectFromWindow(hWnd, idObject = -4) +{ + Acc_Init() + If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0 + Return ComObjEnwrap(9,pacc,1) +} + +Acc_WindowFromObject(pacc) +{ + If DllCall("oleacc\WindowFromAccessibleObject", "Ptr", IsObject(pacc)?ComObjValue(pacc):pacc, "Ptr*", hWnd)=0 + Return hWnd +} + +Acc_GetRoleText(nRole) +{ + nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0) + VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize) + DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1) + Return sRole +} + +Acc_GetStateText(nState) +{ + nSize := DllCall("oleacc\GetStateText", "Uint", nState, "Ptr", 0, "Uint", 0) + VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize) + DllCall("oleacc\GetStateText", "Uint", nState, "str", sState, "Uint", nSize+1) + Return sState +} + +Acc_SetWinEventHook(eventMin, eventMax, pCallback) +{ + Return DllCall("SetWinEventHook", "Uint", eventMin, "Uint", eventMax, "Uint", 0, "Ptr", pCallback, "Uint", 0, "Uint", 0, "Uint", 0) +} + +Acc_UnhookWinEvent(hHook) +{ + Return DllCall("UnhookWinEvent", "Ptr", hHook) +} +/* Win Events: + + pCallback := RegisterCallback("WinEventProc") + WinEventProc(hHook, event, hWnd, idObject, idChild, eventThread, eventTime) + { + Critical + Acc := Acc_ObjectFromEvent(_idChild_, hWnd, idObject, idChild) + ; Code Here: + + } +*/ + +; Written by jethrow +Acc_Role(Acc, ChildId=0) { + try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetRoleText(Acc.accRole(ChildId)):"invalid object" +} +Acc_State(Acc, ChildId=0) { + try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetStateText(Acc.accState(ChildId)):"invalid object" +} +Acc_Location(Acc, ChildId=0, byref Position="") { ; adapted from Sean's code + try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId) + catch + return + Position := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int") + return {x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")} +} +Acc_Parent(Acc) { + try parent:=Acc.accParent + return parent?Acc_Query(parent): +} +Acc_Child(Acc, ChildId=0) { + try child:=Acc.accChild(ChildId) + return child?Acc_Query(child): +} +Acc_Query(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530 + try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1) +} +Acc_Error(p="") { + static setting:=0 + return p=""?setting:setting:=p +} +Acc_Children(Acc) { + if ComObjType(Acc,"Name") != "IAccessible" + ErrorLevel := "Invalid IAccessible Object" + else { + Acc_Init(), cChildren:=Acc.accChildCount, Children:=[] + if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 { + Loop %cChildren% + i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=9?Acc_Query(child):child), NumGet(varChildren,i-8)=9?ObjRelease(child): + return Children.MaxIndex()?Children: + } else + ErrorLevel := "AccessibleChildren DllCall Failed" + } + if Acc_Error() + throw Exception(ErrorLevel,-1) +} +Acc_ChildrenByRole(Acc, Role) { + if ComObjType(Acc,"Name")!="IAccessible" + ErrorLevel := "Invalid IAccessible Object" + else { + Acc_Init(), cChildren:=Acc.accChildCount, Children:=[] + if DllCall("oleacc\AccessibleChildren", "Ptr",ComObjValue(Acc), "Int",0, "Int",cChildren, "Ptr",VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*",cChildren)=0 { + Loop %cChildren% { + i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i) + if NumGet(varChildren,i-8)=9 + AccChild:=Acc_Query(child), ObjRelease(child), Acc_Role(AccChild)=Role?Children.Insert(AccChild): + else + Acc_Role(Acc, child)=Role?Children.Insert(child): + } + return Children.MaxIndex()?Children:, ErrorLevel:=0 + } else + ErrorLevel := "AccessibleChildren DllCall Failed" + } + if Acc_Error() + throw Exception(ErrorLevel,-1) +} +Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") { + static properties := {Action:"DefaultAction", DoAction:"DoDefaultAction", Keyboard:"KeyboardShortcut"} + AccObj := IsObject(WinTitle)? WinTitle + : Acc_ObjectFromWindow( WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText), 0 ) + if ComObjType(AccObj, "Name") != "IAccessible" + ErrorLevel := "Could not access an IAccessible Object" + else { + StringReplace, ChildPath, ChildPath, _, %A_Space%, All + AccError:=Acc_Error(), Acc_Error(true) + Loop Parse, ChildPath, ., %A_Space% + try { + if A_LoopField is digit + Children:=Acc_Children(AccObj), m2:=A_LoopField ; mimic "m2" output in else-statement + else + RegExMatch(A_LoopField, "(\D*)(\d*)", m), Children:=Acc_ChildrenByRole(AccObj, m1), m2:=(m2?m2:1) + if Not Children.HasKey(m2) + throw + AccObj := Children[m2] + } catch { + ErrorLevel:="Cannot access ChildPath Item #" A_Index " -> " A_LoopField, Acc_Error(AccError) + if Acc_Error() + throw Exception("Cannot access ChildPath Item", -1, "Item #" A_Index " -> " A_LoopField) + return + } + Acc_Error(AccError) + StringReplace, Cmd, Cmd, %A_Space%, , All + properties.HasKey(Cmd)? Cmd:=properties[Cmd]: + try { + if (Cmd = "Location") + AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId) + , ret_val := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int") + else if (Cmd = "Object") + ret_val := AccObj + else if Cmd in Role,State + ret_val := Acc_%Cmd%(AccObj, ChildID+0) + else if Cmd in ChildCount,Selection,Focus + ret_val := AccObj["acc" Cmd] + else + ret_val := AccObj["acc" Cmd](ChildID+0) + } catch { + ErrorLevel := """" Cmd """ Cmd Not Implemented" + if Acc_Error() + throw Exception("Cmd Not Implemented", -1, Cmd) + return + } + return ret_val, ErrorLevel:=0 + } + if Acc_Error() + throw Exception(ErrorLevel,-1) +}
\ No newline at end of file diff --git a/lib/AccViewer.ahk b/lib/AccViewer.ahk new file mode 100644 index 0000000..f3d1dae --- /dev/null +++ b/lib/AccViewer.ahk @@ -0,0 +1,839 @@ +; Accessible Info Viewer +; http://www.autohotkey.com/board/topic/77888-accessible-info-viewer-alpha-release-2012-09-20/ +; https://dl.dropbox.com/u/47573473/Accessible%20Info%20Viewer/AccViewer%20Source.ahk + +#SingleInstance force + +_colTextW := 55 +_col2W := 120 +_col4W := 51 + +_margin := 10 + +_offset1 := _margin +_offset2 := _colTextW + 2*_margin ; 2 times the margin +_offset3 := _offset2 + _col2W + _margin +_offset4 := _offset3 + _colTextW + _margin + +_fullW := _offset4 + _col4W - (_margin/2) + +_guiWidth := _fullW + _fullW/2.5 +_guiHeight := 410 +_maxHeight := _guiHeight + 80 +_minHeight := _guiHeight - 80 + + + + +{ + WM_ACTIVATE := 0x06 + WM_KILLFOCUS := 0x08 + WM_LBUTTONDOWN := 0x201 + WM_LBUTTONUP := 0x202 + global Border := new Outline, Stored:={}, Acc, ChildId, TVobj, Win:={} +} +{ + DetectHiddenWindows, On + OnExit, OnExitCleanup + OnMessage(0x200,"WM_MOUSEMOVE") + ComObjError(false) + Hotkey, ~LButton Up, Off +} +{ + Gui Main: New, HWNDhwnd LabelGui AlwaysOnTop, Accessible Info Viewer + Gui Main: Default + Win.Main := hwnd + Gui, Add, Button, x160 y8 w105 h20 vShowStructure gShowStructure, Show Acc Structure + { + Gui, Add, Text, x10 y3 w%_colTextW% h26 Border gCrossHair ReadOnly HWNDh8 Border + CColor(h8, "White") + Gui, Add, Text, x10 y3 w%_colTextW% h4 HWNDh9 Border + CColor(h9, "0046D5") + Gui, Add, Text, x13 y17 w19 h1 Border vHBar + Gui, Add, Text, x22 y8 w1 h19 Border vVBar + } + { + Gui, Font, bold + Gui, Add, GroupBox, x2 y32 w%_fullW% h130 vWinCtrl, Window/Control Info + Gui, Font + Gui, Add, Text, x%_offset1% y49 w%_colTextW% h20 Right, WinTitle: + Gui, Add, Edit, x%_offset2% y47 w%_fullW% h20 vWinTitle , + + Gui, Add, Text, x%_offset1% y71 w%_colTextW% h20 Right, Text: + Gui, Add, Edit, x%_offset2% y69 w%_fullW% h20 vText , + + ; Row 3 + Gui, Add, Text, x%_offset1% y93 w%_colTextW% h20 Right, Hwnd: + Gui, Add, Edit, x%_offset2% y91 w%_col2W% h20 vHwnd, + Gui, Add, Text, x%_offset3% y93 w%_colTextW% h20 vClassText Right, Class(NN): + Gui, Add, Edit, x%_offset4% y91 w%_col2W% h20 vClass, + + ; Row 4 + Gui, Add, Text, x%_offset1% y115 w%_colTextW% h20 Right, Position: + Gui, Add, Edit, x%_offset2% y113 w%_col2W% h20 vPosition, + Gui, Add, Text, x%_offset3% y115 w%_colTextW% h20 Right, Process: + Gui, Add, Edit, x%_offset4% y113 w%_col2W% h20 vProcess, + + ; Row 5 + Gui, Add, Text, x%_offset1% y137 w%_colTextW% h20 Right, Size: + Gui, Add, Edit, x%_offset2% y135 w%_col2W% h20 vSize, + Gui, Add, Text, x%_offset3% y137 w%_colTextW% h20 Right, Proc ID: + Gui, Add, Edit, x%_offset4% y135 w%_col2W% h20 vProcID, + } + { + Gui, Font, bold + Gui, Add, GroupBox, x2 y165 w525 h240 vAcc, Accessible Info + Gui, Font + + Gui, Add, Text, x%_offset1% y182 w%_colTextW% h20 Right, Name: + Gui, Add, Edit, x%_offset2% y180 w%_fullW% h20 vAccName , + + Gui, Add, Text, x%_offset1% y204 w%_colTextW% h20 Right, Value: + Gui, Add, Edit, x%_offset2% y202 w%_fullW% h20 vAccValue , + + + ; Row 3 + Gui, Add, Text, x%_offset1% y226 w%_colTextW% h20 Right, Role: + Gui, Add, Edit, x%_offset2% y224 w%_col2W% h20 vAccRole, + Gui, Add, Text, x%_offset3% y226 w%_colTextW% h20 Right, ChildCount: + Gui, Add, Edit, x%_offset4% y224 w%_col2W% h20 vAccChildCount, + + ; Row 4 + Gui, Add, Text, x%_offset1% y248 w%_colTextW% h20 Right, State: + Gui, Add, Edit, x%_offset2% y246 w%_col2W% h20 vAccState, + Gui, Add, Text, x%_offset3% y248 w%_colTextW% h20 Right, Selection: + Gui, Add, Edit, x%_offset4% y246 w%_col2W% h20 vAccSelection, + + ; Row 5 + Gui, Add, Text, x%_offset1% y270 w%_colTextW% h20 Right, Action: + Gui, Add, Edit, x%_offset2% y268 w%_col2W% h20 vAccAction, + Gui, Add, Text, x%_offset3% y270 w%_colTextW% h20 Right, Focus: + Gui, Add, Edit, x%_offset4% y268 w%_col2W% h20 vAccFocus, + { + Gui, Add, Text, x%_offset1% y292 w%_colTextW% h20 Right vAccLocationText, Location: + Gui, Add, Edit, x%_offset2% y290 w%_fullW% h20 vAccLocation , + Gui, Add, Text, x%_offset1% y314 w%_colTextW% h20 Right, Description: + Gui, Add, Edit, x%_offset2% y312 w%_fullW% h20 vAccDescription , + Gui, Add, Text, x%_offset1% y336 w%_colTextW% h20 Right, Keyboard: + Gui, Add, Edit, x%_offset2% y334 w%_fullW% h20 vAccKeyboard , + Gui, Add, Text, x%_offset1% y358 w%_colTextW% h20 Right, Help: + Gui, Add, Edit, x%_offset2% y356 w%_fullW% h20 vAccHelp , + Gui, Add, Text, x%_offset1% y380 w%_colTextW% h20 Right, HelpTopic: + Gui, Add, Edit, x%_offset2% y378 w%_fullW% h20 vAccHelpTopic , + } + } + { + Gui, Add, StatusBar, gShowMainGui + SB_SetParts(70,150) + SB_SetText("`tshow more", 3) + } + { + Gui Acc: New, ToolWindow AlwaysOnTop Resize LabelAcc HWNDhwnd, Acc Structure + Win.Acc := hwnd + Gui Acc: Add, TreeView, w200 h300 vTView gTreeView R17 AltSubmit + Gui Acc: Show, Hide + } + GoSub, ShowMainGui + WinSet, Redraw, , % "ahk_id" Win.Main + return +} +ShowMainGui: +{ + if A_EventInfo in 1,2 + { + WM_MOUSEMOVE() + StatusBarGetText, SB_Text, %A_EventInfo%, % "ahk_id" Win.Main + if SB_Text + if (A_EventInfo=2 and SB_Text:=SubStr(SB_Text,7)) + or if RegExMatch(SB_Text, "Id: \K\d+", SB_Text) + { + ToolTip % "clipboard = " clipboard:=SB_Text + SetTimer, RemoveToolTip, -2000 + } + } + else { + Gui Main: Default + if ShowingLess { + SB_SetText("`tshow less", 3) + GuiControl, Move, Acc, x2 y165 w275 h240 + GuiControl, Show, AccDescription + GuiControl, Show, AccLocation + GuiControl, Show, AccLocationText + { + height := _guiHeight + while height < _maxHeight { + height += 10 + Gui, Show, w%_guiWidth% h%height% + Sleep, 20 + } + } + Gui, Show, w%_guiWidth% h%_maxHeight% + ShowingLess := false + } + else { + if (ShowingLess != "") { + height := %_maxHeight% + while height > %_minHeight% { + height -= 10 + Gui, Show, w%_guiWidth% h%height% + Sleep, 20 + } + } + Gui, Show, w%_guiWidth% h%_minHeight% + GuiControl, Hide, AccDescription + GuiControl, Hide, AccLocation + GuiControl, Hide, AccLocationText + GuiControl, Move, Acc, x2 y165 w275 h130 + SB_SetText("`tshow more", 3) + ShowingLess := true + } + WinSet, Redraw, , % "ahk_id" Win.Main + } +return +} + +#if Not Lbutton_Pressed +^/:: +{ + SetBatchLines, -1 + Lbutton_Pressed := true + Stored.Chwnd := "" + Gui Acc: Default + GuiControl, Disable, TView + while, Lbutton_Pressed + GetAccInfo() + SetBatchLines, 10ms + return +} +#if Lbutton_Pressed +^/:: +{ + Lbutton_Pressed := false + Gui Main: Default + Sleep, -1 + GuiControl, , WinCtrl, % (DllCall("GetParent", Uint,Acc_WindowFromObject(Acc))? "Control":"Window") " Info" + if Not DllCall("IsWindowVisible", "Ptr",Win.Acc) { + Border.Hide() + SB_SetText("Path: " GetAccPath(Acc).path, 2) + } + else { + Gui Acc: Default + BuildTreeView() + GuiControl, Enable, TView + WinActivate, % "ahk_id" Win.Acc + PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc + } + return +} +#if +~Lbutton Up:: +{ + Hotkey, ~LButton Up, Off + Lbutton_Pressed := False + Gui Main: Default + if Not CH { + GuiControl, Show, HBar + GuiControl, Show, VBar + CrossHair(CH:=true) + } + Sleep, -1 + GuiControl, , WinCtrl, % (DllCall("GetParent", Uint,Acc_WindowFromObject(Acc))? "Control":"Window") " Info" + if Not DllCall("IsWindowVisible", "Ptr",Win.Acc) { + Border.Hide() + SB_SetText("Path: " GetAccPath(Acc).path, 2) + } + else { + Gui Acc: Default + BuildTreeView() + GuiControl, Enable, TView + WinActivate, % "ahk_id" Win.Acc + PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc + } + return +} +CrossHair: +{ + if (A_GuiEvent = "Normal") { + SetBatchLines, -1 + Hotkey, ~LButton Up, On + { + GuiControl, Hide, HBar + GuiControl, Hide, VBar + CrossHair(CH:=false) + } + Lbutton_Pressed := True + Stored.Chwnd := "" + Gui Acc: Default + GuiControl, Disable, TView + while, Lbutton_Pressed + GetAccInfo() + SetBatchLines, 10ms + } + return +} +OnExitCleanup: +{ + CrossHair(true) + GuiClose: + ExitApp +} +ShowStructure: +{ + ControlFocus, Static1, % "ahk_id" Win.Main + if DllCall("IsWindowVisible", "Ptr",Win.Acc) { + PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc + return + } + WinGetPos, x, y, w, , % "ahk_id" Win.Main + WinGetPos, , , AccW, AccH, % "ahk_id" Win.Acc + WinMove, % "ahk_id" Win.Acc, + , (x+w+AccW > A_ScreenWidth? x-AccW-10:x+w+10) + , % y+5, %AccW%, %AccH% + WinShow, % "ahk_id" Win.Acc + if ComObjType(Acc, "Name") = "IAccessible" + BuildTreeView() + if Lbutton_Pressed + GuiControl, Disable, TView + else + GuiControl, Enable, TView + PostMessage, %WM_LBUTTONDOWN%, , , SysTreeView321, % "ahk_id" Win.Acc + return +} +BuildTreeView() +{ + r := GetAccPath(Acc) + AccObj:=r.AccObj, Child_Path:=r.Path, r:="" + Gui Acc: Default + TV_Delete() + GuiControl, -Redraw, TView + parent := TV_Add(Acc_Role(AccObj), "", "Bold Expand") + TVobj := {(parent): {is_obj:true, obj:AccObj, need_children:false, childid:0, Children:[]}} + Loop Parse, Child_Path, . + { + if A_LoopField is not Digit + TVobj[parent].Obj_Path := Trim(TVobj[parent].Obj_Path "," A_LoopField, ",") + else { + StoreParent := parent + parent := TV_BuildAccChildren(AccObj, parent, "", A_LoopField) + TVobj[parent].need_children := false + TV_Expanded(StoreParent) + TV_Modify(parent,"Expand") + AccObj := TVobj[parent].obj + } + } + if Not ChildId { + TV_BuildAccChildren(AccObj, parent) + TV_Modify(parent, "Select") + } + else + TV_BuildAccChildren(AccObj, parent, ChildId) + TV_Expanded(parent) + GuiControl, +Redraw, TView +} +AccClose: +{ + Border.Hide() + Gui Acc: Hide + TV_Delete() + Gui Main: Default + GuiControl, Enable, ShowStructure + return +} +AccSize: +{ + Anchor(TView, "wh") + return +} +TreeView: +{ + Gui, Submit, NoHide + if (A_GuiEvent = "S") + UpdateAccInfo(TVobj[A_EventInfo].obj, TVobj[A_EventInfo].childid, TVobj[A_EventInfo].obj_path) + if (A_GuiEvent = "+") { + GuiControl, -Redraw, TView + TV_Expanded(A_EventInfo) + GuiControl, +Redraw, TView + } + return +} +RemoveToolTip: +{ + ToolTip + return +} +GetAccInfo() { + global Whwnd + static ShowButtonEnabled + MouseGetPos, , , Whwnd + if (Whwnd!=Win.Main and Whwnd!=Win.Acc) { + { + GuiControlGet, SectionLabel, , WinCtrl + if (SectionLabel != "Window/Control Info") + GuiControl, , WinCtrl, Window/Control Info + } + Acc := Acc_ObjectFromPoint(ChildId) + Location := GetAccLocation(Acc, ChildId) + if Stored.Location != Location { + Hwnd := Acc_WindowFromObject(Acc) + if Stored.Hwnd != Hwnd { + if DllCall("GetParent", Uint,hwnd) { + WinGetTitle, title, ahk_id %parent% + ControlGetText, text, , ahk_id %Hwnd% + class := GetClassNN(Hwnd,Whwnd) + ControlGetPos, posX, posY, posW, posH, , ahk_id %Hwnd% + WinGet, proc, ProcessName, ahk_id %parent% + WinGet, procid, PID, ahk_id %parent% + } + else { + WinGetTitle, title, ahk_id %Hwnd% + WinGetText, text, ahk_id %Hwnd% + WinGetClass, class, ahk_id %Hwnd% + WinGetPos, posX, posY, posW, posH, ahk_id %Hwnd% + WinGet, proc, ProcessName, ahk_id %Hwnd% + WinGet, procid, PID, ahk_id %Hwnd% + } + { + GuiControl, , WinTitle, %title% + GuiControl, , Text, %text% + SetFormat, IntegerFast, H + GuiControl, , Hwnd, % Hwnd+0 + SetFormat, IntegerFast, D + GuiControl, , Class, %class% + GuiControl, , Position, x%posX% y%posY% + GuiControl, , Size, w%posW% h%posH% + GuiControl, , Process, %proc% + GuiControl, , ProcId, %procid% + } + Stored.Hwnd := Hwnd + } + UpdateAccInfo(Acc, ChildId) + } + } +} +UpdateAccInfo(Acc, ChildId, Obj_Path="") { + global Whwnd + Gui Main: Default + Location := GetAccLocation(Acc, ChildId, x,y,w,h) + { + GuiControl, , AccName, % Acc.accName(ChildId) + GuiControl, , AccValue, % Acc.accValue(ChildId) + GuiControl, , AccRole, % Acc_GetRoleText(Acc.accRole(ChildId)) + GuiControl, , AccState, % Acc_GetStateText(Acc.accState(ChildId)) + GuiControl, , AccAction, % Acc.accDefaultAction(ChildId) + GuiControl, , AccChildCount, % ChildId? "N/A":Acc.accChildCount + GuiControl, , AccSelection, % ChildId? "N/A":Acc.accSelection + GuiControl, , AccFocus, % ChildId? "N/A":Acc.accFocus + GuiControl, , AccLocation, %Location% + GuiControl, , AccDescription, % Acc.accDescription(ChildId) + GuiControl, , AccKeyboard, % Acc.accKeyboardShortCut(ChildId) + Guicontrol, , AccHelp, % Acc.accHelp(ChildId) + GuiControl, , AccHelpTopic, % Acc.accHelpTopic(ChildId) + SB_SetText(ChildId? "Child Id: " ChildId:"Object") + SB_SetText(DllCall("IsWindowVisible", "Ptr",Win.Acc)? "Path: " Obj_Path:"", 2) + } + Border.Transparent(true) + Border.show(x,y,x+w,y+h) + Border.setabove(Whwnd) + Border.Transparent(false) + Stored.Location := Location +} +GetClassNN(Chwnd, Whwnd) { + global _GetClassNN := {} + _GetClassNN.Hwnd := Chwnd + Detect := A_DetectHiddenWindows + WinGetClass, Class, ahk_id %Chwnd% + _GetClassNN.Class := Class + DetectHiddenWindows, On + EnumAddress := RegisterCallback("GetClassNN_EnumChildProc") + DllCall("EnumChildWindows", "uint",Whwnd, "uint",EnumAddress) + DetectHiddenWindows, %Detect% + return, _GetClassNN.ClassNN, _GetClassNN:="" +} +GetClassNN_EnumChildProc(hwnd, lparam) { + static Occurrence + global _GetClassNN + WinGetClass, Class, ahk_id %hwnd% + if _GetClassNN.Class == Class + Occurrence++ + if Not _GetClassNN.Hwnd == hwnd + return true + else { + _GetClassNN.ClassNN := _GetClassNN.Class Occurrence + Occurrence := 0 + return false + } +} +TV_Expanded(TVid) { + For Each, TV_Child_ID in TVobj[TVid].Children + if TVobj[TV_Child_ID].need_children + TV_BuildAccChildren(TVobj[TV_Child_ID].obj, TV_Child_ID) +} +TV_BuildAccChildren(AccObj, Parent, Selected_Child="", Flag="") { + TVobj[Parent].need_children := false + Parent_Obj_Path := Trim(TVobj[Parent].Obj_Path, ",") + for wach, child in Acc_Children(AccObj) { + if Not IsObject(child) { + added := TV_Add("[" A_Index "] " Acc_GetRoleText(AccObj.accRole(child)), Parent) + TVobj[added] := {is_obj:false, obj:Acc, childid:child, Obj_Path:Parent_Obj_Path} + if (child = Selected_Child) + TV_Modify(added, "Select") + } + else { + added := TV_Add("[" A_Index "] " Acc_Role(child), Parent, "bold") + TVobj[added] := {is_obj:true, need_children:true, obj:child, childid:0, Children:[], Obj_Path:Trim(Parent_Obj_Path "," A_Index, ",")} + } + TVobj[Parent].Children.Insert(added) + if (A_Index = Flag) + Flagged_Child := added + } + return Flagged_Child +} +GetAccPath(Acc, byref hwnd="") { + hwnd := Acc_WindowFromObject(Acc) + WinObj := Acc_ObjectFromWindow(hwnd) + WinObjPos := Acc_Location(WinObj).pos + while Acc_WindowFromObject(Parent:=Acc_Parent(Acc)) = hwnd { + t2 := GetEnumIndex(Acc) "." t2 + if Acc_Location(Parent).pos = WinObjPos + return {AccObj:Parent, Path:SubStr(t2,1,-1)} + Acc := Parent + } + while Acc_WindowFromObject(Parent:=Acc_Parent(WinObj)) = hwnd + t1.="P.", WinObj:=Parent + return {AccObj:Acc, Path:t1 SubStr(t2,1,-1)} +} +GetEnumIndex(Acc, ChildId=0) { + if Not ChildId { + ChildPos := Acc_Location(Acc).pos + For Each, child in Acc_Children(Acc_Parent(Acc)) + if IsObject(child) and Acc_Location(child).pos=ChildPos + return A_Index + } + else { + ChildPos := Acc_Location(Acc,ChildId).pos + For Each, child in Acc_Children(Acc) + if Not IsObject(child) and Acc_Location(Acc,child).pos=ChildPos + return A_Index + } +} +GetAccLocation(AccObj, Child=0, byref x="", byref y="", byref w="", byref h="") { + AccObj.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), Child) + return "x" (x:=NumGet(x,0,"int")) " " + . "y" (y:=NumGet(y,0,"int")) " " + . "w" (w:=NumGet(w,0,"int")) " " + . "h" (h:=NumGet(h,0,"int")) +} +WM_MOUSEMOVE() { + static hCurs := new Cursor(32649) + MouseGetPos,,,,ctrl + if (ctrl = "msctls_statusbar321") + DllCall("SetCursor","ptr",hCurs.ptr) +} +class Cursor { + __New(id) { + this.ptr := DllCall("LoadCursor","UInt",NULL,"Int",id,"UInt") +} +__delete() { +DllCall("DestroyCursor","Uint",this.ptr) +} +} +class Outline { + __New(color="red") { + Gui, +HWNDdefault + Loop, 4 { + Gui, New, -Caption +ToolWindow HWNDhwnd + Gui, Color, w%_color% + this[A_Index] := hwnd + } + this.visible := false + this.color := color + this.top := this[1] + this.right := this[2] + this.bottom := this[3] + this.left := this[4] + Gui, %default%: Default + } + Show(x1, y1, x2, y2, sides="TRBL") { + Gui, +HWNDdefault + if InStr( sides, "T" ) + Gui, % this[1] ":Show", % "NA X" x1-2 " Y" y1-2 " W" x2-x1+4 " H" 2 + Else, Gui, % this[1] ":Hide" + if InStr( sides, "R" ) + Gui, % this[2] ":Show", % "NA X" x2 " Y" y1 " W" 2 " H" y2-y1 + Else, Gui, % this[2] ":Hide" + if InStr( sides, "B" ) + Gui, % this[3] ":Show", % "NA X" x1-2 " Y" y2 " W" x2-x1+4 " H" 2 + Else, Gui, % this[3] ":Hide" + if InStr( sides, "L" ) + Gui, % this[4] ":Show", % "NA X" x1-2 " Y" y1 " W" 2 " H" y2-y1 + Else, Gui, % this[3] ":Hide" + self.visible := true + Gui, %default%: Default + } + Hide() { + Gui, +HWNDdefault + Loop, 4 + Gui, % this[A_Index] ": Hide" + self.visible := false + Gui, %default%: Default + } + SetAbove(hwnd) { + ABOVE := DllCall("GetWindow", "uint", hwnd, "uint", 3) + Loop, 4 + DllCall( "SetWindowPos", "uint", this[A_Index], "uint", ABOVE + , "int", 0, "int", 0, "int", 0, "int", 0 + , "uint", 0x1|0x2|0x10 ) + } + Transparent(param) { + Loop, 4 + WinSet, Transparent, % param=1? 0:255, % "ahk_id" this[A_Index] + self.visible := !param + } + Color(color) { + Gui, +HWNDdefault + Loop, 4 + Gui, % this[A_Index] ": Color" , w%_color% + self.color := color + Gui, %default%: Default + } + Destroy() { + Loop, 4 + Gui, % this[A_Index] ": Destroy" + } +} +CColor(Hwnd, Background="", Foreground="") { + return CColor_(Background, Foreground, "", Hwnd+0) +} +CColor_(Wp, Lp, Msg, Hwnd) { + static + static WM_CTLCOLOREDIT=0x0133, WM_CTLCOLORLISTBOX=0x134, WM_CTLCOLORSTATIC=0x0138 + ,LVM_SETBKCOLOR=0x1001, LVM_SETTEXTCOLOR=0x1024, LVM_SETTEXTBKCOLOR=0x1026, TVM_SETTEXTCOLOR=0x111E, TVM_SETBKCOLOR=0x111D + ,BS_CHECKBOX=2, BS_RADIOBUTTON=8, ES_READONLY=0x800 + ,CLR_NONE=-1, CSILVER=0xC0C0C0, CGRAY=0x808080, CWHITE=0xFFFFFF, CMAROON=0x80, CRED=0x0FF, CPURPLE=0x800080, CFUCHSIA=0xFF00FF,CGREEN=0x8000, CLIME=0xFF00, COLIVE=0x8080, CYELLOW=0xFFFF, CNAVY=0x800000, CBLUE=0xFF0000, CTEAL=0x808000, CAQUA=0xFFFF00 + ,CLASSES := "Button,ComboBox,Edit,ListBox,Static,RICHEDIT50W,SysListView32,SysTreeView32" + If (Msg = "") { + if !adrSetTextColor + adrSetTextColor := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetTextColor") + ,adrSetBkColor := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkColor") + ,adrSetBkMode := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "Gdi32.dll"), "str", "SetBkMode") + BG := !Wp ? "" : C%Wp% != "" ? C%Wp% : "0x" SubStr(WP,5,2) SubStr(WP,3,2) SubStr(WP,1,2) + FG := !Lp ? "" : C%Lp% != "" ? C%Lp% : "0x" SubStr(LP,5,2) SubStr(LP,3,2) SubStr(LP,1,2) + WinGetClass, class, ahk_id %Hwnd% + If class not in %CLASSES% + return A_ThisFunc "> Unsupported control class: " class + ControlGet, style, Style, , , ahk_id %Hwnd% + if (class = "Edit") && (Style & ES_READONLY) + class := "Static" + if (class = "Button") + if (style & BS_RADIOBUTTON) || (style & BS_CHECKBOX) + class := "Static" + else + return A_ThisFunc "> Unsupported control class: " class + if (class = "ComboBox") { + VarSetCapacity(CBBINFO, 52, 0), NumPut(52, CBBINFO), DllCall("GetComboBoxInfo", "UInt", Hwnd, "UInt", &CBBINFO) + hwnd := NumGet(CBBINFO, 48) + %hwnd%BG := BG, %hwnd%FG := FG, %hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : -1 + IfEqual, CTLCOLORLISTBOX,,SetEnv, CTLCOLORLISTBOX, % OnMessage(WM_CTLCOLORLISTBOX, A_ThisFunc) + If NumGet(CBBINFO,44) + Hwnd := Numget(CBBINFO,44), class := "Edit" + } + if class in SysListView32,SysTreeView32 + { + m := class="SysListView32" ? "LVM" : "TVM" + SendMessage, %m%_SETBKCOLOR, ,BG, ,ahk_id %Hwnd% + SendMessage, %m%_SETTEXTCOLOR, ,FG, ,ahk_id %Hwnd% + SendMessage, %m%_SETTEXTBKCOLOR, ,CLR_NONE, ,ahk_id %Hwnd% + return + } + if (class = "RICHEDIT50W") + return f := "RichEdit_SetBgColor", %f%(Hwnd, -BG) + if (!CTLCOLOR%Class%) + CTLCOLOR%Class% := OnMessage(WM_CTLCOLOR%Class%, A_ThisFunc) + return %Hwnd% := BG ? DllCall("CreateSolidBrush", "UInt", BG) : CLR_NONE, %Hwnd%BG := BG, %Hwnd%FG := FG + } + critical + Hwnd := Lp + 0, hDC := Wp + 0 + If (%Hwnd%) { + DllCall(adrSetBkMode, "uint", hDC, "int", 1) + if (%Hwnd%FG) + DllCall(adrSetTextColor, "UInt", hDC, "UInt", %Hwnd%FG) + if (%Hwnd%BG) + DllCall(adrSetBkColor, "UInt", hDC, "UInt", %Hwnd%BG) + return (%Hwnd%) + } +} +CrossHair(OnOff=1) { + static AndMask, XorMask, $, h_cursor, IDC_CROSS := 32515 + ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 + , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 + , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 + if (OnOff = "Init" or OnOff = "I" or $ = "") { + $ := "h" + , VarSetCapacity( h_cursor,4444, 1 ) + , VarSetCapacity( AndMask, 32*4, 0xFF ) + , VarSetCapacity( XorMask, 32*4, 0 ) + , system_cursors := "32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650" + StringSplit c, system_cursors, `, + Loop, %c0% + h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% ) + , h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 ) + , b%A_Index% := DllCall("LoadCursor", "Uint", "", "Int", IDC_CROSS, "Uint") + } + $ := (OnOff = 0 || OnOff = "Off" || $ = "h" && (OnOff < 0 || OnOff = "Toggle" || OnOff = "T")) ? "b" : "h" + Loop, %c0% + h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 ) + , DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% ) +} + +{ ; Acc Library + Acc_Init() + { + Static h + If Not h + h:=DllCall("LoadLibrary","Str","oleacc","Ptr") + } + Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild) + { + Acc_Init() + If DllCall("oleacc\AccessibleObjectFromEvent", "Ptr", hWnd, "UInt", idObject, "UInt", idChild, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0 + Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt") + } + Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "") + { + Acc_Init() + If DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0 + Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt") + } + Acc_ObjectFromWindow(hWnd, idObject = 0) + { + Acc_Init() + If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x%_offset1%19B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0 + Return ComObjEnwrap(9,pacc,1) + } + Acc_WindowFromObject(pacc) + { + If DllCall("oleacc\WindowFromAccessibleObject", "Ptr", IsObject(pacc)?ComObjValue(pacc):pacc, "Ptr*", hWnd)=0 + Return hWnd + } + Acc_GetRoleText(nRole) + { + nSize := DllCall("oleacc\GetRoleText", "Uint", nRole, "Ptr", 0, "Uint", 0) + VarSetCapacity(sRole, (A_IsUnicode?2:1)*nSize) + DllCall("oleacc\GetRoleText", "Uint", nRole, "str", sRole, "Uint", nSize+1) + Return sRole + } + Acc_GetStateText(nState) + { + nSize := DllCall("oleacc\GetStateText", "Uint", nState, "Ptr", 0, "Uint", 0) + VarSetCapacity(sState, (A_IsUnicode?2:1)*nSize) + DllCall("oleacc\GetStateText", "Uint", nState, "str", sState, "Uint", nSize+1) + Return sState + } + Acc_Role(Acc, ChildId=0) + { + try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetRoleText(Acc.accRole(ChildId)):"invalid object" + } + Acc_State(Acc, ChildId=0) + { + try return ComObjType(Acc,"Name")="IAccessible"?Acc_GetStateText(Acc.accState(ChildId)):"invalid object" + } + Acc_Children(Acc) + { + if ComObjType(Acc,"Name")!="IAccessible" + error_message := "Cause:`tInvalid IAccessible Object`n`n" + else + { + Acc_Init() + cChildren:=Acc.accChildCount, Children:=[] + if DllCall("oleacc\AccessibleChildren", "Ptr", ComObjValue(Acc), "Int", 0, "Int", cChildren, "Ptr", VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*", cChildren)=0 + { + Loop %cChildren% + i:=(A_Index-1)*(A_PtrSize*2+8)+8, child:=NumGet(varChildren,i), Children.Insert(NumGet(varChildren,i-8)=3?child:Acc_Query(child)), ObjRelease(child) + return Children + } + } + error:=Exception("",-1) + MsgBox, 262148, Acc_Children Failed, % (error_message?error_message:"") "File:`t" (error.file==A_ScriptFullPath?A_ScriptName:error.file) "`nLine:`t" error.line "`n`nContinue Script?" + IfMsgBox, No + ExitApp + } + Acc_Location(Acc, ChildId=0) + { + try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId) + catch + return + return {x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int") + , pos:"x" NumGet(x,0,"int")" y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")} + } + Acc_Parent(Acc) + { + try parent:=Acc.accParent + return parent?Acc_Query(parent): + } + Acc_Child(Acc, ChildId=0) + { + try child:=Acc.accChild(ChildId) + return child?Acc_Query(child): + } + Acc_Query(Acc) + { + try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1) + } +} + +Anchor(i, a = "", r = false) +{ + static c, cs = 12, cx = 255, cl = 0, g, gs = 8, gl = 0, gpi, gw, gh, z = 0, k = 0xffff, ptr + If z = 0 + VarSetCapacity(g, gs * 99, 0), VarSetCapacity(c, cs * cx, 0), ptr := A_PtrSize ? "Ptr" : "UInt", z := true + If (!WinExist("ahk_id" . i)) + { + GuiControlGet, t, Hwnd, %i% + If ErrorLevel = 0 + i := t + Else ControlGet, i, Hwnd, , %i% + } + VarSetCapacity(gi, 68, 0), DllCall("GetWindowInfo", "UInt", gp := DllCall("GetParent", "UInt", i), ptr, &gi) + , giw := NumGet(gi, 28, "Int") - NumGet(gi, 20, "Int"), gih := NumGet(gi, 32, "Int") - NumGet(gi, 24, "Int") + If (gp != gpi) + { + gpi := gp + Loop, %gl% + If (NumGet(g, cb := gs * (A_Index - 1)) == gp, "UInt") + { + gw := NumGet(g, cb + 4, "Short"), gh := NumGet(g, cb + 6, "Short"), gf := 1 + Break + } + If (!gf) + NumPut(gp, g, gl, "UInt"), NumPut(gw := giw, g, gl + 4, "Short"), NumPut(gh := gih, g, gl + 6, "Short"), gl += gs + } + ControlGetPos, dx, dy, dw, dh, , ahk_id %i% + Loop, %cl% + If (NumGet(c, cb := cs * (A_Index - 1), "UInt") == i) + { + If a = + { + cf = 1 + Break + } + giw -= gw, gih -= gh, as := 1, dx := NumGet(c, cb + 4, "Short"), dy := NumGet(c, cb + 6, "Short") + , cw := dw, dw := NumGet(c, cb + 8, "Short"), ch := dh, dh := NumGet(c, cb + 10, "Short") + Loop, Parse, a, xywh + If A_Index > 1 + av := SubStr(a, as, 1), as += 1 + StrLen(A_LoopField) + , d%av% += (InStr("yh", av) ? gih : giw) * (A_LoopField + 0 ? A_LoopField : 1) + DllCall("SetWindowPos", "UInt", i, "UInt", 0, "Int", dx, "Int", dy + , "Int", InStr(a, "w") ? dw : cw, "Int", InStr(a, "h") ? dh : ch, "Int", 4) + If r != 0 + DllCall("RedrawWindow", "UInt", i, "UInt", 0, "UInt", 0, "UInt", 0x0101) + Return + } + If cf != 1 + cb := cl, cl += cs + bx := NumGet(gi, 48, "UInt"), by := NumGet(gi, 16, "Int") - NumGet(gi, 8, "Int") - gih - NumGet(gi, 52, "UInt") + If cf = 1 + dw -= giw - gw, dh -= gih - gh + NumPut(i, c, cb, "UInt"), NumPut(dx - bx, c, cb + 4, "Short"), NumPut(dy - by, c, cb + 6, "Short") + , NumPut(dw, c, cb + 8, "Short"), NumPut(dh, c, cb + 10, "Short") + Return, true +} diff --git a/lib/Anchor.ahk b/lib/Anchor.ahk new file mode 100644 index 0000000..41d6070 --- /dev/null +++ b/lib/Anchor.ahk @@ -0,0 +1,76 @@ +/* + Function: Anchor + Defines how controls should be automatically positioned relative to the new dimensions of a window when resized. + + Parameters: + cl - a control HWND, associated variable name or ClassNN to operate on + a - (optional) one or more of the anchors: 'x', 'y', 'w' (width) and 'h' (height), + optionally followed by a relative factor, e.g. "x h0.5" + r - (optional) true to redraw controls, recommended for GroupBox and Button types + + Examples: +> "xy" ; bounds a control to the bottom-left edge of the window +> "w0.5" ; any change in the width of the window will resize the width of the control on a 2:1 ratio +> "h" ; similar to above but directrly proportional to height + + Remarks: + To assume the current window size for the new bounds of a control (i.e. resetting) simply omit the second and third parameters. + However if the control had been created with DllCall() and has its own parent window, + the container AutoHotkey created GUI must be made default with the +LastFound option prior to the call. + For a complete example see anchor-example.ahk. + + License: + - Version 4.60a <http://www.autohotkey.net/~polyethene/#anchor> + - Dedicated to the public domain (CC0 1.0) <http://creativecommons.org/publicdomain/zero/1.0/> +*/ +Anchor(i, a = "", r = false) { + static c, cs = 12, cx = 255, cl = 0, g, gs = 8, gl = 0, gpi, gw, gh, z = 0, k = 0xffff + If z = 0 + VarSetCapacity(g, gs * 99, 0), VarSetCapacity(c, cs * cx, 0), z := true + If (!WinExist("ahk_id" . i)) { + GuiControlGet, t, Hwnd, %i% + If ErrorLevel = 0 + i := t + Else ControlGet, i, Hwnd, , %i% + } + VarSetCapacity(gi, 68, 0), DllCall("GetWindowInfo", "UInt", gp := DllCall("GetParent", "UInt", i), "UInt", &gi) + , giw := NumGet(gi, 28, "Int") - NumGet(gi, 20, "Int"), gih := NumGet(gi, 32, "Int") - NumGet(gi, 24, "Int") + If (gp != gpi) { + gpi := gp + Loop, %gl% + If (NumGet(g, cb := gs * (A_Index - 1)) == gp) { + gw := NumGet(g, cb + 4, "Short"), gh := NumGet(g, cb + 6, "Short"), gf := 1 + Break + } + If (!gf) + NumPut(gp, g, gl), NumPut(gw := giw, g, gl + 4, "Short"), NumPut(gh := gih, g, gl + 6, "Short"), gl += gs + } + ControlGetPos, dx, dy, dw, dh, , ahk_id %i% + Loop, %cl% + If (NumGet(c, cb := cs * (A_Index - 1)) == i) { + If a = + { + cf = 1 + Break + } + giw -= gw, gih -= gh, as := 1, dx := NumGet(c, cb + 4, "Short"), dy := NumGet(c, cb + 6, "Short") + , cw := dw, dw := NumGet(c, cb + 8, "Short"), ch := dh, dh := NumGet(c, cb + 10, "Short") + Loop, Parse, a, xywh + If A_Index > 1 + av := SubStr(a, as, 1), as += 1 + StrLen(A_LoopField) + , d%av% += (InStr("yh", av) ? gih : giw) * (A_LoopField + 0 ? A_LoopField : 1) + DllCall("SetWindowPos", "UInt", i, "Int", 0, "Int", dx, "Int", dy + , "Int", InStr(a, "w") ? dw : cw, "Int", InStr(a, "h") ? dh : ch, "Int", 4) + If r != 0 + DllCall("RedrawWindow", "UInt", i, "UInt", 0, "UInt", 0, "UInt", 0x0101) ; RDW_UPDATENOW | RDW_INVALIDATE + Return + } + If cf != 1 + cb := cl, cl += cs + bx := NumGet(gi, 48), by := NumGet(gi, 16, "Int") - NumGet(gi, 8, "Int") - gih - NumGet(gi, 52) + If cf = 1 + dw -= giw - gw, dh -= gih - gh + NumPut(i, c, cb), NumPut(dx - bx, c, cb + 4, "Short"), NumPut(dy - by, c, cb + 6, "Short") + , NumPut(dw, c, cb + 8, "Short"), NumPut(dh, c, cb + 10, "Short") + Return, true +} diff --git a/out/arrowdown.bmp b/out/arrowdown.bmp Binary files differnew file mode 100644 index 0000000..83848f0 --- /dev/null +++ b/out/arrowdown.bmp diff --git a/out/arrowup.bmp b/out/arrowup.bmp Binary files differnew file mode 100644 index 0000000..f83122f --- /dev/null +++ b/out/arrowup.bmp diff --git a/out/bluesection.bmp b/out/bluesection.bmp Binary files differnew file mode 100644 index 0000000..e7e940a --- /dev/null +++ b/out/bluesection.bmp diff --git a/out/db.sqlite3 b/out/db.sqlite3 Binary files differnew file mode 100644 index 0000000..25b2944 --- /dev/null +++ b/out/db.sqlite3 diff --git a/out/ru.ico b/out/ru.ico Binary files differnew file mode 100644 index 0000000..15a0616 --- /dev/null +++ b/out/ru.ico diff --git a/out/scripts.ahk b/out/scripts.ahk new file mode 100644 index 0000000..ece6515 --- /dev/null +++ b/out/scripts.ahk @@ -0,0 +1,864 @@ +#Include ../lib/Acc.ahk + +; Directives ------------------------------------------------------------------ + + +#SingleInstance Force +#Persistent +#NoEnv +#WinActivateForce +#MaxHotkeysPerInterval 200 + +; Initialization -------------------------------------------------------------- + +WindowMessageHandlers := [] + +DoubleClickClicked := false +JumpPaths := { s: env("Sync") + , w: env("Sync") "\Projekt\john.ankarstrom.se\htdocs" + , e: env("Personal") + , d: env("Personal") "\Downloads" + , b: "C:\Program Files\KM-Goanna\k-meleon.exe" + , m: "C:\Program Files\Mozilla Thunderbird\thunderbird.exe" } +layouts := { ru: DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1) + , sv: DllCall("LoadKeyboardLayout", "Str", "0000041D", "Int", 1) } +ShowLayout() +WindowMessageHandlers.Push("LayoutWindowMessage") +OnMessage(0x404, "NotifyIcon") +ShellApp := ComObjCreate("Shell.Application") +GroupAdd, Explorer, ahk_class CabinetWClass +GroupAdd, Explorer, ahk_class ExploreWClass +GroupAdd, Desktop, ahk_class Progman +GroupAdd, Desktop, ahk_class WorkerW +GroupAdd, ExplorerDesktop, ahk_class CabinetWClass +GroupAdd, ExplorerDesktop, ahk_class ExploreWClass +GroupAdd, ExplorerDesktop, ahk_class Progman +GroupAdd, ExplorerDesktop, ahk_class WorkerW +Menu, Tray, NoStandard +Menu, Tray, Tip, %A_ScriptName% +Menu, Tray, Add, &Open directory..., TrayOpen +Menu, Tray, Add, Re&build..., TrayRebuild +Menu, Tray, Add, &Reload, TrayReload +Menu, Tray, Add, E&xit, TrayExit +Gui, OSD:+AlwaysOnTop +LastFound +Owner +Disabled -Caption +Gui, OSD:Color, FFFFFF +Gui, OSD:Font, s30, VCR OSD Mono +Gui, OSD:Add, Text, vOSD c00BB00, % " " +WinSet, TransColor, FFFFFF 250 +y := A_ScreenHeight - 100 +Gui, OSD:Show, x0 y%y% AutoSize NA, OSD +GroupAdd, WindowsExplorer, ahk_class CabinetWClass +GroupAdd, WindowsExplorer, ahk_class ExploreWClass +Gui, FakeWindow:+LastFound +Owner +Disabled -Caption +Gui, +hwndFakeWindowHwnd +y := A_ScreenHeight - 100 +Gui, FakeWindow:Show, x0 y%y% AutoSize NA, FakeWindow +WindowMessageHandlers.Push("WindowsWindowMessage") + +Gui +LastFound +DllCall("RegisterShellHookWindow", UInt, WinExist()) +msg := DllCall("RegisterWindowMessage", Str, "SHELLHOOK") +OnMessage(msg, "WindowMessage") +return + +; Body ------------------------------------------------------------------------ + +; Open in new Explorer window +#s:: +ToolTip, ... +SendInput, {Blind}{LWin Up} +Input, k, L1 +if (JumpPaths[k] != "") +{ + if (InStr(FileExist(JumpPaths[k]), "D")) + Run, % "explorer /n, """ JumpPaths[k] """" + else + Run, % """" JumpPaths[k] """" +} +ToolTip +return +; Open in current (or new) Explorer window +!#s:: +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] """" +ToolTip +return +LWin & LShift:: +LShift & LWin:: ; (my CapsLock is mapped to LWin) +PostMessage, 0x50, 2, 0,, A ; WM_INPUTLANGCHANGEREQUEST +Sleep, 100 +ShowLayout() ; display new layout in tray icon +return +#IfWinActive ahk_class Emacs +; RAlt::Alt +#IfWinActive ahk_class ConsoleWindowClass +!F4::WinClose, A +#IfWinActive ahk_exe WINWORD.EXE +XButton1::SendInput, +{F5} ; cycle cursor position backwards +#IfWinActive ahk_class Audition v1.5 ++WheelUp:: +Loop, 30 + SendInput, ^+{Left} +return ++WheelDown:: +Loop, 30 + SendInput, ^+{Right} +return +#IfWinActive ahk_class EVERYTHING +WheelUp::Up +WheelDown::Down +#IfWinActive ahk_class SciTEWindow +F2::Gosub, TrayRebuild ; rebuild scripts.ahk +#IfWinActive ahk_class MozillaWindowClass ++^!+::SendInput, ^!{WheelUp} ++^!-::SendInput, ^!{WheelDown} +!s::SendInput, ^k +F3::SendInput, !{Left} +F4::SendInput, !{Right} +!F1::SendInput, {WheelUp} +!F2::SendInput, {WheelDown} +F1:: +Loop, 5 + SendInput, {WheelUp} +return +F2:: +Loop, 5 + SendInput, {WheelDown} +return +#IfWinActive ahk_class KMeleon Browser Window +F3::SendInput, !{Left} +F4::SendInput, !{Right} +!F1::SendInput, {LAlt Up}{Up} +!F2::SendInput, {LAlt Up}{Down} +F1:: +Loop, 5 + SendInput, {WheelUp} +return +F2:: +Loop, 5 + SendInput, {WheelDown} +return +#IfWinActive ahk_class MediaPlayerClassicW +Esc:: +WinGetPos, x, y, w, h +if (x = 0 and y = 0 and w = A_ScreenWidth and h = A_ScreenHeight) + 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 +MouseGetPos, mx, my +MouseMove, % A_ScreenWidth, % A_ScreenHeight, 0 +KeyWait, RShift +MouseMove, % mx, % my, 0 +return +~LShift:: +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 +KeyWait, LShift +MouseMove, % mx, % my, 0 +SendInput, {LCtrl Down}7{LCtrl Up} +return +#IfWinActive +#IfWinActive ahk_group ExplorerDesktop +; Open new window/command prompt +^n::Run, % "explorer /n,""" ExplorerPath() """" +^p::Run, % "cmd /k cd /d """ ExplorerPath() """" ++^p:: +path := ExplorerPath() +Run, % "C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Visual Studio 2010 Express\Visual Studio Command Prompt (2010).lnk" +WinWait, ahk_class ConsoleWindowClass +SendInput, % "cd " path "{Return}" +return +; Create new folder/file +^+n:: +FileCreateDir, % ExplorerPath() "\New Folder" +SendInput, {F5}New Folder{F2} +return +^!n:: +FileAppend,, % ExplorerPath() "\New Text Document.txt" +SendInput, {F5}New Text Document.txt{F2} +return +; Edit file +#IfWinActive +LWin & LButton:: +MouseGetPos,,, hwnd +DllCall("SetForegroundWindow", "UInt", hwnd) +if (not DoubleClick()) ; see tt.doubleclick.ahk + return +if (not WinActive("ahk_group Explorer")) +{ + SendInput, {Click} + return +} +; fall through to next hotkey +#IfWinActive ahk_group Explorer +#NumPadEnter:: +#Enter:: +i := Explorer().Document.FocusedItem +if (i.IsFolder) + return +ShellApp.ShellExecute(i.path, "", "", "Edit", 1) +return +; Directory navigation +LAlt & Up:: +RAlt & Up:: +e := Explorer() +path := e.Document.Folder.Self.path +if (InStr(path, "::{") = 1) + return +slash := InStr(path, "\", 0, 0) +if (slash = StrLen(path)) + slash := InStr(path, "\", 0, 0, 2) +if (slash = 0) + parent = ::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ; My Computer +else + parent := SubStr(path, 1, slash) +e.Navigate(parent) +return +LAlt & Down:: +RAlt & Down:: +path := ExplorerPath() +if (InStr(path, "::{") = 1) + return +Explorer().Navigate(path) ; go to real path of folder +return +; Toggle hidden status +^h:: +SSF_SHOWALLOBJECTS := 0x0001 +VarSetCapacity(SHELLSTATE, 32, 0) +DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", SSF_SHOWALLOBJECTS, "Int", false) +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 +return +; Sort and display options +^q::ExplorerFolderView("name") +^w::ExplorerFolderView("modified") +^e::ExplorerFolderView("type") +^t::ExplorerFolderView("created") +^g::ExplorerFolderView("groups") +^s::ExplorerFolderView("tiles") +^d::ExplorerFolderView("icons") +^+d::ExplorerFolderView("thumbnails") +^f::ExplorerFolderView("details") +^+f::ExplorerFolderView("list") +^!q::ExplorerFolderView("name", true) +^!w::ExplorerFolderView("modified", true) +^!e::ExplorerFolderView("type", true) +^!t::ExplorerFolderView("created", true) +^!g::ExplorerFolderView("groups", true) +^!s::ExplorerFolderView("tiles", true) +^!d::ExplorerFolderView("icons", true) +^!+d::ExplorerFolderView("thumbnails", true) +^!f::ExplorerFolderView("details", true) +^!+f::ExplorerFolderView("list", true) +#IfWinActive +;§ & LButton::SendInput, {WheelDown} +;§ & RButton::SendInput, {WheelUp} +; <^>!§::SendInput, {Text}§ +#IfWinActive ahk_class PuTTY +PgUp:: +Loop, 5 + SendInput, ^{PgUp} +return +PgDn:: +Loop, 5 + SendInput, ^{PgDn} +return +#IfWinActive ahk_class SUMATRA_PDF_FRAME +PgUp::SendInput, {PgUp} +PgDn::SendInput, {PgDn} +#IfWinActive ahk_class Chrome_WidgetWin_1 +PgUp::SendInput, {PgUp} +PgDn::SendInput, {PgDn} +#IfWinActive +PgUp:: +Loop, 5 + SendInput, {WheelUp} +return +PgDn:: +Loop, 5 + SendInput, {WheelDown} +return +<^>!PgUp::SendInput, {PgUp} +<^>!PgDn::SendInput, {PgDn} +XButton2::SendInput, {XButton2} +XButton2 & WheelUp::SetVolume(GetKeyState("Shift") ? 2 : 1) +XButton2 & WheelDown::SetVolume(GetKeyState("Shift") ? -2 : -1) +RAlt & F6::SetVolume(GetKeyState("Shift") ? 2 : 1) +RAlt & F5::SetVolume(GetKeyState("Shift") ? -2 : -1) +#q::WinSet, Bottom,, A +#a::WinSet, Top,, A +#t::WinSet, AlwaysOnTop, Toggle, A +#y:: +WinGet, t, Transparent, A +if (t = OFF) + WinSet, Transparent, 180, A +else + WinSet, Transparent, OFF, A +return +#b::WinSet, Bottom,, A +#!m::WinMove, A,, 0, 0 +#z::WinMinimize, A +#v:: +WinGet, mm, MinMax, A +if (mm = 1) + WinRestore, A +else + WinMaximize, A +return +#x:: ; minimize all except current +WinGet, hwnd, id, A +WinGet, s, Style, ahk_id %hwnd% +WinSet, Style, -0x20000, ahk_id %hwnd% ; WS_MINIMIZEBOX +WinMinimizeAll +Sleep, 50 +WinSet, Style, % s, ahk_id %hwnd% +WinActivate, ahk_id %hwnd% +WinGet, mm, MinMax, ahk_id %hwnd% +if (mm = -1) + WinRestore, ahk_id %hwnd% +return +#c:: ; minimize last window +SendInput, !{Tab} +Sleep, 50 +WinMinimize, A +return +/* +#!m:: ; fix minimization bug (?) +WinGet, hwnd, id, A +parent := DllCall("GetParent", "uint", hwnd) +WinGet, progman, id, Program Manager ahk_class Progman +DllCall("SetParent", "uint", hwnd, "uint", progman) +DllCall("SetParent", "uint", hwnd, "uint", parent) +return +*/ +/* +#c:: +GWL_HWNDPARENT := -8 +MouseGetPos,,, hwnd +WindowDisabled := hwnd +return +*/ +/* +$!Tab:: +HandleAltTab: +if (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 +if (esc) + SendInput, {Esc} +SendInput, {LAlt Up} +Hotkey, $!Tab, HandleAltTab, On +Hotkey, $!+Tab, HandleAltShiftTab, On +WinSet, Enable,, ahk_id %WindowDisabled% +return +$!+Tab:: +HandleAltShiftTab: +if (WindowDisabled) + WinSet, Disable,, ahk_id %WindowDisabled% +if (WinActive("A") = WindowDisabled) + SendInput, {LAlt Down}{LShift Down}{Tab}{LShift Up}{Tab} +else + 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 +if (esc) + SendInput, {Esc} +SendInput, {LAlt Up} +Hotkey, $!Tab, HandleAltTab, On +Hotkey, $!+Tab, HandleAltShiftTab, On +WinSet, Enable,, ahk_id %WindowDisabled% +return +*/ +^RButton:: +hwndp := WinActive("A") +MouseGetPos,,, hwnd +if (hwnd = hwndp) +{ + WinSet, Top,, A + return +} +DllCall("SetForegroundWindow", "UInt", hwnd) +WinSet, AlwaysOnTop, On, ahk_id %hwndp% +WinSet, AlwaysOnTop, Off, ahk_id %hwndp% +return +#1::FocusButton(1) +#2::FocusButton(2) +#3::FocusButton(3) +#4::FocusButton(4) +#5::FocusButton(5) +#6::FocusButton(6) +#7::FocusButton(7) +#8::FocusButton(8) +#9::FocusButton(9) +#0::FocusButton(10) + +; Miscellaneous + +#Space::CapsLock +#PrintScreen::Media_Prev +#ScrollLock::Media_Play_Pause +#Pause::Media_Next + +#e::Run, % "explorer /n, ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" +#!t::WinSet, AlwaysOnTop,, ahk_class tooltips_class32 ; fix bug + +; Sleep + +^+F12 Up:: +Sleep, 600 +DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) +return + ++F12 Up:: +Sleep, 600 +SendMessage,0x112,0xF170,2,,Program Manager ; turn off monitor +return + +; Library --------------------------------------------------------------------- + +DoubleClick(alternate := false) +{ + + + global DoubleClickClicked + global DoubleClickPriorX + global DoubleClickPriorY + global DoubleClickLast + SysGet, SM_CXDOUBLECLK, 36 + SysGet, SM_CYDOUBLECLK, 37 + max := DllCall("User32\GetDoubleClickTime") + + tmp := A_CoordModeMouse + CoordMode, Mouse, Screen + MouseGetPos, x, y + CoordMode, Mouse, %tmp% + + if (not DoubleClickClicked) + { + 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 + } + + DoubleClickClicked := false + return true +} +env(name) +{ + EnvGet, r, %name% + return r +} +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% +} +LayoutWindowMessage(wParam, lParam) +{ + if (wParam = 4 or wParam = 32772) ; HSHELL_WINDOW_ACTIVATED | HSHELL_RUDEAPPACTIVATED + { + ShowLayout(lParam) + WinSet, AlwaysOnTop, On, OSD + } +} +NotifyIcon(wParam, lParam) +{ + if (lParam = 0x202) ; WM_LBUTTONUP + Run, % "Rundll32 Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}" +} +Explorer(hwnd := "") +{ + 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 +} +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 +} +TrayOpen: +Run, % "explorer " A_ScriptDir "\.." +return +TrayExit: +ExitApp +return +TrayReload: +Reload +return +TrayRebuild: +RunWait, % A_ScriptDir "\..\build" +Reload +return +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) +} +/* +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 +} +*/ +OSD(text) +{ + SetTimer, RemoveOSD, Off + WinSet, AlwaysOnTop, On, OSD + GuiControl, OSD:Text, OSD, %text% + SetTimer, RemoveOSD, 3000 + return +} +RemoveOSD: +SetTimer, RemoveOSD, Off +GuiControl, OSD:Text, OSD, % " " +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") + } +} +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) +} +; https://code.google.com/archive/p/activatebynum/ +Add_hWndToArray(gi, 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 +} +BundleSize(gi) +{ + global + return g_bundleSize%gi% +} +Get_hWndFromArray(gi, wi) +{ + global + return g_hWnd%gi%_%wi% +} +SetButtonTopLeftLoc(gi, x, 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) +} +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 + } +} +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 +} +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 +} + +WindowMessage(wParam, lParam) +{ + global WindowMessageHandlers + for k, v in WindowMessageHandlers + { + %v%(wParam, lParam) + } +} diff --git a/out/sv.ico b/out/sv.ico Binary files differnew file mode 100644 index 0000000..b0b2549 --- /dev/null +++ b/out/sv.ico diff --git a/out/whitesection.bmp b/out/whitesection.bmp Binary files differBinary files differnew file mode 100644 index 0000000..aae32fd --- /dev/null +++ b/out/whitesection.bmp diff --git a/scripts.ahk b/scripts.ahk new file mode 100644 index 0000000..de1fd0b --- /dev/null +++ b/scripts.ahk @@ -0,0 +1,62 @@ +#Include ../lib/Acc.ahk + +; Directives ------------------------------------------------------------------ + +<<directives>> + +#SingleInstance Force +#Persistent +#NoEnv +#WinActivateForce +#MaxHotkeysPerInterval 200 + +; Initialization -------------------------------------------------------------- + +WindowMessageHandlers := [] + +<<init>> + +Gui +LastFound +DllCall("RegisterShellHookWindow", UInt, WinExist()) +msg := DllCall("RegisterWindowMessage", Str, "SHELLHOOK") +OnMessage(msg, "WindowMessage") +return + +; Body ------------------------------------------------------------------------ + +<<body>> + +; Miscellaneous + +#Space::CapsLock +#PrintScreen::Media_Prev +#ScrollLock::Media_Play_Pause +#Pause::Media_Next + +#e::Run, % "explorer /n, ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" +#!t::WinSet, AlwaysOnTop,, ahk_class tooltips_class32 ; fix bug + +; Sleep + +^+F12 Up:: +Sleep, 600 +DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) +return + ++F12 Up:: +Sleep, 600 +SendMessage,0x112,0xF170,2,,Program Manager ; turn off monitor +return + +; Library --------------------------------------------------------------------- + +<<library>> + +WindowMessage(wParam, lParam) +{ + global WindowMessageHandlers + for k, v in WindowMessageHandlers + { + %v%(wParam, lParam) + } +} Binary files differdiff --git a/tt.doubleclick.ahk b/tt.doubleclick.ahk new file mode 100644 index 0000000..0b2454b --- /dev/null +++ b/tt.doubleclick.ahk @@ -0,0 +1,94 @@ +;; DoubleClick function +;; ============================================================================ + +;; DoubleClick returns true if a double click has been performed. The first +;; click in the double click is allowed to pass through, but the second click +;; is prevented. + +;; To use the function, call it whenever the user clicks. The function returns +;; true if two calls in a row meet the requirements for a double click. + +;; Function definition -> library +;; ---------------------------------------------------------------------------- + +;; The 'alternate' argument, if set to true, signifies a right click: + +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 + +;; The DoubleClickClicked variable should be set to false in the beginning of +;; the script: -> init + +DoubleClickClicked := false + +;; We'll continue the definition of the function. -> library + +;; 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") + +;; The current absolute position of the mouse is retrieved: + + 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. + +;; If a click has not already been performed, then this is the first click. +;; 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 + } + +;; 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 + } + +;; 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 +} Binary files differdiff --git a/tt.jump.ahk b/tt.jump.ahk new file mode 100644 index 0000000..4ad0d40 --- /dev/null +++ b/tt.jump.ahk @@ -0,0 +1,48 @@ +;; -> init + +JumpPaths := { s: env("Sync") + , w: env("Sync") "\Projekt\john.ankarstrom.se\htdocs" + , e: env("Personal") + , d: env("Personal") "\Downloads" + , b: "C:\Program Files\KM-Goanna\k-meleon.exe" + , m: "C:\Program Files\Mozilla Thunderbird\thunderbird.exe" } + +;; -> body + +; Open in new Explorer window + +#s:: +ToolTip, ... +SendInput, {Blind}{LWin Up} +Input, k, L1 +if (JumpPaths[k] != "") +{ + if (InStr(FileExist(JumpPaths[k]), "D")) + Run, % "explorer /n, """ JumpPaths[k] """" + else + Run, % """" JumpPaths[k] """" +} +ToolTip +return + +; Open in current (or new) Explorer window + +!#s:: +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] """" +ToolTip +return + +;; -> library + +env(name) +{ + EnvGet, r, %name% + return r +} diff --git a/tt.layout.ahk b/tt.layout.ahk new file mode 100644 index 0000000..4ce61b0 --- /dev/null +++ b/tt.layout.ahk @@ -0,0 +1,72 @@ +;; Quickly change keyboard layout --------------------------------------------- + +;; -> body + +LWin & LShift:: +LShift & LWin:: ; (my CapsLock is mapped to LWin) +PostMessage, 0x50, 2, 0,, A ; WM_INPUTLANGCHANGEREQUEST +Sleep, 100 +ShowLayout() ; display new layout in tray icon +return + +;; Display keyboard layout in tray icon --------------------------------------- + +;; -> init + +layouts := { ru: DllCall("LoadKeyboardLayout", "Str", "00000419", "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% +} + +;; Update layout display on window change ------------------------------------- + +;; -> library + +LayoutWindowMessage(wParam, lParam) +{ + if (wParam = 4 or wParam = 32772) ; HSHELL_WINDOW_ACTIVATED | HSHELL_RUDEAPPACTIVATED + { + ShowLayout(lParam) + WinSet, AlwaysOnTop, On, OSD + } +} + +;; -> init + +WindowMessageHandlers.Push("LayoutWindowMessage") + +;; Click tray icon to open Text Services and Input Languages ------------------ + +;; -> init + +OnMessage(0x404, "NotifyIcon") + +;; -> library + +NotifyIcon(wParam, lParam) +{ + 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 new file mode 100644 index 0000000..e0e7c8e --- /dev/null +++ b/tt.programs.ahk @@ -0,0 +1,100 @@ +;; Program shortcuts ---------------------------------------------------------- + +;; -> body + +#IfWinActive ahk_class Emacs + +; RAlt::Alt + +#IfWinActive ahk_class ConsoleWindowClass + +!F4::WinClose, A + +#IfWinActive ahk_exe WINWORD.EXE + +XButton1::SendInput, +{F5} ; cycle cursor position backwards + +#IfWinActive ahk_class Audition v1.5 + ++WheelUp:: +Loop, 30 + SendInput, ^+{Left} +return + ++WheelDown:: +Loop, 30 + SendInput, ^+{Right} +return + +#IfWinActive ahk_class EVERYTHING + +WheelUp::Up +WheelDown::Down + +#IfWinActive ahk_class SciTEWindow + +F2::Gosub, TrayRebuild ; rebuild scripts.ahk + +#IfWinActive ahk_class MozillaWindowClass + ++^!+::SendInput, ^!{WheelUp} ++^!-::SendInput, ^!{WheelDown} +!s::SendInput, ^k +F3::SendInput, !{Left} +F4::SendInput, !{Right} +!F1::SendInput, {WheelUp} +!F2::SendInput, {WheelDown} +F1:: +Loop, 5 + SendInput, {WheelUp} +return +F2:: +Loop, 5 + SendInput, {WheelDown} +return + +#IfWinActive ahk_class KMeleon Browser Window + +F3::SendInput, !{Left} +F4::SendInput, !{Right} +!F1::SendInput, {LAlt Up}{Up} +!F2::SendInput, {LAlt Up}{Down} +F1:: +Loop, 5 + SendInput, {WheelUp} +return +F2:: +Loop, 5 + SendInput, {WheelDown} +return + +#IfWinActive ahk_class MediaPlayerClassicW + +Esc:: +WinGetPos, x, y, w, h +if (x = 0 and y = 0 and w = A_ScreenWidth and h = A_ScreenHeight) + 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 +MouseGetPos, mx, my +MouseMove, % A_ScreenWidth, % A_ScreenHeight, 0 +KeyWait, RShift +MouseMove, % mx, % my, 0 +return + +~LShift:: +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 +KeyWait, LShift +MouseMove, % mx, % my, 0 +SendInput, {LCtrl Down}7{LCtrl Up} +return + +#IfWinActive diff --git a/tt.programs.explorer.ahk b/tt.programs.explorer.ahk new file mode 100644 index 0000000..8e2e659 --- /dev/null +++ b/tt.programs.explorer.ahk @@ -0,0 +1,197 @@ +;; -> init + +ShellApp := ComObjCreate("Shell.Application") +GroupAdd, Explorer, ahk_class CabinetWClass +GroupAdd, Explorer, ahk_class ExploreWClass +GroupAdd, Desktop, ahk_class Progman +GroupAdd, Desktop, ahk_class WorkerW +GroupAdd, ExplorerDesktop, ahk_class CabinetWClass +GroupAdd, ExplorerDesktop, ahk_class ExploreWClass +GroupAdd, ExplorerDesktop, ahk_class Progman +GroupAdd, ExplorerDesktop, ahk_class WorkerW + +;; -> library + +Explorer(hwnd := "") +{ + 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 +} + +;; -> body + +;; Explorer/Desktop hotkeys --------------------------------------------------- + +#IfWinActive ahk_group ExplorerDesktop + +; Open new window/command prompt + +^n::Run, % "explorer /n,""" ExplorerPath() """" +^p::Run, % "cmd /k cd /d """ ExplorerPath() """" + ++^p:: +path := ExplorerPath() +Run, % "C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Visual Studio 2010 Express\Visual Studio Command Prompt (2010).lnk" +WinWait, ahk_class ConsoleWindowClass +SendInput, % "cd " path "{Return}" +return + +; Create new folder/file + +^+n:: +FileCreateDir, % ExplorerPath() "\New Folder" +SendInput, {F5}New Folder{F2} +return + +^!n:: +FileAppend,, % ExplorerPath() "\New Text Document.txt" +SendInput, {F5}New Text Document.txt{F2} +return + +;; Explorer hotkeys ----------------------------------------------------------- + +; Edit file + +#IfWinActive + +LWin & LButton:: +MouseGetPos,,, hwnd +DllCall("SetForegroundWindow", "UInt", hwnd) +if (not DoubleClick()) ; see tt.doubleclick.ahk + return +if (not WinActive("ahk_group Explorer")) +{ + SendInput, {Click} + return +} +; fall through to next hotkey + +#IfWinActive ahk_group Explorer + +#NumPadEnter:: +#Enter:: +i := Explorer().Document.FocusedItem +if (i.IsFolder) + return +ShellApp.ShellExecute(i.path, "", "", "Edit", 1) +return + +; Directory navigation + +LAlt & Up:: +RAlt & Up:: +e := Explorer() +path := e.Document.Folder.Self.path +if (InStr(path, "::{") = 1) + return +slash := InStr(path, "\", 0, 0) +if (slash = StrLen(path)) + slash := InStr(path, "\", 0, 0, 2) +if (slash = 0) + parent = ::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ; My Computer +else + parent := SubStr(path, 1, slash) +e.Navigate(parent) +return + +LAlt & Down:: +RAlt & Down:: +path := ExplorerPath() +if (InStr(path, "::{") = 1) + return +Explorer().Navigate(path) ; go to real path of folder +return + +; Toggle hidden status + +^h:: +SSF_SHOWALLOBJECTS := 0x0001 +VarSetCapacity(SHELLSTATE, 32, 0) +DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", SSF_SHOWALLOBJECTS, "Int", false) +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 +return + +; Sort and display options + +^q::ExplorerFolderView("name") +^w::ExplorerFolderView("modified") +^e::ExplorerFolderView("type") +^t::ExplorerFolderView("created") +^g::ExplorerFolderView("groups") +^s::ExplorerFolderView("tiles") +^d::ExplorerFolderView("icons") +^+d::ExplorerFolderView("thumbnails") +^f::ExplorerFolderView("details") +^+f::ExplorerFolderView("list") + +^!q::ExplorerFolderView("name", true) +^!w::ExplorerFolderView("modified", true) +^!e::ExplorerFolderView("type", true) +^!t::ExplorerFolderView("created", true) +^!g::ExplorerFolderView("groups", true) +^!s::ExplorerFolderView("tiles", true) +^!d::ExplorerFolderView("icons", true) +^!+d::ExplorerFolderView("thumbnails", true) +^!f::ExplorerFolderView("details", true) +^!+f::ExplorerFolderView("list", true) + +#IfWinActive + +;; -> library + +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 +} diff --git a/tt.scroll.ahk b/tt.scroll.ahk new file mode 100644 index 0000000..44e1a26 --- /dev/null +++ b/tt.scroll.ahk @@ -0,0 +1,46 @@ +;; -> body + +;; TODO: Check how far up/down window cursor is +;; (but let perhaps the top 30-40% give the same scroll) + +;§ & LButton::SendInput, {WheelDown} +;§ & RButton::SendInput, {WheelUp} + +; <^>!§::SendInput, {Text}§ + +#IfWinActive ahk_class PuTTY + +PgUp:: +Loop, 5 + SendInput, ^{PgUp} +return + +PgDn:: +Loop, 5 + SendInput, ^{PgDn} +return + +#IfWinActive ahk_class SUMATRA_PDF_FRAME + +PgUp::SendInput, {PgUp} +PgDn::SendInput, {PgDn} + +#IfWinActive ahk_class Chrome_WidgetWin_1 + +PgUp::SendInput, {PgUp} +PgDn::SendInput, {PgDn} + +#IfWinActive + +PgUp:: +Loop, 5 + SendInput, {WheelUp} +return + +PgDn:: +Loop, 5 + SendInput, {WheelDown} +return + +<^>!PgUp::SendInput, {PgUp} +<^>!PgDn::SendInput, {PgDn} diff --git a/tt.traymenu.ahk b/tt.traymenu.ahk new file mode 100644 index 0000000..bb32664 --- /dev/null +++ b/tt.traymenu.ahk @@ -0,0 +1,29 @@ +;; Tray menu ------------------------------------------------------------------ + +;; -> init + +Menu, Tray, NoStandard +Menu, Tray, Tip, %A_ScriptName% +Menu, Tray, Add, &Open directory..., TrayOpen +Menu, Tray, Add, Re&build..., TrayRebuild +Menu, Tray, Add, &Reload, TrayReload +Menu, Tray, Add, E&xit, TrayExit + +;; -> library + +TrayOpen: +Run, % "explorer " A_ScriptDir "\.." +return + +TrayExit: +ExitApp +return + +TrayReload: +Reload +return + +TrayRebuild: +RunWait, % A_ScriptDir "\..\build" +Reload +return diff --git a/tt.volume.ahk b/tt.volume.ahk new file mode 100644 index 0000000..59d16a7 --- /dev/null +++ b/tt.volume.ahk @@ -0,0 +1,93 @@ +;; Volume adjustment ---------------------------------------------------------- + +;; -> body + +XButton2::SendInput, {XButton2} +XButton2 & WheelUp::SetVolume(GetKeyState("Shift") ? 2 : 1) +XButton2 & WheelDown::SetVolume(GetKeyState("Shift") ? -2 : -1) + +RAlt & F6::SetVolume(GetKeyState("Shift") ? 2 : 1) +RAlt & F5::SetVolume(GetKeyState("Shift") ? -2 : -1) + +;; -> library + +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) +} + +/* + +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 +} + +*/ + +;; On-screen display ---------------------------------------------------------- + +;; -> init + +Gui, OSD:+AlwaysOnTop +LastFound +Owner +Disabled -Caption +Gui, OSD:Color, FFFFFF +Gui, OSD:Font, s30, VCR OSD Mono +Gui, OSD:Add, Text, vOSD c00BB00, % " " +WinSet, TransColor, FFFFFF 250 +y := A_ScreenHeight - 100 +Gui, OSD:Show, x0 y%y% AutoSize NA, OSD + +;; -> library + +OSD(text) +{ + SetTimer, RemoveOSD, Off + WinSet, AlwaysOnTop, On, OSD + GuiControl, OSD:Text, OSD, %text% + SetTimer, RemoveOSD, 3000 + return +} + +RemoveOSD: +SetTimer, RemoveOSD, Off +GuiControl, OSD:Text, OSD, % " " +return diff --git a/tt.windows.ahk b/tt.windows.ahk new file mode 100644 index 0000000..b8eb857 --- /dev/null +++ b/tt.windows.ahk @@ -0,0 +1,173 @@ +;; Window management ---------------------------------------------------------- + +;; -> init + +GroupAdd, WindowsExplorer, ahk_class CabinetWClass +GroupAdd, WindowsExplorer, ahk_class ExploreWClass + +Gui, FakeWindow:+LastFound +Owner +Disabled -Caption +Gui, +hwndFakeWindowHwnd +y := A_ScreenHeight - 100 +Gui, FakeWindow:Show, x0 y%y% AutoSize NA, FakeWindow + +;; -> body + +#q::WinSet, Bottom,, A +#a::WinSet, Top,, A +#t::WinSet, AlwaysOnTop, Toggle, A +#y:: +WinGet, t, Transparent, A +if (t = OFF) + WinSet, Transparent, 180, A +else + WinSet, Transparent, OFF, A +return +#b::WinSet, Bottom,, A +#!m::WinMove, A,, 0, 0 + +#z::WinMinimize, A +#v:: +WinGet, mm, MinMax, A +if (mm = 1) + WinRestore, A +else + WinMaximize, A +return + +#x:: ; minimize all except current +WinGet, hwnd, id, A +WinGet, s, Style, ahk_id %hwnd% +WinSet, Style, -0x20000, ahk_id %hwnd% ; WS_MINIMIZEBOX +WinMinimizeAll +Sleep, 50 +WinSet, Style, % s, ahk_id %hwnd% +WinActivate, ahk_id %hwnd% +WinGet, mm, MinMax, ahk_id %hwnd% +if (mm = -1) + WinRestore, ahk_id %hwnd% +return + +#c:: ; minimize last window +SendInput, !{Tab} +Sleep, 50 +WinMinimize, A +return + + +;; -> body + +/* +#!m:: ; fix minimization bug (?) +WinGet, hwnd, id, A +parent := DllCall("GetParent", "uint", hwnd) +WinGet, progman, id, Program Manager ahk_class Progman +DllCall("SetParent", "uint", hwnd, "uint", progman) +DllCall("SetParent", "uint", hwnd, "uint", parent) +return +*/ + +/* +#c:: +GWL_HWNDPARENT := -8 +MouseGetPos,,, hwnd +WindowDisabled := hwnd +return +*/ + +/* +$!Tab:: +HandleAltTab: +if (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 +if (esc) + SendInput, {Esc} +SendInput, {LAlt Up} +Hotkey, $!Tab, HandleAltTab, On +Hotkey, $!+Tab, HandleAltShiftTab, On +WinSet, Enable,, ahk_id %WindowDisabled% +return + +$!+Tab:: +HandleAltShiftTab: +if (WindowDisabled) + WinSet, Disable,, ahk_id %WindowDisabled% +if (WinActive("A") = WindowDisabled) + SendInput, {LAlt Down}{LShift Down}{Tab}{LShift Up}{Tab} +else + 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 +if (esc) + SendInput, {Esc} +SendInput, {LAlt Up} +Hotkey, $!Tab, HandleAltTab, On +Hotkey, $!+Tab, HandleAltShiftTab, On +WinSet, Enable,, ahk_id %WindowDisabled% +return +*/ + +^RButton:: +hwndp := WinActive("A") +MouseGetPos,,, hwnd +if (hwnd = hwndp) +{ + WinSet, Top,, A + return +} +DllCall("SetForegroundWindow", "UInt", hwnd) +WinSet, AlwaysOnTop, On, ahk_id %hwndp% +WinSet, AlwaysOnTop, Off, ahk_id %hwndp% +return + +;; Fix inconsistent z-order after minimization via taskbar -------------------- + +;; -> library + +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") + } +} + +;; -> init + +WindowMessageHandlers.Push("WindowsWindowMessage") + +;; Change the position of a given window in the z-order ----------------------- + +;; -> library + +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) +} diff --git a/tt.windowselect.ahk b/tt.windowselect.ahk new file mode 100644 index 0000000..ba9abb5 --- /dev/null +++ b/tt.windowselect.ahk @@ -0,0 +1,202 @@ +;; Select window by number ---------------------------------------------------- + +;; -> body + +#1::FocusButton(1) +#2::FocusButton(2) +#3::FocusButton(3) +#4::FocusButton(4) +#5::FocusButton(5) +#6::FocusButton(6) +#7::FocusButton(7) +#8::FocusButton(8) +#9::FocusButton(9) +#0::FocusButton(10) + +;; -> library + +; https://code.google.com/archive/p/activatebynum/ + +Add_hWndToArray(gi, 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 +} + +BundleSize(gi) +{ + global + return g_bundleSize%gi% +} + +Get_hWndFromArray(gi, wi) +{ + global + return g_hWnd%gi%_%wi% +} + +SetButtonTopLeftLoc(gi, x, 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) +} + +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 + } +} + +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 +} + +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 +} diff --git a/whitesection.bmp b/whitesection.bmp Binary files differnew file mode 100644 index 0000000..aae32fd --- /dev/null +++ b/whitesection.bmp |