daily pastebin goal
46%
SHARE
TWEET

[НЕ УДАЛЯТЬ!] sc vk коды клавиш

alexdubovyck Dec 10th, 2017 318 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Для https://www.youtube.com/watch?v=VJ8eLC2njLg
  2. Для https://www.youtube.com/watch?v=VJ8eLC2njLg
  3. Для https://www.youtube.com/watch?v=VJ8eLC2njLg
  4.  
  5. Menu, Tray, Icon, Shell32.dll, 45
  6.  
  7. ; клавиши дополнительной клавиатуры и Pause, sc которых ф-ция MapVirtualKey не определяет
  8. ScVk := "45,13|11D,A3|135,6F|136,A1|137,2C|138,A5|145,90|147,24|148,26|149,21|"
  9. . "14B,25|14D,27|14F,23|150,28|151,22|152,2D|153,2E|15B,5B|15C,5C|15D,5D"
  10.  
  11. ; клавиши мыши и их vk, а также Ctrl+Break и Clear
  12. KeysVK := "LButton,1|RButton,2|Ctrl+Break,3|MButton,4|XButton1,5|XButton2,6|"
  13. . "Clear,c|Shift,10|Ctrl,11|Alt,12"
  14.  
  15. Height := 165 ; высота клиентской области, не включая заголовки вкладок
  16.  
  17. Gui, +AlwaysOnTop
  18. Gui, Color, DAD6CA
  19. Gui, Add, Tab2, vTab gTab x0 y0 w200 h185 AltSubmit hwndhTab, Получить код|Клавиша по коду
  20. Tab = 2
  21. VarSetCapacity(RECT, 16)
  22. SendMessage, TCM_GETITEMRECT := 0x130A, 1, &RECT,, ahk_id %hTab%
  23. TabH := NumGet(RECT, 12, "UInt")
  24. GuiControl, Move, Tab, % "x0 y0 w200 h" TabH + Height
  25. Gui, Add, Text, % "x8 y" TabH + 8 " w183 +" SS_GRAYFRAME := 0x8 " h" Height - 16
  26.  
  27. Gui, Font, q5 s12, Verdana
  28. Gui, Add, Text, vAction x15 yp+7 w170 Center c0033BB, Нажмите клавишу
  29. Gui, Add, Text, vKey xp yp+35 wp Center Hidden
  30.  
  31. Gui, Font, q5 c333333
  32. Gui, Add, Text, vTextVK xp+8 yp+37 Hidden, vk =
  33. Gui, Add, Text, vVK xp+35 yp w62 h23 Center Hidden
  34. Gui, Add, Text, vTextSC xp-35 yp+35 Hidden, sc =
  35. Gui, Add, Text, vSC xp+35 yp w62 h23 Center Hidden
  36.  
  37. Gui, Font, s8
  38. Gui, Add, Button, vCopyVK gCopy xp+70 yp-35 w50 h22 Hidden, Copy
  39. Gui, Add, Button, vCopySC gCopy xp yp+33 wp hp Hidden, Copy
  40.  
  41. Gui, Tab, 2
  42. Gui, Add, Text, % "x8 y" TabH + 8 " w183 +" SS_GRAYFRAME " h" Height - 16
  43. Gui, Add, Text, x15 yp+7 w170 c0033BB
  44. , Введите код`nв шестнадцатеричном формате без префикса "0x"
  45.  
  46. Gui, Font, q5 s11
  47. Gui, Add, Text, xp yp+58, vk
  48. Gui, Add, Edit, vEditVK gGetKey xp+25 yp-2 w45 h23 Limit3 Uppercase Center
  49. Gui, Add, Text, vKeyVK xp+45 yp+2 w105 Center
  50.  
  51. Gui, Add, Text, x15 yp+43, sc
  52. Gui, Add, Edit, vEditSC gGetKey xp+25 yp-2 w45 h23 Limit3 Uppercase Center
  53. Gui, Add, Text, vKeySC xp+45 yp+2 w105 Center
  54. Gui, Show, % "w199 h" TabH + Height - 1, Коды клавиш
  55.  
  56. hHookKeybd := SetWindowsHookEx()
  57. OnExit, Exit
  58. OnMessage(0x6, "WM_ACTIVATE")
  59. OnMessage(0x102, "WM_CHAR")
  60. Return
  61.  
  62. Tab: ; whenever the user switches to a new tab, the output variable will
  63. If (Tab = 2 && !hHookKeybd) ; be set to the previously selected tab number in the case of AltSubmit.
  64. hHookKeybd := SetWindowsHookEx()
  65. Else if (Tab = 1 && hHookKeybd)
  66. DllCall("UnhookWindowsHookEx", UInt, hHookKeybd), hHookKeybd := ""
  67. Return
  68.  
  69. Copy:
  70. GuiControlGet, Code,, % SubStr(A_GuiControl, -1)
  71. StringLower, GuiControl, A_GuiControl
  72. Clipboard := SubStr(GuiControl, -1) . SubStr(Code, 3)
  73. Return
  74.  
  75. GetKey:
  76. GuiControlGet, Code,, % A_GuiControl
  77. Code := RegExReplace(Code, "^0+")
  78. Code := "0x" . Code
  79. SetFormat, IntegerFast, H
  80. if A_GuiControl = EditVK
  81. {
  82. if (Code > 0xA5 && Code < 0xBA)
  83. Key := "", IsKey := 1
  84.  
  85. Loop, parse, KeysVK, |
  86. {
  87. if (Substr(Code, 3) = RegExReplace(A_LoopField, ".*,(.*)", "$1"))
  88. {
  89. Key := RegExReplace(A_LoopField, "(.*),.*", "$1")
  90. IsKey = 1
  91. Break
  92. }
  93. }
  94.  
  95. if !IsKey
  96. {
  97. Loop, parse, ScVk, |
  98. {
  99. if (Code = "0x" . RegExReplace(A_LoopField, ".*,(.*)", "$1"))
  100. {
  101. Code := RegExReplace(A_LoopField, "(.*),.*", "0x$1")
  102. IsCode = 1
  103. Break
  104. }
  105. }
  106. if !IsCode
  107. Code := DllCall("MapVirtualKey", UInt, Code, UInt, MAPVK_VK_TO_VSC := 0)
  108. }
  109. }
  110. else if (Code = 0x56 || Code > 0x1FF)
  111. Key := "", IsKey := 1
  112.  
  113. if !IsKey
  114. Key := GetKeyNameText(Code)
  115.  
  116. Key := RegExReplace(Key, "(.*)Windows", "$1Win")
  117. GuiControl,, % "Key" SubStr(A_GuiControl, -1), % Key
  118. Key := IsKey := IsCode := ""
  119. Return
  120.  
  121. GuiClose:
  122. ExitApp
  123.  
  124. Exit:
  125. if hHookKeybd
  126. DllCall("UnhookWindowsHookEx", Ptr, hHookKeybd)
  127. ExitApp
  128.  
  129. WM_ACTIVATE(wp)
  130. {
  131. global
  132. if (wp & 0xFFFF = 0 && hHookKeybd)
  133. DllCall("UnhookWindowsHookEx", UInt, hHookKeybd), hHookKeybd := ""
  134. if (wp & 0xFFFF && Tab = 2 && !hHookKeybd)
  135. hHookKeybd := SetWindowsHookEx()
  136. GuiControl,, Action, % wp & 0xFFFF = 0 ? "Активируйте окно" : "Нажмите клавишу"
  137. }
  138.  
  139. SetWindowsHookEx()
  140. {
  141. Return DllCall("SetWindowsHookEx" . (A_IsUnicode ? "W" : "A")
  142. , Int, WH_KEYBOARD_LL := 13
  143. , Ptr, RegisterCallback("LowLevelKeyboardProc", "Fast")
  144. , Ptr, DllCall("GetModuleHandle", UInt, 0, Ptr)
  145. , UInt, 0, Ptr)
  146. }
  147.  
  148. LowLevelKeyboardProc(nCode, wParam, lParam)
  149. {
  150. static once, WM_KEYDOWN = 0x100, WM_SYSKEYDOWN = 0x104
  151.  
  152. Critical
  153. SetFormat, IntegerFast, H
  154. vk := NumGet(lParam+0, "UInt")
  155. Extended := NumGet(lParam+0, 8, "UInt") & 1
  156. sc := (Extended<<8)|NumGet(lParam+0, 4, "UInt")
  157. sc := sc = 0x136 ? 0x36 : sc
  158. Key := GetKeyNameText(sc)
  159.  
  160. if (wParam = WM_SYSKEYDOWN || wParam = WM_KEYDOWN)
  161. {
  162. GuiControl,, Key, % Key
  163. GuiControl,, VK, % vk
  164. GuiControl,, SC, % sc
  165. }
  166.  
  167. if !once
  168. {
  169. Controls := "Key|TextVK|VK|TextSC|SC|CopyVK|CopySC"
  170. Loop, parse, Controls, |
  171. GuiControl, Show, % A_LoopField
  172. once = 1
  173. }
  174.  
  175. if Key Contains Ctrl,Alt,Shift,Tab
  176. Return CallNextHookEx(nCode, wParam, lParam)
  177.  
  178. if (Key = "F4" && GetKeyState("Alt", "P")) ; закрытие окна и выход по Alt + F4
  179. Return CallNextHookEx(nCode, wParam, lParam)
  180.  
  181. Return nCode < 0 ? CallNextHookEx(nCode, wParam, lParam) : 1
  182. }
  183.  
  184. CallNextHookEx(nCode, wp, lp)
  185. {
  186. Return DllCall("CallNextHookEx", Ptr, 0, Int, nCode, UInt, wp, UInt, lp)
  187. }
  188.  
  189. GetKeyNameText(sc)
  190. {
  191. VarSetCapacity(Key, A_IsUnicode ? 32 : 16)
  192. DllCall("GetKeyNameText" . (A_IsUnicode ? "W" : "A"), UInt, sc<<16, Str, Key, UInt, 16)
  193. if Key in Shift,Ctrl,Alt
  194. Key := "Left " . Key
  195. Return Key
  196. }
  197.  
  198. WM_CHAR(wp)
  199. {
  200. global hBall
  201. SetWinDelay, 0
  202. CoordMode, Caret
  203. WinClose, ahk_id %hBall%
  204. GuiControlGet, Focus, Focus
  205. if !InStr(Focus, "Edit")
  206. Return
  207.  
  208. if wp in 3,8,24,26 ; обработка Ctrl + C, BackSpace, Ctrl + X, Ctrl + Z
  209. Return
  210.  
  211. if wp = 22 ; обработка Ctrl + V
  212. {
  213. GuiControlGet, Content,, % Focus
  214. if !StrLen(String := SubStr(Clipboard, 1, 3 - StrLen(Content)))
  215. {
  216. ShowBall("Буфер обмена не содержит текста.", "Ошибка!")
  217. Return 0
  218. }
  219. Loop, parse, String
  220. {
  221. Text .= A_LoopField
  222. if A_LoopField not in 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,A,B,C,D,E,F
  223. {
  224. ShowBall("Буфер обмена содержит недопустимые символы."
  225. . "`nДопустимые символы:`n0123456789ABCDEF", "Ошибка!")
  226. Return 0
  227. }
  228. }
  229. Control, EditPaste, % Text, % Focus, Коды клавиш
  230. Return 0
  231. }
  232.  
  233. Char := Chr(wp)
  234. if Char not in 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,A,B,C,D,E,F
  235. {
  236. ShowBall("Допустимые символы:`n0123456789ABCDEF", Char " — недопустимый символ")
  237. Return 0
  238. }
  239. Return
  240. }
  241.  
  242. ShowBall(Text, Title="")
  243. {
  244. global
  245. WinClose, ahk_id %hBall%
  246. hBall := BalloonTip(A_CaretX+1, A_CaretY+15, Text, Title)
  247. SetTimer, BallDestroy, -2000
  248. Return
  249.  
  250. BallDestroy:
  251. WinClose, ahk_id %hBall%
  252. Return
  253. }
  254.  
  255. BalloonTip(x, y, sText, sTitle = "", h_icon = 0)
  256. {
  257. ; BalloonTip — это ToolTip с хвостиком
  258. ; h_icon — 0: None, 1:Info, 2: Warning, 3: Error, n > 3: предполагается hIcon.
  259.  
  260. TTS_NOPREFIX := 2, TTS_ALWAYSTIP := 1, TTS_BALLOON := 0x40, TTS_CLOSE := 0x80
  261.  
  262. hWnd := DllCall("CreateWindowEx", UInt, WS_EX_TOPMOST := 8
  263. , Str, "tooltips_class32", Str, ""
  264. , UInt, TTS_NOPREFIX|TTS_ALWAYSTIP|TTS_BALLOON|TTS_CLOSE
  265. , Int, 0, Int, 0, Int, 0, Int, 0
  266. , UInt, 0, UInt, 0, UInt, 0, UInt, 0)
  267.  
  268. NumPut(VarSetCapacity(TOOLINFO, A_PtrSize = 4 ? 48 : 72, 0), TOOLINFO, "UInt")
  269. NumPut(0x20, TOOLINFO, 4, "UInt") ; TTF_TRACK = 0x20
  270. NumPut(&sText, TOOLINFO, A_PtrSize = 4 ? 36 : 48, "UInt")
  271.  
  272. A_DHW := A_DetectHiddenWindows
  273. DetectHiddenWindows, On
  274. WinWait, ahk_id %hWnd%
  275.  
  276. WM_USER := 0x400
  277. SendMessage, WM_USER + 24,, w ; TTM_SETMAXTIPWIDTH
  278. SendMessage, WM_USER + (A_IsUnicode ? 50 : 4),, &TOOLINFO ; TTM_ADDTOOL
  279. SendMessage, WM_USER + (A_IsUnicode ? 33 : 32), h_icon, &sTitle ; TTM_SETTITLEA и TTM_SETTITLEW
  280. SendMessage, WM_USER + (A_IsUnicode ? 57 : 12),, &TOOLINFO ; TTM_UPDATETIPTEXTA и TTM_UPDATETIPTEXTW
  281. SendMessage, WM_USER + 18,, x|(y<<16) ; TTM_TRACKPOSITION
  282. SendMessage, WM_USER + 17, 1, &TOOLINFO ; TTM_TRACKACTIVATE
  283.  
  284. DetectHiddenWindows, % A_DHW
  285. Return hWnd
  286. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top