屏幕键盘 v1.5

许多实用脚本和封装函数, 可以让您编写脚本更加便捷高效
feiyue
Posts: 130
Joined: 08 Aug 2014, 04:08

屏幕键盘 v1.5

26 Oct 2018, 00:30

写了个简单的屏幕键盘,可以加入到开机启动脚本中,希望大家喜欢!

Code: Select all

/*
--------------------------------
  屏幕键盘() v1.5  By FeiYue

  这是一个类似 WinXP 屏幕键盘的小工具,

  写成函数形式,便于在其他脚本中调用。
--------------------------------
*/

屏幕键盘()

屏幕键盘() {

  static NewName:={ "":"Space", Caps:"CapsLock"
     , App:"AppsKey", Psc:"PrintScreen", Slk:"ScrollLock"
     , "↑":"Up", "↓":"Down", "←":"Left", "→":"Right" }
  w1:=45, h1:=30, w2:=60, 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"]
     ,["Psc",w2,10],["Slk",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
  Gui, OSK: +AlwaysOnTop +Owner +E0x08000000 ; +E0x08000000 点击不激活
  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% h%h1% -Wrap gRunOSK, % v.1
    }
  }
  Gui, OSK: Show, NA, 屏幕键盘
  return

  OSKGuiClose:
  Gui, OSK: Destroy
  return

  RunOSK:
  k:=A_GuiControl
  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
}

;

Return to “脚本函数”

Who is online

Users browsing this forum: No registered users and 1 guest