Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
#DefineFunction GetVirualKeyScanCode( nVirtualKey ) ; sDll = StrCat(DirWindows(1), "user32.dll") nScanCode = DllCall(sDll, long:"MapVirtualKeyA", long:nVirtualKey, long:0) Return nScanCode #EndSubRoutine ; Note to self: never post to the board before having first cup of coffee.... ; The trick is figuring out the scan code for the key when the Fn key is down. ; On my Dell the Fn+Dn keys mute the speakers. The scan code for this is 32 ; You may find the scan code for your notebook via Google or by trial and error. #DefineFunction SendFnKey( wScanCode ) ; Initialize nSize = 28 ; Size of input structure. nOffset = 0 ; Current buffer location. ; Flag member values INPUT_KEYBOARD = 1 KEYEVENTF_EXTENDEDKEY = 1 ; Causes a 0x 30 to be sent ahead of the key ; This gives the scan code the "fn" meaning. KEYEVENTF_KEYUP = 2 KEYEVENTF_SCANCODE = 8 ; 2 stucture buffer. Input = BinaryAlloc(nSize * 2 ) ; Key down structure BinaryPoke4(Input, nOffset, INPUT_KEYBOARD) ; type nOffset = nOffset + 4 BinaryPoke2(Input, nOffset, 0) ; wVk - ignored nOffset = nOffset + 2 BinaryPoke2(Input, nOffset, wScanCode) ; wScan nOffset = nOffset + 2 nFlagOff = nOffset BinaryPoke4(Input, nOffset, KEYEVENTF_EXTENDEDKEY|KEYEVENTF_SCANCODE) ; dwFlags nOffset = nOffset + 4 BinaryPoke4(Input, nOffset, 0) ; time - not used nOffset = nOffset + 4 BinaryPoke4(Input, nOffset, 0) ; dwExtraInfo - not used ; Key up structure nOffset = nSize BinaryPoke4(Input, nOffset, INPUT_KEYBOARD) ; type nOffset = nOffset + 4 BinaryPoke2(Input, nOffset, 0) ; wVk - ignored nOffset = nOffset + 2 BinaryPoke2(Input, nOffset, wScanCode) ; wScan nOffset = nOffset + 2 nFlagOff = nOffset BinaryPoke4(Input, nOffset, KEYEVENTF_EXTENDEDKEY|KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP) ; dwFlags nOffset = nOffset + 4 BinaryPoke4(Input, nOffset, 0) ; time - not used nOffset = nOffset + 4 BinaryPoke4(Input, nOffset, 0) ; dwExtraInfo - not used ; Get a structure pointer. pInput = IntControl(42, Input, 0, 0, 0) ; Do the deed. sDll = StrCat(DirWindows(1), "user32.dll") nResult = DllCall(sDll, long:"SendInput", long:2, long:pInput, long:nSize ); key down ; Clean up BinaryFree(Input) Return nResult ; 0 on failure otherwise number of inputs. #EndFunction ;VK_END = 35 ;nScanCode = GetVirualKeyScanCode( 68 ) ;message("Scan code", nScanCode) ;exit ; Mute the speakers. nResult = SendFnKey(32) If nResult == 2 sText = "Success" Else sText = "Failure" EndIf Message("SendFnKey", sText)
Article ID: W18270
Filename: Send Fn key on a Notebook.txt
File Created: 2008:05:19:07:40:40
Last Updated: 2008:05:19:07:40:40