RegiOween Posted October 25, 2008 Share Posted October 25, 2008 Hi, folks! Is it possible to remap Win+Tab to Ctrl+Tab? I have tried this way: HotKeySet("#{Tab}", "WinTab") ProcessWait("") Func WinTab() Send("^{Tab}") EndFunc But this didn't work, because Windows has the #{Tab} shortcut to shift between programs in taskbar. Did I miss something? I could workaround the problem using AutoHotKey instruction "#Tab::^Tab", but I just love AutoIt, and I would feel like a betrayer flirting with another scripting language, so I want to avoid this at any cost. Can you help to keep me loyal? Thanks in advance! Reginald0 Link to comment Share on other sites More sharing options...
MrCreatoR Posted October 25, 2008 Share Posted October 25, 2008 Hi, You can not set Win hotkey with HotKeySet because it's preserved by windows. But i think you can make it with Keyboard hook, something like this: expandcollapse popupHotKeySet("{ESC}", "OnAutoItExit") Opt("SendKeyDownDelay", 0) Opt("SendKeyDelay", 0) Global Const $WH_KEYBOARD_LL = 13 Global $sBuffer = "" Global $hStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr") Global $hMod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) Global $hHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", _ $WH_KEYBOARD_LL, "ptr", DllCallbackGetPtr($hStub_KeyProc), "hwnd", $hMod[0], "dword", 0) While 1 Sleep(10) WEnd Func _KeyProc($nCode, $wParam, $lParam) Local $aRet, $KEYHOOKSTRUCT If $nCode < 0 Then $aRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook[0], "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $aRet[0] EndIf If $wParam = 256 Then $KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr", $lParam) Local $nKeyCode = DllStructGetData($KEYHOOKSTRUCT, 1) If $sBuffer = 91 And $nKeyCode = 9 Then $sBuffer = "" Send("^{Tab}") Return 1 EndIf $sBuffer = $nKeyCode EndIf $aRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook[0], "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $aRet[0] EndFunc ;==>_KeyProc Func OnAutoItExit() If $hStub_KeyProc Then DllCallbackFree($hStub_KeyProc) $hStub_KeyProc = 0 DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hHook[0]) If @HotKeyPressed <> "" Then Exit EndFunc ;==>OnAutoItExit Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
RegiOween Posted October 26, 2008 Author Share Posted October 26, 2008 MrCreatoR, thanks for your response, and it really works, but I think you'll agree with me that there's a lot of code complexity for such a simple task: remap a key. And if Winkey is preserved by Windows, why another script language can handle it? In my point of view, a keyboard hook is done outside the AutoIt intelligence, so I don't understand why AutoIt developers don't treat this kind of situation inside the HotKeySet instruction, cause the remapping of F12 key bring us the same problem. But anyway, thanks again for you attention. Reginald0 Link to comment Share on other sites More sharing options...
jvanegmond Posted October 26, 2008 Share Posted October 26, 2008 The windows key or start key is not preserved by windows. Only a number of buttons are reserved by Windows because they do a variety of tasks that are always should be enabled (Alt+Tab, Start+E, Start+F, etc. etc.) If you really want to remap a Windows Hotkey, then that should be done using the registry to remap the keys.AutoIt's HotKeySet uses the RegisterHotkey function. Look at it on MSDN. Because it uses that RegisterHotkey it also is bound between the limits of that function.The RegisterHotkey can also be called in AutoIt directly, and you'll see the limitations more easily. Look here for an example: http://www.autoitscript.com/forum/index.ph...t=0#entry515994 github.com/jvanegmond Link to comment Share on other sites More sharing options...
RegiOween Posted October 27, 2008 Author Share Posted October 27, 2008 Manadar, thanks for your response too, but I can't agree when you say that if I really want to remap a Windows hotkey, that should be done using the registry, just because another script language (already cited on first post) much similar to AutoIt can do that job without much hassle with just one little instruction. Ok, I know it's a different application, but AutoIt is so much better, so is out of my comprehension why this is not implemented inside the HotKeySet instruction. Link to comment Share on other sites More sharing options...
RegiOween Posted April 10, 2012 Author Share Posted April 10, 2012 Hi folks! Sorry for bumping this old thread, but till this day, I'm using the somewhat "ugly" AutoHotkey solution, and to make things worse, MrCreatoR solution is not working properly in Windows 7, since sometimes it sends just the "Win" key, sometimes "Ctrl+Tab", and sometimes "Win+Tab". I really hope with the time has passed since the first post (almost 4 years), AutoIt has a nice solution for this seemingly simple issue. Thanks in advance. Reginald0 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now