qwert Posted December 5, 2010 Share Posted December 5, 2010 I have one of the low-cost presenters -- a usb-based remote control that sends F5 as one of its four buttons. I'd like to use F5 to initiate a feature in my script. By using _IsPressed, I can indeed receive the key and act on it. The problem is the F5 click is being passed on to another application, which results in an extraneous message on the screen. The only reference I can find related to F5 is this:To refresh the active window in IE or WE, press F5.I've searched these forums, but the only key intercept techniques seem to be related to catching characters going into an input control. Is there a way to assign F5 to my application so that it is "captured" and not seen by other apps?Thanks in advance for any help. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted December 5, 2010 Share Posted December 5, 2010 Use HotKeySet() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
qwert Posted December 6, 2010 Author Share Posted December 6, 2010 Thanks for your suggestion. I had gotten off that track (from hotkeys) when I started using _IsPressed for my other key selections.But now, I've run into a different problem. Apparently the presenter's usb device manager behaves as a separate application. It seems to detect its own F5 button -- and will "send" it to my script, so that it gets detected by _IsPressed, but the operating system and my script's HotKeySet never receive the key press. Yet, if I press F5 on the keyboard, my HotKeySet function executes immediately.I've also found this in the AutoIt Help:The following hotkeys cannot be set: ....F12 -- reserved by Windows ... Other -- Any global hotkeys a user has defined using third-party software.I'm going to have to think about this some more. Link to comment Share on other sites More sharing options...
Yashied Posted December 6, 2010 Share Posted December 6, 2010 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
rover Posted December 6, 2010 Share Posted December 6, 2010 I have one of the low-cost presenters -- a usb-based remote control that sends F5 as one of its four buttons. I'd like to use F5 to initiate a feature in my script. By using _IsPressed, I can indeed receive the key and act on it. The problem is the F5 click is being passed on to another application, which results in an extraneous message on the screen. The only reference I can find related to F5 is this: I've searched these forums, but the only key intercept techniques seem to be related to catching characters going into an input control. Is there a way to assign F5 to my application so that it is "captured" and not seen by other apps? Thanks in advance for any help. qwert your usb device works at the hardware driver level and may be unhookable; this probably wont work, but give it a try. a quick reworking of help file example for _WinAPI_SetWindowsHookEx to show low level keyboard hook of F5 key you can process F5, then either block or pass it on to other apps you should return quickly from the _KeyProc function, i.e. no blocking msgbox, loops, sleep etc. or the pc will become unresponsive. Use ESC key to exit the script - this will properly close hook and callback in _OnAutoItExit() expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> OnAutoItExitRegister("_OnAutoItExit") Opt('MustDeclareVars', 1) Global $iF5Key = False Global Const $VK_F5 = 0x74 ;F5 key Global Const $VK_ESCAPE = 0x1B ;ESC key Global $hHook, $hStub_KeyProc, $iDLLUSER32 ; globals required for hook $iDLLUSER32 = DllOpen("user32.dll") _Main() Func _Main() $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam") Local $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod) While 1 Sleep(50) If $iF5Key = True Then ;place in your message loop. you can use global or GuiCtrlSendToDummy() in EvaluateKey or _KeyProc $iF5Key = False ConsoleWrite("!F5 Blocked" & @CRLF) ;do your own processing after blocking F5 EndIf WEnd EndFunc ;==>_Main Func EvaluateKey($keycode) If ($keycode = $VK_F5) Then $iF5Key = True Return 1 ;to block F5 to other apps ;Return 0 ; allow F5 to pass ElseIf ($keycode = $VK_ESCAPE) Then ; esc key Exit EndIf Return 0 EndFunc ;==>EvaluateKey ;=========================================================== ; callback function ;=========================================================== Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $nCode < 0 Then ;must return if $nCode less than zero Return __WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf If $wParam = $WM_KEYDOWN Then If EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode")) = 1 Then Return 1 Else Local $flags = DllStructGetData($tKEYHOOKS, "flags") Switch $flags Case $LLKHF_ALTDOWN ;ConsoleWrite("$LLKHF_ALTDOWN" & @LF) Case $LLKHF_EXTENDED ;ConsoleWrite("$LLKHF_EXTENDED" & @LF) Case $LLKHF_INJECTED ;ConsoleWrite("$LLKHF_INJECTED" & @LF) Case $LLKHF_UP ;ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @LF) EndSwitch EndIf Return __WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>_KeyProc Func _OnAutoItExit() ;unhook keyboard, free callback, close open dll _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_KeyProc) DllClose($iDLLUSER32) EndFunc ;==>OnAutoItExit Func __WinAPI_CallNextHookEx($hhk, $iCode, $wParam, $lParam) Local $aResult = DllCall($iDLLUSER32, "lresult", "CallNextHookEx", _ "handle", $hhk, "int", $iCode, "wparam", $wParam, "lparam", $lParam) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc ;==>_WinAPI_CallNextHookEx I see fascists... Link to comment Share on other sites More sharing options...
rover Posted December 6, 2010 Share Posted December 6, 2010 qwert ignore my post above go with Yashieds Hotkey UDF I should have read it first why are posts uneditable or deleteable? I see fascists... 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