600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 用热键win+字母激活任务栏上的按钮[ahk]

用热键win+字母激活任务栏上的按钮[ahk]

时间:2022-01-14 12:38:02

相关推荐

用热键win+字母激活任务栏上的按钮[ahk]

;bug:热键请自行修改,发现按win+d win+l 等和系统热键冲突,可以改成空格键或Capslock键+字母

; File encoding: UTF-8;/liuyukuan/article/details/8349832AutoHotkey 版本: 1.0.9.1操作系统: Windows XP作者: sunwind <1576157@>博客: /liuyukuan脚本说明:Quick task switching with Win+[a,b,...,z]脚本版本: v1.0Timestamp:-12-20 14:12:56*/;改版by sunwind:;~ 按win+-显示任务栏上按钮标号;~ 标号是用字母标识;~ 按win+字母 切换;~ 原版:;Quick task switching with Win+[1,2,...,0];Win + 数字键 切换,用 Win - 可能看到任务栏标号,然后再 Win + 数字 切换;/forum/viewtopic.php?t=41542&highlight=taskbar+order+switch#SingleInstance#WinActivateForceBuild_hWndArray(26)Loop %g_bundleCount%{sym:=Chr(A_Index+96)Hotkey, #%sym%, %sym%}Returna:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnb:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnc:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnd:n:=Asc(A_ThisLabel)-96FocusButton(n)Returne:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnf:n:=Asc(A_ThisLabel)-96FocusButton(n)Returng:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnh:n:=Asc(A_ThisLabel)-96FocusButton(n)Returni:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnj:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnk:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnl:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnm:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnn:n:=Asc(A_ThisLabel)-96FocusButton(n)Returno:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnp:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnq:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnr:n:=Asc(A_ThisLabel)-96FocusButton(n)Returns:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnt:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnu:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnv:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnw:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnx:n:=Asc(A_ThisLabel)-96FocusButton(n)Returny:n:=Asc(A_ThisLabel)-96FocusButton(n)Returnz:n:=Asc(A_ThisLabel)-96FocusButton(n)Return;WIN+- shows button numbers as tooltips.#-::#NumpadSub::ShowToolTips()SetTimer, RemoveToolTips, -1000ReturnRemoveToolTips:Loop, 12ToolTip,,,,%A_Index%ReturnShowToolTips(){global g_bundleCountCoordMode, ToolTip, ScreenLoop, %g_bundleCount%{;~ If A_Index < 5;~ continuex := g_xs%A_Index%y := g_ys%A_Index%;~ If A_Index = 10;~ text = 0;~ Else;~ text = %A_Index%text:=Chr(A_Index+96)ToolTip, %text%, %x%, %y%, %A_Index%}}Add_hWndToArray(gi, hWnd){globalg_bundleSize%gi% := g_bundleSize%gi% + 1local wi := g_bundleSize%gi%g_hWnd%gi%_%wi% := hWnd}AddBundle(gi){globalg_bundleSize%gi% := 0}BundleSize(gi){globalReturn g_bundleSize%gi%}Get_hWndFromArray(gi, wi){globalReturn g_hWnd%gi%_%wi%}SetButtonTopLeftLoc(gi, x, y){globalg_xs%gi% := xg_ys%gi% := y}Build_hWndArray(maxBundleCount){global g_bundleCountWinGet,pidTaskbar, PID, ahk_class Shell_TrayWndhProc := 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_ButtonCountButtonCount := ErrorLevelg_bundleCount := 0Loop, %ButtonCount%{SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETButtonVarSetCapacity(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 dwDatadwData := 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%BreakHidden := Statyle & 0x08 ; TBSTATE_HiddenIf Not Hidden{grpCollapsed := trueg_bundleCount := g_bundleCount + 1AddBundle(g_bundleCount)GetTaskbarButtonTopLeft(idn, x, y)SetButtonTopLeftLoc(g_bundleCount, x, y)}ElsegrpCollapsed := false}Else ; actual window Button{If grpCollapsed{Add_hWndToArray(g_bundleCount, hWnd)}Else{g_bundleCount := g_bundleCount + 1AddBundle(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; inaccuracystatic prevBundleIndex := 0static prevWindowIndex := 0Build_hWndArray(n)If (g_bundleCount >= n){bundleSize := BundleSize(n)If n = %prevBundleIndex%windowIndex := Mod(prevWindowIndex, bundleSize) + 1ElsewindowIndex := 1hWnd := Get_hWndFromArray(n, windowIndex)If bundleSize > 1 ; cycle through windows in the same bundleWinActivate, ahk_id %hWnd%Else ; Single-window bundle; Toggles Between activating (restoring) and minimizing the windowIfWinActive, ahk_id %hWnd%WinMinimize, ahk_id %hWnd%ElseWinActivate, ahk_id %hWnd%prevBundleIndex := nprevWindowIndex := windowIndex}}GetTaskSwBar(){ControlGet, hParent, hWnd,, MSTaskSwWClass1 , ahk_class Shell_TrayWndControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%Loop{ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWndIf Not hWndBreakElse If hWnd = %hChild%{idxTB := A_IndexBreak}}ReturnidxTB}GetTaskbarButtonTopLeft(id, ByRef x, ByRef y){idxTB := GetTaskSwBar()WinGet,pidTaskbar, PID, ahk_class Shell_TrayWndhProc := 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_TrayWndWinGetPos, 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 + lefty := y + top}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。