; 屏幕键盘 —— OSK() v2.0 By FeiYue ; 这是一个类似 Windows 屏幕键盘的小工具 OSK() OSK(f="") { static myid, ShowOSK:=Func("OSK").Bind("") , RunOSK:=Func("OSK").Bind("RunOSK") , NewName:={ "":"Space", Caps:"CapsLock" , App:"AppsKey", PrScn:"PrintScreen", ScrLk:"ScrollLock" , "↑":"Up", "↓":"Down", "←":"Left", "→":"Right" } if (f="MouseIsOver") { MouseGetPos,,, id return (id=myid) } else if (f="HotkeyOn" or f="HotkeyOff") { #If OSK("MouseIsOver") #IF Hotkey, If, OSK("MouseIsOver") Hotkey, $*LButton, %RunOSK%, % InStr(f,"On")?"On":"Off" Hotkey If return } else if (f="RunOSK") { MouseGetPos,,, id, cid, 2 if (id!=myid) return if (cid="") { WinGetPos, wx, wy, ww,, ahk_id %myid% CoordMode, Mouse MouseGetPos, x1, y1 KeyWait, LButton if (x1>wx+ww-60 and x1<wx+ww and y1>wy and y1<wy+30) { Gui, OSK: Destroy OSK("HotkeyOff") return } MouseGetPos, x2, y2 WinMove, ahk_id %myid%,, wx+x2-x1, wy+y2-y1 return } SendLevel, 1 ControlGetText, k,, ahk_id %cid% if k in Shift,Ctrl,Win,Alt { v:=k="Win" ? "LWin" : k GuiControlGet, isEnabled, OSK: Enabled, %k% GuiControl, OSK: Disable%isEnabled%, %k% if (!isEnabled) SendInput, {Blind}{%v%} return } s:=InStr(k," ") ? SubStr(k,0) : k s:=(v:=NewName[s]) ? v : s, s:="{" s "}" For i,k in StrSplit("Shift,Ctrl,Win,Alt", ",") { GuiControlGet, isEnabled, OSK: Enabled, %k% if (!isEnabled) { GuiControl, OSK: Enable, %k% v:=k="Win" ? "LWin" : k s={%v% Down}%s%{%v% Up} } } SendInput, {Blind}%s% return } else if (f!="") return ; Keyboard layout: [keyname, width, spacing] w1:=40, w2:=55, w3:=w1*14+2*13 s1:=[ ["Esc"],["F1",,w3-w1*13-15*2-2*9],["F2"],["F3"],["F4"],["F5",,15] ,["F6"],["F7"],["F8"],["F9",,15],["F10"],["F11"],["F12"] ,["PrScn",w2,10],["ScrLk",w2],["Pause",w2] ] s2:=[ ["~ ``"],["! 1"],["@ 2"],["# 3"],["$ 4"],["% 5"],["^ 6"] ,["&& 7"],["* 8"],["( 9"],[") 0"],["_ -"],["+ ="],["BS"] ,["Ins",w2,10],["Home",w2],["PgUp",w2] ] s3:=[ ["Tab"],["q"],["w"],["e"],["r"],["t"],["y"] ,["u"],["i"],["o"],["p"],["{ ["],["} ]"],["| \"] ,["Del",w2,10],["End",w2],["PgDn",w2] ] s4:=[ ["Caps",w2],["a"],["s"],["d"],["f"],["g"],["h"] ,["j"],["k"],["l"],[": `;"],[""" '"],["Enter",w3-w1*11-w2-2*12] ] s5:=[ ["Shift",w1*2],["z"],["x"],["c"],["v"],["b"] ,["n"],["m"],["< ,"],["> ."],["? /"],["Shift",w3-w1*12-2*11] ,["↑",w2,10+w2+2] ] s6:=[ ["Ctrl",w2],["Win",w2],["Alt",w2],["",w3-w2*7-2*7] ,["Alt",w2],["Win",w2],["App",w2],["Ctrl",w2] ,["←",w2,10],["↓",w2],["→",w2] ] Gui, OSK: Destroy ; +E0x08000000 Click not to activate Gui, OSK: +AlwaysOnTop +Owner +E0x08000000 +Hwndmyid Gui, OSK: Font, s12, Verdana Gui, OSK: Margin, 10, 10 Gui, OSK: Color, DDEEFF Loop, 6 { if (A_Index<=2) j= For i,v in s%A_Index% { w:=v.2 ? v.2 : w1, d:=v.3 ? v.3 : 2 j:=j="" ? "xm" : i=1 ? "xm y+2" : "x+" d Gui, OSK: Add, Button, %j% w%w% r0.8 -Wrap, % v.1 } } Gui, OSK: Show, NA, On-Screen Keyboard OSK("HotkeyOn") Try Menu, Tray, Delete, OSK Menu, Tray, Add, OSK, %ShowOSK% Menu, Tray, Default, OSK Menu, Tray, Click, 1 return } ;
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)