SHARE
TWEET

Ctrl+A

AZJIO Aug 30th, 2012 581 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; http://forum.ru-board.com/topic.cgi?&forum=5&topic=33902&start=780#16
  2. ; осуществил реализацию ViSiToR, добавил восстановление стартовой раскладки AZJIO
  3. #include <EditConstants.au3>
  4. #include <GUIConstantsEx.au3>
  5.  
  6. $hGUI = GUICreate("Fix for hotkey/Accelerators assign problem", 300, 200)
  7. $nEdit = GUICtrlCreateEdit("", 20, 40, 260, 120)
  8.  
  9. $nDummy = GUICtrlCreateDummy()
  10. Dim $aAccelKeys[1][2] = [["^a", $nDummy]]
  11.  
  12. ; если раскладка не совпадает с англ. яз. то временно переключаем в неё, чтобы зарегистрировать горячие клавиши
  13. $tmp=0
  14. $KeyLayout = RegRead("HKCU\Keyboard Layout\Preload", 1)
  15. If Not @error And $KeyLayout <> 00000409 Then
  16.         _WinAPI_LoadKeyboardLayout(0x0409)
  17.         $tmp=1
  18. EndIf
  19.  
  20. HotKeySet("^+e", "_Quit")
  21. GUISetAccelerators($aAccelKeys)
  22. If $tmp=1 Then _WinAPI_LoadKeyboardLayout(Dec($KeyLayout)) ; восстанавливаем раскладку по умолчанию
  23.  
  24. GUISetState(@SW_SHOW, $hGUI)
  25.  
  26. While 1
  27.     Switch GUIGetMsg()
  28.         Case $GUI_EVENT_CLOSE
  29.             Exit
  30.         Case $nDummy
  31.             GUICtrlSendMsg($nEdit, $EM_SETSEL, 0, -1)
  32.     EndSwitch
  33. WEnd
  34.  
  35. Func _Quit()
  36.     Exit
  37. EndFunc
  38.  
  39. Func _WinAPI_LoadKeyboardLayout($sLayoutID, $hWnd = 0)
  40.     Local Const $WM_INPUTLANGCHANGEREQUEST = 0x50
  41.     Local $aRet = DllCall("user32.dll", "long", "LoadKeyboardLayoutW", "wstr", Hex($sLayoutID, 8), "int", 0)
  42.  
  43.     If Not @error And $aRet[0] Then
  44.         If $hWnd = 0 Then
  45.             $hWnd = WinGetHandle(AutoItWinGetTitle())
  46.         EndIf
  47.  
  48.         DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $aRet[0])
  49.         Return 1
  50.     EndIf
  51.  
  52.     Return SetError(1)
  53. EndFunc
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