找回密码
 加入
搜索
查看: 2027|回复: 2

[系统综合] 这个虚拟键盘能做成自定义函数或插件吗?

[复制链接]
发表于 2016-12-19 13:03:40 | 显示全部楼层 |阅读模式
本帖最后由 cashiba 于 2016-12-19 13:05 编辑

在网上看到一段虚拟键盘的代码,经测试可用。
在论坛里搜了一下,曾经有人发过,不过要花钱下载。
1、界面不算流畅,布局有点拥挤
2、如果能做成一个自定义函数或插件就好了,可以在需要的时候给呼出来.....
AU3基础差,能力不足,不会修改。发出来给需要的、感兴趣的.....。免币。
  1. #NoTrayIcon
  2. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  3. #AutoIt3Wrapper_Icon=1295599487_Gnome-Input-Keyboard-64.ico
  4. #AutoIt3Wrapper_OutFile=Virtual_Keyboard.exe
  5. #AutoIt3Wrapper_Compression=4
  6. #AutoIt3Wrapper_Res_Description=Virtual Keyboard with Anti - KeyLogger
  7. #AutoIt3Wrapper_Res_FileVersion=1.1.0.6
  8. #AutoIt3Wrapper_Res_Language=1033
  9. #AutoIt3Wrapper_Res_Field=ProductName|Virtual Keyboard with Anti - KeyLogger
  10. #AutoIt3Wrapper_Res_Field=InternalName|VirtualKeyboard.exe
  11. #AutoIt3Wrapper_Res_Field=ProductVersion|1.1.0.6
  12. #AutoIt3Wrapper_Res_Field=OriginalFilename|VirtualKeyboard.exe
  13. #AutoIt3Wrapper_Run_Tidy=y
  14. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

  15. #include <ButtonConstants.au3>
  16. #include <GUIConstantsEx.au3>
  17. #include <WindowsConstants.au3>
  18. #include <StaticConstants.au3>
  19. #include <Array.au3>
  20. #include <WinAPI.au3>
  21. #include <IE.au3>

  22. Opt("WinWaitDelay", 0)
  23. Opt("SendKeyDelay", 0)
  24. Opt("SendKeyDownDelay", 0)
  25. Opt("Sendcapslockmode", 0)
  26. Opt("TrayIconHide", 1)
  27. Opt("GUICloseOnESC", 0)

  28. Global $fLeftShiftHolden = False
  29. Global $fLeftAltHolden = False
  30. Global $fLeftCtrlHolden = False
  31. Global $fRightShiftHolden = False
  32. Global $fRightAltHolden = False
  33. Global $fRightCtrlHolden = False
  34. Global Const $VK_NUMLOCK = 0x90
  35. Global Const $VK_SCROLL = 0x91
  36. Global Const $VK_CAPITAL = 0x14
  37. Global $ctrlstatus = 0, $altstatus = 0, $shiftstatus = 0
  38. ;
  39. Global $_NOACTIVATE = 0x08000000
  40. Global $MA_NOACTIVATE = 3
  41. Global $MA_NOACTIVATEANDEAT = 4
  42. Global $keyStroke_Array[68] = ['{SPACE}', '{ENTER}', '{ALT}', '{BS}', '{BACKSPACE}', '{DEL}', '{UP}', '{DOWN}', _
  43.                 '{LEFT}', '{RIGHT}', '{HOME}', '{END}', '{ESC}', '{INS}', '{PGUP}', '{PGDN}', '{F1}', '{F2}', '{F3}', _
  44.                 '{F4}', '{F5}', '{F6}', '{F7}', '{F8}', '{F9}', '{F10}', '{F11}', '{F12}', '{TAB}', '{PRINTSCREEN}', '{LWIN}', _
  45.                 '{RWIN}', '{BREAK}', '{PAUSE}', '{NUMPADMULT}', '{NUMPADADD}', '{NUMPADSUB}', '{NUMPADDIV}', '{NUMPADDOT}', _
  46.                 '{NUMPADENTER}', '{APPSKEY}', '{LALT}', '{RALT}', '{LCTRL}', '{RCTRL}', '{LSHIFT}', '{RSHIFT}', '{SLEEP}', _
  47.                 '{NUMPAD0}', '{NUMPAD1}', '{NUMPAD2}', '{NUMPAD3}', '{NUMPAD4}', '{NUMPAD5}', '{NUMPAD6}', '{NUMPAD7}', _
  48.                 '{NUMPAD8}', '{NUMPAD9}', '{ALTDOWN}', '{SHIFTDOWN}', '{CTRLDOWN}', '{ALTUP}', '{CTRLUP}', '{SHIFTUP}', '{CAPSLOCK}', _
  49.                 '{INSERT}', '{DELETE}', '{Escape}']

  50. _ArraySort($keyStroke_Array)

  51. HotKeySet("{Esc}", "Quit")

  52. $ProductVersion = "v0.1"
  53. $MainGUITitle = "Virtual Keyboard " & $ProductVersion & " - "
  54. $Form1 = GUICreate($MainGUITitle, 722, 194, 300, 300, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $_NOACTIVATE)) ;$WS_POPUPWINDOW;BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
  55. $Esc = GUICtrlCreateButton("Esc", 0, 0, 33, 25, $WS_GROUP)
  56. $F1 = GUICtrlCreateButton("F1", 48, 0, 33, 25, $WS_GROUP)
  57. $F2 = GUICtrlCreateButton("F2", 80, 0, 33, 25, $WS_GROUP)
  58. $F3 = GUICtrlCreateButton("F3", 112, 0, 33, 25, $WS_GROUP)
  59. $F4 = GUICtrlCreateButton("F4", 144, 0, 33, 25, $WS_GROUP)
  60. $F5 = GUICtrlCreateButton("F5", 184, 0, 33, 25, $WS_GROUP)
  61. $F6 = GUICtrlCreateButton("F6", 216, 0, 33, 25, $WS_GROUP)
  62. $F7 = GUICtrlCreateButton("F7", 248, 0, 33, 25, $WS_GROUP)
  63. $F8 = GUICtrlCreateButton("F8", 280, 0, 33, 25, $WS_GROUP)
  64. $F9 = GUICtrlCreateButton("F9", 320, 0, 33, 25, $WS_GROUP)
  65. $F10 = GUICtrlCreateButton("F10", 352, 0, 33, 25, $WS_GROUP)
  66. $F11 = GUICtrlCreateButton("F11", 385, 0, 33, 25, $WS_GROUP)
  67. $F12 = GUICtrlCreateButton("F12", 417, 0, 33, 25, $WS_GROUP)
  68. $PrintScreen = GUICtrlCreateButton("prtscr", 488, 0, 33, 25, $WS_GROUP)
  69. $ScrollLock = GUICtrlCreateButton("scr lo", 520, 0, 33, 25, $WS_GROUP)
  70. $PauseBreak = GUICtrlCreateButton("pa br", 552, 0, 33, 25, $WS_GROUP)
  71. $Igel = GUICtrlCreateButton("`", 0, 32, 33, 33, $WS_GROUP)
  72. $One = GUICtrlCreateButton("1", 32, 32, 33, 33, $WS_GROUP)
  73. $Two = GUICtrlCreateButton("2", 64, 32, 33, 33, $WS_GROUP)
  74. $Three = GUICtrlCreateButton("3", 96, 32, 33, 33, $WS_GROUP)
  75. $Four = GUICtrlCreateButton("4", 128, 32, 33, 33, $WS_GROUP)
  76. $Five = GUICtrlCreateButton("5", 160, 32, 33, 33, $WS_GROUP)
  77. $Six = GUICtrlCreateButton("6", 192, 32, 33, 33, $WS_GROUP)
  78. $Seven = GUICtrlCreateButton("7", 224, 32, 33, 33, $WS_GROUP)
  79. $Eight = GUICtrlCreateButton("8", 256, 32, 33, 33, $WS_GROUP)
  80. $Nine = GUICtrlCreateButton("9", 288, 32, 33, 33, $WS_GROUP)
  81. $Zero = GUICtrlCreateButton("0", 320, 32, 33, 33, $WS_GROUP)
  82. $Minus = GUICtrlCreateButton("-", 352, 32, 33, 33, $WS_GROUP)
  83. $Equal = GUICtrlCreateButton("=", 384, 32, 33, 33, $WS_GROUP)
  84. $Back = GUICtrlCreateButton("<-------", 416, 32, 65, 33, $WS_GROUP)
  85. $Insert = GUICtrlCreateButton("Insert", 488, 32, 33, 33, $WS_GROUP)
  86. $Home = GUICtrlCreateButton("Home", 520, 32, 33, 33, $WS_GROUP)
  87. $PageUp = GUICtrlCreateButton("PgUp", 552, 32, 33, 33, $WS_GROUP)
  88. $NumberLock = GUICtrlCreateButton("NmLo", 592, 32, 33, 33, $WS_GROUP)
  89. $NumberPadSlash = GUICtrlCreateButton("/", 624, 32, 33, 33, $WS_GROUP)
  90. $NumberPadX = GUICtrlCreateButton("*", 656, 32, 33, 33, $WS_GROUP)
  91. $NumberPadMinus = GUICtrlCreateButton("-", 688, 32, 33, 33, $WS_GROUP)
  92. $Tab = GUICtrlCreateButton("Tab", 0, 64, 41, 33, $WS_GROUP)
  93. $q = GUICtrlCreateButton("Q", 40, 64, 33, 33, $WS_GROUP)
  94. $w = GUICtrlCreateButton("W", 72, 64, 33, 33, $WS_GROUP)
  95. $e = GUICtrlCreateButton("E", 104, 64, 33, 33, $WS_GROUP)
  96. $r = GUICtrlCreateButton("R", 136, 64, 33, 33, $WS_GROUP)
  97. $t = GUICtrlCreateButton("T", 168, 64, 33, 33, $WS_GROUP)
  98. $y = GUICtrlCreateButton("Y", 200, 64, 33, 33, $WS_GROUP)
  99. $u = GUICtrlCreateButton("U", 232, 64, 33, 33, $WS_GROUP)
  100. $i = GUICtrlCreateButton("I", 264, 64, 33, 33, $WS_GROUP)
  101. $o = GUICtrlCreateButton("O", 296, 64, 33, 33, $WS_GROUP)
  102. $p = GUICtrlCreateButton("P", 328, 64, 33, 33, $WS_GROUP)
  103. $LeftBrackets = GUICtrlCreateButton("[", 360, 64, 33, 33, $WS_GROUP)
  104. $RightBrackets = GUICtrlCreateButton("]", 392, 64, 33, 33, $WS_GROUP)
  105. $Enter = GUICtrlCreateButton("Enter", 424, 64, 57, 65, $WS_GROUP)
  106. $Delete = GUICtrlCreateButton("Del", 488, 64, 33, 33, $WS_GROUP)
  107. $End = GUICtrlCreateButton("End", 520, 64, 33, 33, $WS_GROUP)
  108. $PageDown = GUICtrlCreateButton("PgDn", 552, 64, 33, 33, $WS_GROUP)
  109. $NumberPad7 = GUICtrlCreateButton("7", 592, 64, 33, 33, $WS_GROUP)
  110. $NumberPad8 = GUICtrlCreateButton("8", 624, 64, 33, 33, $WS_GROUP)
  111. $NumberPad9 = GUICtrlCreateButton("9", 656, 64, 33, 33, $WS_GROUP)
  112. $NumberPadPlus = GUICtrlCreateButton("+", 688, 64, 33, 65, $WS_GROUP)
  113. $CapsLock = GUICtrlCreateButton("CapsLck", 0, 96, 49, 33, $WS_GROUP)
  114. $a = GUICtrlCreateButton("A", 48, 96, 33, 33, $WS_GROUP)
  115. $s = GUICtrlCreateButton("S", 80, 96, 33, 33, $WS_GROUP)
  116. $d = GUICtrlCreateButton("D", 112, 96, 33, 33, $WS_GROUP)
  117. $f = GUICtrlCreateButton("F", 144, 96, 33, 33, $WS_GROUP)
  118. $g = GUICtrlCreateButton("G", 176, 96, 33, 33, $WS_GROUP)
  119. $h = GUICtrlCreateButton("H", 208, 96, 33, 33, $WS_GROUP)
  120. $j = GUICtrlCreateButton("J", 240, 96, 33, 33, $WS_GROUP)
  121. $k = GUICtrlCreateButton("K", 272, 96, 33, 33, $WS_GROUP)
  122. $l = GUICtrlCreateButton("L", 304, 96, 33, 33, $WS_GROUP)
  123. $Colon = GUICtrlCreateButton(";", 336, 96, 33, 33, $WS_GROUP)
  124. $Apostrophe = GUICtrlCreateButton("'", 368, 96, 33, 33, $WS_GROUP)
  125. $RightSlash = GUICtrlCreateButton("", 400, 96, 33, 33, $WS_GROUP)
  126. $NumberPad4 = GUICtrlCreateButton("4", 592, 96, 33, 33, $WS_GROUP)
  127. $NumberPad5 = GUICtrlCreateButton("5", 624, 96, 33, 33, $WS_GROUP)
  128. $NumberPad6 = GUICtrlCreateButton("6", 656, 96, 33, 33, $WS_GROUP)
  129. $LeftShift = GUICtrlCreateButton("Shift", 0, 128, 33, 33, $WS_GROUP)
  130. $LeftSlash = GUICtrlCreateButton("", 32, 128, 33, 33, $WS_GROUP)
  131. $z = GUICtrlCreateButton("Z", 64, 128, 33, 33, $WS_GROUP)
  132. $x = GUICtrlCreateButton("X", 96, 128, 33, 33, $WS_GROUP)
  133. $c = GUICtrlCreateButton("C", 128, 128, 33, 33, $WS_GROUP)
  134. $v = GUICtrlCreateButton("V", 160, 128, 33, 33, $WS_GROUP)
  135. $b = GUICtrlCreateButton("B", 192, 128, 33, 33, $WS_GROUP)
  136. $n = GUICtrlCreateButton("N", 224, 128, 33, 33, $WS_GROUP)
  137. $m = GUICtrlCreateButton("M", 256, 128, 33, 33, $WS_GROUP)
  138. $Comma = GUICtrlCreateButton(",", 288, 128, 33, 33, $WS_GROUP)
  139. $Dot = GUICtrlCreateButton(".", 320, 128, 33, 33, $WS_GROUP)
  140. $QuestionMark = GUICtrlCreateButton("/", 352, 128, 33, 33, $WS_GROUP)
  141. $RightShift = GUICtrlCreateButton("Shift", 384, 128, 97, 33, $WS_GROUP)
  142. $NumberPad1 = GUICtrlCreateButton("1", 592, 128, 33, 33, $WS_GROUP)
  143. $NumberPad2 = GUICtrlCreateButton("2", 624, 128, 33, 33, $WS_GROUP)
  144. $NumberPad3 = GUICtrlCreateButton("3", 656, 128, 33, 33, $WS_GROUP)
  145. $NumberPadEnter = GUICtrlCreateButton("Enter", 688, 128, 33, 65, $WS_GROUP)
  146. $LeftCtrl = GUICtrlCreateButton("Ctrl", 0, 160, 41, 33, $WS_GROUP)
  147. $LeftWindows = GUICtrlCreateButton("Win", 40, 160, 41, 33, $WS_GROUP)
  148. $LeftAlt = GUICtrlCreateButton("Alt", 80, 160, 41, 33, $WS_GROUP)
  149. $Space = GUICtrlCreateButton("Space", 120, 160, 201, 33, $WS_GROUP)
  150. $RightAlt = GUICtrlCreateButton("Alt", 320, 160, 41, 33, $WS_GROUP)
  151. $RightWindows = GUICtrlCreateButton("Win", 360, 160, 41, 33, $WS_GROUP)
  152. $RightCtrl = GUICtrlCreateButton("Ctrl", 400, 160, 81, 33, $WS_GROUP)
  153. $NumberPad0 = GUICtrlCreateButton("0", 592, 160, 65, 33, $WS_GROUP)
  154. $NumberPadDot = GUICtrlCreateButton(".", 656, 160, 33, 33, $WS_GROUP)
  155. $LeftArrow = GUICtrlCreateButton("<", 488, 160, 33, 33, $WS_GROUP)
  156. $DownArrow = GUICtrlCreateButton("|", 520, 160, 33, 33, $WS_GROUP)
  157. $RightArrow = GUICtrlCreateButton(">", 552, 160, 33, 33, $WS_GROUP)
  158. $UpArrow = GUICtrlCreateButton("^", 520, 128, 33, 33, $WS_GROUP)
  159. ;Pictures:
  160. $NumberLockOnPic = GUICtrlCreatePic("on.bmp", 600, 3, 18, 26, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
  161. $NumberLockOffPic = GUICtrlCreatePic("off.bmp", 600, 3, 18, 26, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
  162. $CapsLockOnPic = GUICtrlCreatePic("on.bmp", 624, 3, 18, 26, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
  163. $CapsLockOffPic = GUICtrlCreatePic("off.bmp", 624, 3, 18, 26, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
  164. $ScrollLockOnPic = GUICtrlCreatePic("on.bmp", 648, 3, 18, 26, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
  165. $ScrollLockOffPic = GUICtrlCreatePic("off.bmp", 648, 3, 18, 26, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))

  166. ;Setting Pictures:
  167. _GetNumLock()
  168. _GetCapsLock()
  169. _GetScrollLock()
  170. If _GetNumLock() = 1 Then
  171.         $NumberLockOn = True
  172. Else
  173.         GUICtrlSetState($NumberLockOnPic, $GUI_HIDE)
  174.         $NumberLockOn = False
  175. EndIf

  176. If _GetCapsLock() = 1 Then
  177.         $CapsLockOn = True
  178. Else
  179.         GUICtrlSetState($CapsLockOnPic, $GUI_HIDE) ;;
  180.         $CapsLockOn = False
  181. EndIf

  182. If _GetScrollLock() = 1 Then
  183.         $ScrollLockOn = True
  184. Else
  185.         GUICtrlSetState($ScrollLockOnPic, $GUI_HIDE)
  186.         $ScrollLockOn = False
  187. EndIf
  188. ;Current focused window will remain focused even after the keyboard GUI is up:
  189. ;~ GUISetState()
  190. GUISetState(@SW_HIDE)
  191. GUIRegisterMsg($WM_MOUSEACTIVATE, 'WM_EVENTS')
  192. $WGT = WinGetTitle("", "")
  193. GUISetState(@SW_SHOWNOACTIVATE)
  194. WinActivate($WGT)


  195. While 1
  196.         If WinActive($Form1) = False Then
  197.                 WinSetTitle($Form1, "", $MainGUITitle & WinGetTitle("", ""))
  198.         EndIf
  199.         $nMsg = GUIGetMsg()
  200.         Switch $nMsg
  201.                 Case $GUI_EVENT_CLOSE
  202.                         Exit
  203.                 Case $ScrollLock
  204.                         _ScrollLockPushed()
  205.                 Case $NumberLock
  206.                         _NumberLockPushed()
  207.                 Case $CapsLock
  208.                         _CapsLockPushed()
  209.                 Case $Esc
  210.                         PressButton("{Escape}", 0)
  211.                 Case $F1
  212.                         PressButton("{F1}", 0)
  213.                 Case $F2
  214.                         PressButton("{F2}", 0)
  215.                 Case $F3
  216.                         PressButton("{F3}", 0)
  217.                 Case $F4
  218.                         PressButton("{F4}", 0)
  219.                 Case $F5
  220.                         PressButton("{F5}", 0)
  221.                 Case $F6
  222.                         PressButton("{F6}", 0)
  223.                 Case $F7
  224.                         PressButton("{F7}", 0)
  225.                 Case $F8
  226.                         PressButton("{F8}", 0)
  227.                 Case $F9
  228.                         PressButton("{F9}", 0)
  229.                 Case $F10
  230.                         PressButton("{F10}", 0)
  231.                 Case $F11
  232.                         PressButton("{F11}", 0)
  233.                 Case $F12
  234.                         PressButton("{F12}", 0)
  235.                 Case $PrintScreen
  236.                         GUISetState(@SW_HIDE)
  237.                         PressButton("{PrintScreen}", 0)
  238.                         GUISetState(@SW_SHOW)
  239.                 Case $PauseBreak
  240.                         PressButton("{PAUSE}", 0)
  241.                 Case $Igel
  242.                         PressButton("`", 0)
  243.                 Case $One
  244.                         PressButton("1", 0)
  245.                 Case $Two
  246.                         PressButton("2", 0)
  247.                 Case $Three
  248.                         PressButton("3", 0)
  249.                 Case $Four
  250.                         PressButton("4", 0)
  251.                 Case $Five
  252.                         PressButton("5", 0)
  253.                 Case $Six
  254.                         PressButton("6", 0)
  255.                 Case $Seven
  256.                         PressButton("7", 0)
  257.                 Case $Eight
  258.                         PressButton("8", 0)
  259.                 Case $Nine
  260.                         PressButton("9", 0)
  261.                 Case $Zero
  262.                         PressButton("0", 0)
  263.                 Case $Minus
  264.                         PressButton("-", 0)
  265.                 Case $Equal
  266.                         PressButton("=", 0)
  267.                 Case $Back
  268.                         PressButton("{Backspace}", 0)
  269.                 Case $Insert
  270.                         PressButton("{Insert}", 0)
  271.                 Case $Home
  272.                         PressButton("{Home}", 0)
  273.                 Case $PageUp
  274.                         PressButton("{PgUp}", 0)
  275.                 Case $NumberPadSlash
  276.                         PressButton("/", 0)
  277.                 Case $NumberPadX
  278.                         PressButton("*", 0)
  279.                 Case $NumberPadMinus
  280.                         PressButton("-", 0)
  281.                 Case $Tab
  282.                         PressButton("{Tab}", 0)
  283.                 Case $q
  284.                         PressButton("q", 0)
  285.                 Case $w
  286.                         PressButton("w", 0)
  287.                 Case $e
  288.                         PressButton("e", 0)
  289.                 Case $r
  290.                         PressButton("r", 0)
  291.                 Case $t
  292.                         PressButton("t", 0)
  293.                 Case $y
  294.                         PressButton("y", 0)
  295.                 Case $u
  296.                         PressButton("u", 0)
  297.                 Case $i
  298.                         PressButton("i", 0)
  299.                 Case $o
  300.                         PressButton("o", 0)
  301.                 Case $p
  302.                         PressButton("p", 0)
  303.                 Case $LeftBrackets
  304.                         PressButton("[", 0)
  305.                 Case $RightBrackets
  306.                         PressButton("]", 0)
  307.                 Case $Enter
  308.                         PressButton("{Enter}", 0)
  309.                 Case $Delete
  310.                         PressButton("{Delete}", 0)
  311.                 Case $End
  312.                         PressButton("{End}", 0)
  313.                 Case $PageDown
  314.                         PressButton("{PgDn}", 0)
  315.                 Case $NumberPad7
  316.                         PressButton("7", 0)
  317.                 Case $NumberPad8
  318.                         PressButton("8", 0)
  319.                 Case $NumberPad9
  320.                         PressButton("9", 0)
  321.                 Case $NumberPadPlus
  322.                         PressButton("+", 0)
  323.                 Case $a
  324.                         PressButton("a", 0)
  325.                 Case $s
  326.                         PressButton("s", 0)
  327.                 Case $d
  328.                         PressButton("d", 0)
  329.                 Case $f
  330.                         PressButton("f", 0)
  331.                 Case $g
  332.                         PressButton("g", 0)
  333.                 Case $h
  334.                         PressButton("h", 0)
  335.                 Case $j
  336.                         PressButton("j", 0)
  337.                 Case $k
  338.                         PressButton("k", 0)
  339.                 Case $l
  340.                         PressButton("l", 0)
  341.                 Case $Colon
  342.                         PressButton(";", 0)
  343.                 Case $Apostrophe
  344.                         PressButton("'", 0)
  345.                 Case $RightSlash
  346.                         PressButton("", 0)
  347.                 Case $NumberPad4
  348.                         PressButton("4", 0)
  349.                 Case $NumberPad5
  350.                         PressButton("5", 0)
  351.                 Case $NumberPad6
  352.                         PressButton("6", 0)
  353.                 Case $LeftSlash
  354.                         PressButton("", 0)
  355.                 Case $z
  356.                         PressButton("z", 0)
  357.                 Case $x
  358.                         PressButton("x", 0)
  359.                 Case $c
  360.                         PressButton("c", 0)
  361.                 Case $v
  362.                         PressButton("v", 0)
  363.                 Case $b
  364.                         PressButton("b", 0)
  365.                 Case $n
  366.                         PressButton("n", 0)
  367.                 Case $m
  368.                         PressButton("m", 0)
  369.                 Case $Comma
  370.                         PressButton(",", 0)
  371.                 Case $Dot
  372.                         PressButton(".", 0)
  373.                 Case $QuestionMark
  374.                         PressButton("/", 0)
  375.                 Case $NumberPad1
  376.                         PressButton("1", 0)
  377.                 Case $NumberPad2
  378.                         PressButton("2", 0)
  379.                 Case $NumberPad3
  380.                         PressButton("3", 0)
  381.                 Case $NumberPadEnter
  382.                         PressButton("{Enter}", 0)
  383.                 Case $LeftWindows
  384.                         PressButton("{Lwin}", 0)
  385.                 Case $Space
  386.                         PressButton("{Space}", 0)
  387.                 Case $RightWindows
  388.                         PressButton("{Rwin}", 0)
  389.                 Case $NumberPad0
  390.                         PressButton("0", 0)
  391.                 Case $NumberPadDot
  392.                         PressButton(".", 0)
  393.                 Case $LeftArrow
  394.                         PressButton("{Left}", 0)
  395.                 Case $DownArrow
  396.                         PressButton("{Down}", 0)
  397.                 Case $RightArrow
  398.                         PressButton("{Right}", 0)
  399.                 Case $UpArrow
  400.                         PressButton("{Up}", 0)
  401.                 Case $LeftShift
  402.                         If $fLeftShiftHolden = False And $fRightShiftHolden = False Then
  403.                                 PressButton("{SHIFTDOWN}", 1)
  404.                                 $fLeftShiftHolden = True
  405.                                 GUICtrlDelete($LeftShift)
  406.                                 $LeftShift = GUICtrlCreateButton("Shift", 0, 128, 33, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  407.                         ElseIf $fLeftShiftHolden = True And $fRightShiftHolden = False Then
  408.                                 PressButton("{SHIFTUP}", 1)
  409.                                 $fLeftShiftHolden = False
  410.                                 GUICtrlDelete($LeftShift)
  411.                                 $LeftShift = GUICtrlCreateButton("Shift", 0, 128, 33, 33, $WS_GROUP)
  412.                         ElseIf $fLeftShiftHolden = False And $fRightShiftHolden = True Then
  413.                                 PressButton("{SHIFTDOWN}", 1)
  414.                                 $fRightShiftHolden = False
  415.                                 $fLeftShiftHolden = True
  416.                                 GUICtrlDelete($LeftShift)
  417.                                 GUICtrlDelete($RightShift)
  418.                                 $LeftShift = GUICtrlCreateButton("Shift", 0, 128, 33, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  419.                                 $RightShift = GUICtrlCreateButton("Shift", 384, 128, 97, 33, $WS_GROUP)
  420.                         EndIf
  421.                 Case $RightShift
  422.                         If $fRightShiftHolden = False And $fLeftShiftHolden = False Then
  423.                                 PressButton("{SHIFTDOWN}", 1)
  424.                                 $fRightShiftHolden = True
  425.                                 GUICtrlDelete($RightShift)
  426.                                 $RightShift = GUICtrlCreateButton("Shift", 384, 128, 97, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  427.                         ElseIf $fRightShiftHolden = True And $fLeftShiftHolden = False Then
  428.                                 PressButton("{SHIFTUP}", 1)
  429.                                 $fRightShiftHolden = False
  430.                                 GUICtrlDelete($RightShift)
  431.                                 $RightShift = GUICtrlCreateButton("Shift", 384, 128, 97, 33, $WS_GROUP)
  432.                         ElseIf $fRightShiftHolden = False And $fLeftShiftHolden = True Then
  433.                                 PressButton("{SHIFTDOWN}", 1)
  434.                                 $fLeftShiftHolden = False
  435.                                 $fRightShiftHolden = True
  436.                                 GUICtrlDelete($RightShift)
  437.                                 GUICtrlDelete($LeftShift)
  438.                                 $RightShift = GUICtrlCreateButton("Shift", 384, 128, 97, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  439.                                 $LeftShift = GUICtrlCreateButton("Shift", 0, 128, 33, 33, $WS_GROUP)
  440.                         EndIf
  441.                 Case $LeftCtrl
  442.                         If $fLeftCtrlHolden = False And $fRightCtrlHolden = False Then
  443.                                 PressButton("{CTRLDOWN}", 1)
  444.                                 $fLeftCtrlHolden = True
  445.                                 GUICtrlDelete($LeftCtrl)
  446.                                 $LeftCtrl = GUICtrlCreateButton("Ctrl", 0, 160, 41, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  447.                         ElseIf $fLeftCtrlHolden = True And $fRightCtrlHolden = False Then
  448.                                 PressButton("{CTRLUP}", 1)
  449.                                 $fLeftCtrlHolden = False
  450.                                 GUICtrlDelete($LeftCtrl)
  451.                                 $LeftCtrl = GUICtrlCreateButton("Ctrl", 0, 160, 41, 33, $WS_GROUP)
  452.                         ElseIf $fLeftCtrlHolden = False And $fRightCtrlHolden = True Then
  453.                                 PressButton("{CTRLDOWN}", 1)
  454.                                 $fRightCtrlHolden = False
  455.                                 $fLeftCtrlHolden = True
  456.                                 GUICtrlDelete($LeftCtrl)
  457.                                 GUICtrlDelete($RightCtrl)
  458.                                 $LeftCtrl = GUICtrlCreateButton("Ctrl", 0, 160, 41, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  459.                                 $RightCtrl = GUICtrlCreateButton("Ctrl", 400, 160, 81, 33, $WS_GROUP)
  460.                         EndIf
  461.                 Case $RightCtrl
  462.                         If $fRightCtrlHolden = False And $fLeftCtrlHolden = False Then
  463.                                 PressButton("{CTRLDOWN}", 1)
  464.                                 $fRightCtrlHolden = True
  465.                                 GUICtrlDelete($RightCtrl)
  466.                                 $RightCtrl = GUICtrlCreateButton("Ctrl", 400, 160, 81, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  467.                         ElseIf $fRightCtrlHolden = True And $fLeftCtrlHolden = False Then
  468.                                 PressButton("{CTRLUP}", 1)
  469.                                 $fRightCtrlHolden = False
  470.                                 GUICtrlDelete($RightCtrl)
  471.                                 $RightCtrl = GUICtrlCreateButton("Ctrl", 400, 160, 81, 33, $WS_GROUP)
  472.                         ElseIf $fRightCtrlHolden = False And $fLeftCtrlHolden = True Then
  473.                                 PressButton("{CTRLDOWN}", 1)
  474.                                 $fLeftCtrlHolden = False
  475.                                 $fRightCtrlHolden = True
  476.                                 GUICtrlDelete($RightCtrl)
  477.                                 GUICtrlDelete($LeftCtrl)
  478.                                 $RightCtrl = GUICtrlCreateButton("Ctrl", 400, 160, 81, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  479.                                 $LeftCtrl = GUICtrlCreateButton("Ctrl", 0, 160, 41, 33, $WS_GROUP)
  480.                         EndIf
  481.                 Case $LeftAlt
  482.                         If $fLeftAltHolden = False And $fRightAltHolden = False Then
  483.                                 PressButton("{ALTDOWN}", 1)
  484.                                 $fLeftAltHolden = True
  485.                                 GUICtrlDelete($LeftAlt)
  486.                                 $LeftAlt = GUICtrlCreateButton("Alt", 80, 160, 41, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  487.                         ElseIf $fLeftAltHolden = True And $fRightAltHolden = False Then
  488.                                 PressButton("{ALTUP}", 1)
  489.                                 $fLeftAltHolden = False
  490.                                 GUICtrlDelete($LeftAlt)
  491.                                 $LeftAlt = GUICtrlCreateButton("Alt", 80, 160, 41, 33, $WS_GROUP)
  492.                         ElseIf $fLeftAltHolden = False And $fRightAltHolden = True Then
  493.                                 PressButton("{ALTDOWN}", 1)
  494.                                 $fRightAltHolden = False
  495.                                 $fLeftAltHolden = True
  496.                                 GUICtrlDelete($LeftAlt)
  497.                                 GUICtrlDelete($RightAlt)
  498.                                 $LeftAlt = GUICtrlCreateButton("Alt", 80, 160, 41, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  499.                                 $RightAlt = GUICtrlCreateButton("Alt", 320, 160, 41, 33, $WS_GROUP)
  500.                         EndIf
  501.                 Case $RightAlt
  502.                         If $fRightAltHolden = False And $fLeftAltHolden = False Then
  503.                                 PressButton("{ALTDOWN}", 1)
  504.                                 $fRightAltHolden = True
  505.                                 GUICtrlDelete($RightAlt)
  506.                                 $RightAlt = GUICtrlCreateButton("Alt", 320, 160, 41, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  507.                         ElseIf $fRightAltHolden = True And $fLeftAltHolden = False Then
  508.                                 PressButton("{ALTUP}", 1)
  509.                                 $fRightAltHolden = False
  510.                                 GUICtrlDelete($RightAlt)
  511.                                 $RightAlt = GUICtrlCreateButton("Alt", 320, 160, 41, 33, $WS_GROUP)
  512.                         ElseIf $fRightAltHolden = False And $fLeftAltHolden = True Then
  513.                                 PressButton("{ALTDOWN}", 1)
  514.                                 $fLeftAltHolden = False
  515.                                 $fRightAltHolden = True
  516.                                 GUICtrlDelete($RightAlt)
  517.                                 GUICtrlDelete($LeftAlt)
  518.                                 $RightAlt = GUICtrlCreateButton("Alt", 320, 160, 41, 33, $WS_GROUP, $WS_EX_CLIENTEDGE)
  519.                                 $LeftAlt = GUICtrlCreateButton("Alt", 80, 160, 41, 33, $WS_GROUP)
  520.                         EndIf
  521.         EndSwitch
  522. WEnd

  523. Func PressButton($_Key, $_HoldNeeded)
  524.         Local $ctrl
  525.         $ReplacedString = StringReplace(WinGetTitle($Form1), "Virtual Keyboard v0.1 - ", "")
  526.         $ctrl = ControlGetFocus($ReplacedString)
  527.         $ie_handle = WinWaitActive(WinGetTitle('', ''))
  528.         If WinActivate($ReplacedString) Then
  529.                 If _ArrayBinarySearch($keyStroke_Array, $_Key) <> -1 And $_Key <> "{TAB}" Then
  530.                         Select
  531.                                 Case $_Key == '{SHIFTDOWN}'
  532.                                         $shiftstatus = 1
  533.                                 Case $_Key == '{SHIFTUP}'
  534.                                         $shiftstatus = 0
  535.                                 Case $_Key == '{CTRLDOWN}'
  536.                                         $ctrlstatus = 1
  537.                                 Case $_Key == '{CTRLUP}'
  538.                                         $ctrlstatus = 0
  539.                                 Case $_Key == '{ALTUP}'
  540.                                         $altstatus = 0
  541.                                 Case $_Key == '{ALTDOWN}'
  542.                                         $altstatus = 1
  543.                                 Case StringLower($_Key) == StringLower('{BS}')
  544.                                         ControlFocus($ReplacedString, "", $ctrl)
  545.                                         ControlSend($ReplacedString, "", $ctrl, "{ASC 008}")
  546.                                 Case StringLower($_Key) == StringLower('{BACKSPACE}')
  547.                                         ControlFocus($ReplacedString, "", $ctrl)
  548.                                         ControlSend($ReplacedString, "", $ctrl, "{ASC 008}")
  549.                                 Case Else
  550.                                         Send($_Key)
  551.                         EndSelect
  552.                 Else
  553.                         If $shiftstatus == 1 And $CapsLockOn == False And $ctrlstatus == 0 And $altstatus == 0 And $_Key <> "{TAB}" Then
  554. ;~ Send('0')
  555.                                 ControlFocus($ReplacedString, "", $ctrl)
  556.                                 If $ie_handle <> 0 And StringInStr($ctrl, 'Internet Explorer_Server', 0) > 0 Then
  557.                                         get_keyboard_focus($ie_handle, $ctrl, StringUpper($_Key))
  558.                                 Else
  559.                                         ControlCommand($ReplacedString, "", $ctrl, "EditPaste", StringUpper($_Key))
  560.                                 EndIf
  561.                         ElseIf $shiftstatus == 0 And $CapsLockOn == True And $ctrlstatus == 0 And $altstatus == 0 And $_Key <> "{TAB}" Then
  562.                                 ControlFocus($ReplacedString, "", $ctrl)
  563.                                 If $ie_handle <> 0 And StringInStr($ctrl, 'Internet Explorer_Server', 0) > 0 Then
  564.                                         get_keyboard_focus($ie_handle, $ctrl, StringUpper($_Key))
  565.                                 Else
  566.                                         ControlCommand($ReplacedString, "", $ctrl, "EditPaste", StringUpper($_Key))
  567.                                 EndIf
  568.                         ElseIf $shiftstatus == 1 And $CapsLockOn == True And $ctrlstatus == 0 And $altstatus == 0 And $_Key <> "{TAB}" Then
  569.                                 ControlFocus($ReplacedString, "", $ctrl)
  570.                                 If $ie_handle <> 0 And StringInStr($ctrl, 'Internet Explorer_Server', 0) > 0 Then
  571.                                         get_keyboard_focus($ie_handle, $ctrl, $_Key)
  572.                                 Else
  573.                                         ControlCommand($ReplacedString, "", $ctrl, "EditPaste", $_Key)
  574.                                 EndIf
  575.                         ElseIf $shiftstatus == 0 And $CapsLockOn == False And $ctrlstatus == 0 And $altstatus == 0 And $_Key <> "{TAB}" Then
  576.                                 ControlFocus($ReplacedString, "", $ctrl)
  577.                                 If $ie_handle <> 0 And StringInStr($ctrl, 'Internet Explorer_Server', 0) > 0 Then
  578.                                         get_keyboard_focus($ie_handle, $ctrl, $_Key)
  579.                                 Else
  580.                                         ControlCommand($ReplacedString, "", $ctrl, "EditPaste", $_Key)
  581.                                 EndIf
  582.                         ElseIf $ctrlstatus == 1 And $altstatus == 0 Then
  583.                                 ControlFocus($ReplacedString, "", $ctrl)
  584.                                 If $ie_handle <> 0 And StringInStr($ctrl, 'Internet Explorer_Server', 0) > 0 Then
  585.                                         get_keyboard_focus($ie_handle, $ctrl, $_Key)
  586.                                 Else
  587.                                         ControlSend($ReplacedString, "", $ctrl, '^' & $_Key)
  588.                                 EndIf
  589.                         ElseIf $ctrlstatus == 0 And $altstatus == 1 Then
  590.                                 ControlFocus($ReplacedString, "", $ctrl)
  591.                                 ControlSend($ReplacedString, "", $ctrl, '!' & $_Key)
  592.                         Else
  593.                                 ControlFocus($ReplacedString, "", $ctrl)
  594.                                 ControlSend($ReplacedString, "", $ctrl, "{ASC 0x09}")
  595.                         EndIf
  596.                 EndIf
  597.         EndIf
  598.         If $_HoldNeeded = 1 Then
  599.                 SoundPlay("Hold.wav")
  600.         Else
  601.                 SoundPlay("Type.wav")
  602.                 SoundSetWaveVolume(10) ;Set volume for both Hold.wav and Type.wav
  603.         EndIf
  604. EndFunc   ;==>PressButton

  605. Func get_keyboard_focus($ie_handle, $control_class_namenn, $key)
  606.         _IEErrorHandlerRegister("MyErrFunc")
  607.         $oIE = _IEAttach($ie_handle, 'Embedded')
  608.         If IsObj($oIE) Then
  609.                 $oIE.document.activeElement.name
  610.                 If @error == 0 Then
  611.                         $oRange = $oIE.document.selection.createRange()
  612.                         $oRange.text = $key
  613.                         Return
  614.                 Else
  615.                         ConsoleWrite($key)
  616.                         ControlSend('', '', '', $key)
  617.                 EndIf
  618.         EndIf
  619. EndFunc   ;==>get_keyboard_focus

  620. Func MyErrFunc()
  621.         SetError(1, 1, 1)
  622.         Return
  623. EndFunc   ;==>MyErrFunc

  624. Func _GetNumLock() ; By GaryFrost
  625.         Local $ret
  626.         $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_NUMLOCK)
  627.         Return $ret[0]
  628. EndFunc   ;==>_GetNumLock

  629. Func _GetScrollLock() ; By GaryFrost
  630.         Local $ret
  631.         $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_SCROLL)
  632.         Return $ret[0]
  633. EndFunc   ;==>_GetScrollLock

  634. Func _GetCapsLock() ; By GaryFrost
  635.         Local $ret
  636.         $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_CAPITAL)
  637.         Return $ret[0]
  638. EndFunc   ;==>_GetCapsLock

  639. Func Quit()
  640.         GUIDelete($Form1)
  641.         Exit
  642. EndFunc   ;==>Quit

  643. Func _NumberLockPushed()
  644.         If $NumberLockOn = True Then
  645.                 GUICtrlSetState($NumberLockOnPic, $GUI_HIDE)
  646.                 PressButton("{NumLock}", 1)
  647.                 $NumberLockOn = False
  648.         Else
  649.                 GUICtrlSetState($NumberLockOnPic, $GUI_SHOW)
  650.                 PressButton("{NumLock}", 1)
  651.                 $NumberLockOn = True
  652.         EndIf
  653. EndFunc   ;==>_NumberLockPushed

  654. Func _ScrollLockPushed()
  655.         If $ScrollLockOn = True Then
  656.                 GUICtrlSetState($ScrollLockOnPic, $GUI_HIDE)
  657.                 PressButton("{ScrollLock}", 1)
  658.                 $ScrollLockOn = False
  659.         Else
  660.                 GUICtrlSetState($ScrollLockOnPic, $GUI_SHOW)
  661.                 PressButton("{ScrollLock}", 1)
  662.                 $ScrollLockOn = True
  663.         EndIf
  664. EndFunc   ;==>_ScrollLockPushed

  665. Func _CapsLockPushed()
  666.         If $CapsLockOn = True Then
  667.                 GUICtrlSetState($CapsLockOnPic, $GUI_HIDE)
  668.                 PressButton("{CapsLock}", 1)
  669.                 $CapsLockOn = False
  670.         Else
  671.                 GUICtrlSetState($CapsLockOnPic, $GUI_SHOW)
  672.                 PressButton("{CapsLock}", 1)
  673.                 $CapsLockOn = True
  674.         EndIf
  675. EndFunc   ;==>_CapsLockPushed

  676. Func WM_EVENTS($hWndGUI, $MsgID, $WParam, $LParam)
  677.         Switch $hWndGUI
  678.                 Case $Form1
  679.                         Switch $MsgID
  680.                                 Case $WM_MOUSEACTIVATE
  681.                                         ; Check mouse position
  682.                                         Local $aMouse_Pos = GUIGetCursorInfo($Form1)
  683.                                         If $aMouse_Pos[4] > 0 Then
  684.                                                 Local $word = _WinAPI_MakeLong($aMouse_Pos[4], $BN_CLICKED)
  685.                                                 _SendMessage($Form1, $WM_COMMAND, $word, GUICtrlGetHandle($aMouse_Pos[4]))
  686.                                         ElseIf $aMouse_Pos[1] < 0 And $aMouse_Pos[0] > 700 Then
  687.                                                 Quit()
  688.                                         Else
  689.                                                 WinActivate($Form1)
  690.                                         EndIf
  691.                                         Return $MA_NOACTIVATEANDEAT
  692.                         EndSwitch
  693.         EndSwitch
  694.         Return $GUI_RUNDEFMSG
  695. EndFunc   ;==>WM_EVENTS
复制代码
发表于 2016-12-19 13:12:00 | 显示全部楼层
本帖最后由 q410225 于 2016-12-19 13:17 编辑

做的挺精致的,

想呼出,最简单的是编译后做个快捷方式,设热键,

要不然就用HotKeySet
发表于 2016-12-21 09:21:42 | 显示全部楼层
PressButton($_Key, $_HoldNeeded)
这个就是主函数吧,可以直接调用,其他的都是界面和变量定义。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2026-9-20 23:31 , Processed in 0.080417 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表