 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
XavierGr
Joined: 15 Jul 2006 Posts: 42
|
Posted: Sun Mar 04, 2007 7:06 pm Post subject: |
|
|
My keyboard is Microsoft's Wireless Desktop 6000 v2.0
And I have a Logitech G7 Mouse
Both of these products have some buttons that AutoHotKey can't recognise.
Using Micha's Script my results are not so good.
The keyboard and mouse classes work and detect the normal keypresses that AutoHotkey detects by default.
All the other buttons need the HID class to be captured.
Unfortunately my logitech mouse will not transmit any data on the HID class (1, 12), so at least on that class you can't really capture any keypresses.
My Wireless Keyboard does transmit data on 2 HID devices.
While monitoring you get tons of data and I had to do some filtering to get keypress data.
Again, unfortunately, while pressing the unrecognized buttons I got various values and most of the times buttons would produce varying results on each keypress. So mapping specific values to a button didn't work out in the end.
Either I am missing something or there is something fishy to it.
Though I have to say that the detection script worked perfectly for a HID joystick I have. (though there aren't any non recognizable buttons that autohotkey failed to map with this device)
If someone manages to find something further please report it.
Both setpoint and intellitype are worthless and horrible programs which I am sure lots of people would be very happy to replace with just an autohotkey script. _________________ One hotkey to rule them all! |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Mar 06, 2007 2:13 am Post subject: |
|
|
I have a Conceptronic (PC-SATi) USB Reciver.
Win XP install it as a Keyboard.
When I press a key in my remote, send to desktop keys as tab,enter,1,2,3,4,5,n,f,...
With .dll I can get all keys pressed in all keyboards.
And change .ahk I can get only My reciver pressed keys.
Two Problems:
1.- (More Important) Can I disable device for other aplications?
When I press a remote key .ahk work but send key to desktop too.
In 'uICE' (Win Program) has Option 'disable device for other aplications' with this uICE catch my reciver but windows don`t send this keys to desktop.
Is posible this with Autorhothey HDI-device?
2.- + and - VOL is the same Key (16) with the same parameters.
Thanks. |
|
| Back to top |
|
 |
interiot
Joined: 06 Nov 2005 Posts: 64
|
Posted: Wed Jun 27, 2007 6:23 pm Post subject: Support more than 9 devices |
|
|
The AutoHotkeyRemoteControlDLL.ahk script posted on the site only supports 9 HID/KB/MOUSE devices. To view more than that, this patch is required:
| Code: |
;
; AutoHotkey Version: 1.0.39.00
; Language: English/German
; Platform: WinXP
; Author: Michael Simon (MISIFUSC-MAIL@yahoo.de)
;
; Script Function:
; Support for
;
HomePath=AutohotkeyRemoteControl.dll
hModule := DllCall("LoadLibrary", "str", HomePath) ; Avoids the need for DllCall() to load the dll each call
;When receiving a WM_INPUT-message call the InputMsg-Label
OnMessage(0x00FF, "InputMsg")
;How many devices are attached?
nRC := DllCall("AutohotkeyRemoteControl\GetDeviceCount", "Cdecl UInt")
if errorlevel <> 0
{
MsgBox GetDeviceCount fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
devlb = ; ListboxInhalt
;Anzeige der Infos. Füllen der Listbox mit Devices
;Fill the listbox with the devicenames
loop, %nRC%
{
;msgbox %A_Index%
strRC := DllCall("AutohotkeyRemoteControl\GetDeviceType", Int, A_Index-1, "Cdecl Str")
if errorlevel <> 0
{
MsgBox GetDeviceType fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
ifequal, A_Index, 1
LBText2Add = %A_Index%: %strRC%
else
LBText2Add = %LBText2Add%|%A_Index%: %strRC%
}
;Gui, Add, ListBox, x6 y20 w460 h110 Choose1 gLBSelChange Vdevlb, %LBText2Add%
Gui, Add, ListBox, x6 y20 w460 h110 gLBSelChange Vdevlb, %LBText2Add%
Gui, Add, Text, x6 y0 w460 h20, Device Description
Gui, Add, Edit, x6 y130 w460 h110 VDevDesc, Device Info
Gui, Add, Edit, x6 y310 w100 h30 VEditUsage Number,
Gui, Add, Text, x6 y250 w330 h30,Enter Usage + UsagePage of the Ctrl`, then register it. Keyboard: Usage=6 Page=1 - Mouse: Usage=2 Page=1
Gui, Add, Text, x6 y280 w100 h30,Usage
Gui, Add, Text, x106 y280 w100 h30, UsagePage
Gui, Add, Edit, x106 y310 w100 h30 VEditUsagePage Number,
Gui, Add, Button, x216 y310 w90 h30 gRegisterCtrl,&Register
Gui, Add, Edit, x6 y370 w460 h290 vEditRespond,
Gui, Add, Text, x6 y340 w460 h12,Respond from Device:
Gui, Add, Text, x6 y352 w460 h12,
Gui, Show, x182 y192 h666 w474, Autohotkey HID-Support
return
LBSelChange:
;User has selected another item. /*Deregister all Devices and*/ Register the selected one
GuiControlGet, devlb
nWhereSpace := InStr(devlb, ":")
StringLeft, nCount, devlb, % nWhereSpace - 1
nRC := DllCall("AutohotkeyRemoteControl\GetDeviceCount", "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox GetDeviceCount fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
;Get DeviceInfo
DevType = %devlb%
StringTrimLeft, DevType, DevType, % nWhereSpace + 1
if DevType = MOUSE
{
;msgbox Es ist eine Maus: %DevType%
;Get Mouse-Device-Information
DevID = 0
BtnNr = 0
SampleRate = 0
NameSize = 400
VarSetCapacity(Name, 500) ;Reserve more space than needed.
nRC := DllCall("AutohotkeyRemoteControl\GetMouseDeviceInfo", INT, nCount, "INT *", DevID, "INT *", BtnNr, "INT *", SampleRate, INT, NameSize, Str, Name, "Cdecl Int")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox error while calling GetMouseDeviceInfo Errorlevel: %errorlevel%
}
;Show Info in Edit
szText = DeviceID: %DevID%`nButtoncount:%BtnNr%`nSamplerate:%SampleRate%`nName:%Name%
GuiControl, , DevDesc, %szText%
GuiControl, , EditUsage, 2
GuiControl, , EditUsagePage, 1
}
if DevType = KEYBOARD
{
;Get Keyboard-Device-Information
nSubType = 0
nKeyboardMode = 0
nFuncKeyCount = 0
nIndicators = 0
nTotalKeys = 0
NameSize = 400
VarSetCapacity(Name, 500)
nRC := DllCall("AutohotkeyRemoteControl\GetKeyDeviceInfo", INT, nCount, "INT *", nSubType, "INT *", nKeyboardMode, "INT *", nFuncKeyCount, "INT *", nIndicators, "INT *", nTotalKeys, INT, NameSize, Str, Name, "Cdecl Int")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox error while calling GetKeyboardDeviceInfo Errorlevel: %errorlevel%
}
;Show Info in Edit
szText = SubType:%nSubType%, Keyboardmode:%nKeyboardMode%, FunctionKeys:%nFuncKeyCount%, Indicators:%nIndicators%, Total Keys:%nTotalKeys%, Name:%Name%
GuiControl, , DevDesc, %szText%
GuiControl, , EditUsage, 6
GuiControl, , EditUsagePage, 1
}
if DevType = HID
{
;Get HID-Device-Information
dwVendorId = 0
dwProductId = 0
dwVersionNumber = 0
usUsagePage = 0
usUsage = 0
NameSize = 400
VarSetCapacity(Name, 500)
nRC := DllCall("AutohotkeyRemoteControl\GetHIDDeviceInfo", INT, nCount, "INT *", dwVendorId, "INT *", dwProductId, "INT *", dwVersionNumber, "INT *", usUsagePage, "INT *", usUsage, INT, NameSize, Str, Name, "Cdecl Int")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox error while calling GetHIDDeviceInfo Errorlevel: %errorlevel%
}
;Show Info in Edit
szText = Vendor:%dwVendorId%, Product:%dwProductId%, VersionNr:%dwVersionNumber%, UsagePage:%usUsagePage%, Usage:%usUsage%, Name:%Name%
GuiControl, , EditUsage, %usUsage%
GuiControl, , EditUsagePage, %usUsagePage%
GuiControl, , DevDesc, %szText%
}
return
RegisterCtrl:
;Register a Control
HWND := WinExist("Autohotkey HID-Support")
GuiControlGet, EditUsage
GuiControlGet, EditUsagePage
;MsgBox -%HWND%- >>%EditUsage%<< >%EditUsagePage%<
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox RegisterDevice fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
return
;This function is called, when an WM_INPUT-msg from a device is received
InputMsg(wParam, lParam, msg, hwnd)
{
;MsgBox %wParam% %lParam%
;MsgBox eingetroffen %wParam% %lParam% %msg% %HWND%
DeviceNr = -1
nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTDataType", UINT, wParam, UINT, lParam, "INT *", DeviceNr, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == 0xFFFFFFFF)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
;Tooltip, %DeviceNr%
ifequal, nRC, 0
{
GetMouseData(wParam, lParam)
}
else ifequal, nRC, 1
{
GetKeyboardData(wParam, lParam)
}
else ifequal, nRC, 2
{
GetHIDData(wParam, lParam)
}
}
return
GetHIDData(wParam, lParam)
{
DataSize = 5000
VarSetCapacity(RawData, %DataSize%)
nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDData", UINT, wParam, UINT, lParam, "UINT *" , DataSize, "UINT *", RawData, "Cdecl UInt")
if (errorlevel <> 0) || (nHandle == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", INT, nHandle, "Cdecl Int")
DeviceNumber := DeviceNumber +1 ;Index 0
;Msgbox, %DataSize%
loop, %DataSize%
{
Zeichen := ExtractInteger(RawData, A_Index, false, 1)
Vals = %Vals% - %Zeichen%
}
;MsgBox %Vals%
Vals = %Vals% `n
GuiControlGet, EditRespond
OldText = %EditRespond%
OldText = %Vals% %OldText%
StringLeft, OldText, OldText, 300
GuiControl, , EditRespond, %OldText%
ControlSetText, Static6, %DeviceNumber%
;MsgBox %Vals%
}
GetMouseData(wParam, lParam)
{
nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTMOUSEData", UINT, wParam, UINT, lParam, "UINT *" , pusFlags, "UINT *", pusBtnFlg
, "UINT *" , pusBtnData, "UINT *", pulRawBtn, "UINT *" , px, "UINT *", py, "UINT *", pextraInfo, "Cdecl UInt")
if (errorlevel <> 0) || (nHandle == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", INT, nHandle, "Cdecl Int")
DeviceNumber := DeviceNumber +1 ;Index 0
Text = Flags: %pusFlags% `nBtnFlag: %pusBtnFlg% `nButtonData: %pusBtnData% `nRawButton: %pulRawBtn% `nX: %px% `nY: %py% `nExtrainfo: %pextraInfo%
GuiControlGet, EditRespond
OldText = %EditRespond%
StringLeft, OldText, OldText, 500
GuiControl, , EditRespond, %Text%`n%OldText%
ControlSetText, Static6, %DeviceNumber%
}
return
GetKeyboardData(wParam, lParam)
{
nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTKEYBOARDData", UINT, wParam, UINT, lParam, "UINT *" , pusMakeCode, "UINT *", pusFlags
, "UINT *" , pusKey, "UINT *", punMsg, "UINT *", pextraInfo, "Cdecl UInt")
if (errorlevel <> 0) || (nHandle == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", INT, nHandle, "Cdecl Int")
DeviceNumber := DeviceNumber +1 ;Index 0
Text = MakeCode: %pusMakeCode% `nFlags: %pusFlags% `nKey: %pusKey% `nMsg: %punMsg% `nExtrainfo: %pextraInfo%
GuiControlGet, EditRespond
OldText = %EditRespond%
StringLeft, OldText, OldText, 500
GuiControl, , EditRespond, %Text%`n%OldText%
ControlSetText, Static6, %DeviceNumber%
}
return
GuiClose:
ExitApp
cleanup:
DllCall("FreeLibrary", "UInt", hModule) ; It is best to unload the DLL after using it (or before the script exits).
ExitApp
ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
; The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
; pSource must be ByRef to avoid corruption during the formal-to-actual copying process
; (since pSource might contain valid data beyond its first binary zero).
{
SourceAddress := &pSource + pOffset ; Get address and apply the caller's offset.
result := 0 ; Init prior to accumulation in the loop.
Loop %pSize% ; For each byte in the integer:
{
result := result | (*SourceAddress << 8 * (A_Index - 1)) ; Build the integer from its bytes.
SourceAddress += 1 ; Move on to the next byte.
}
if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
return result ; Signed vs. unsigned doesn't matter in these cases.
; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
return -(0xFFFFFFFF - result + 1)
}
|
I also am trying to figure out the same question above. Is there a way to suppress WM_INPUT from being sent to other applications? |
|
| Back to top |
|
 |
K-Mile Guest
|
Posted: Tue Jul 03, 2007 9:20 pm Post subject: |
|
|
I must say this script is really amazing! It lets me handle all but my 7 button Dell mouse perfectly. I do have one question however:
Is it possible to prevent propagation of events? I have a Microsoft keyboard that features a lot of extra buttons, but I can't seem to stop the keys from firing as well.
Thanks! |
|
| Back to top |
|
 |
darkangael
Joined: 18 Jun 2007 Posts: 3
|
Posted: Tue Jul 24, 2007 12:34 am Post subject: |
|
|
Another hand up for the suppressing propagation. I have finally worked out how to get it to distinguish my two keyboards but there are two problems:
1) Autohotkey gets there first. If Autohotkey is blocking propagation then the DLL won't get it.
2) If AHK doesn't have a blocking hotkey it gets passed to active as well as wherever I redirect it to.
According to the autohotkey documentation OnMessage callbacks can return an integer to prevent the message being passed on, however doing so doesn't prevent the WM_INPUT message being passed on. This is possibly because the message arrives elsewhere first? Or WM_INPUT generates separate messages for each window registered? Or perhaps the application is receiving a completely different message which is allowing it to receive the keypress.
It is possible that modifying autohotkey to set a variable upon a hotkey to detect which keyboard it was called from rather than using this DLL for the purpose is easier. Autohotkey is already able to prevent message propagation and also handles regular keyboard input. It works well for detecting multimedia keys however, provided that no action was already mapped (which could be a problem for Vista users).
Hopefully I have given those with more Win32 experience than I something useful to help solve this. I am by no means an expert so take what I have said with the appropriate cautions. |
|
| Back to top |
|
 |
darkangael
Joined: 18 Jun 2007 Posts: 3
|
Posted: Thu Jul 26, 2007 5:10 pm Post subject: |
|
|
After looking at the AHK source code I can see that seeing what device caused an input wouldn't be easy at all, it may not even be possible without a lot of rewriting as the keyboard hook method doesn't expose this information.
I have another idea of how to approach the problem although it probably won't work. I'll let you know how I go.
EDIT: My idea was to set a flag via the DLL when an input was received stating which device it was from. The hotkey would then pick this flag up. Of course this didn't work as the hook picks it up first and blocks the event from reaching the DLL callback. With the tilde prefix it works somewhat curiously. While the hotkey FIRES first, it still appears to receive the result from the callback and uses it. This was a consistent result. Either way I think it's a dead end.
Another interesting thing I noted was that the hotkey wasn't received when the script's gui (a keyboard log) was active. This wasn't the window that I registered the callback with, however.
I think in terms of using this DLL to detect input from additional keyboards/mice we would need to discover why returning an integer doesn't block the propagation of the message. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Mon Jul 30, 2007 5:04 pm Post subject: |
|
|
Thanks for posting your findings. They will be useful to me when the time comes to work on support for alternate input devices (including multiple keyboards and mice).
I don't know why OnMessage can't block WM_INPUT. Perhaps the OS has special low-level handling for it that makes it behave differently than other messages. |
|
| Back to top |
|
 |
eph Guest
|
Posted: Tue Aug 14, 2007 10:52 am Post subject: |
|
|
I don't know if Micha is still frequenting the forum, but maybe others have any clue too..?
I'm on Vista Home Premium 64 bit.
My Sony Ericsson K510 phone supports HID profiles (you can even make your own, like on all SE Bluetooth phones).
The MOUSE device works without problem; but every time I try to register its KEYBOARD device, it crashes silently after the first keypress on the phone..
Would be nice to get it working though, I think the API didn't change (much) with Vista, so my guess is that this is not where the problem is related. But this is above my head anyway..
Ideas / fixes? |
|
| Back to top |
|
 |
selyb
Joined: 20 Jul 2007 Posts: 7
|
Posted: Sun Aug 19, 2007 7:21 am Post subject: |
|
|
IF i understood correctly, several people asked about preventing some multimedia keys from reaching the active window when AHK captures them
the most efficient (probably) method i have found to do this is using the registry to remap some keys
basically you can remap any key on your keyboard that produces a scancode to another scancode
this happens transparently and at a lower level than any other method i've seen
at this moment (1am) i cant remember exactly what key or the format to use
i believe its something like HKLM\Software\Microsoft\Windows\IniFileMapping
keytweak is a program that aids with this but it is limited and doesnt support multimedia keys AFAIK
you can search for posts made by me on the promixis forums for some good info and links about this method |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 433 Location: Germany
|
Posted: Mon Aug 27, 2007 9:50 pm Post subject: |
|
|
Hi,
I've found time to have a look at the dll and I've found bugs!
The dll returns 00 04 00 and the values are converted to 00 52 00 from the script.
Please download the archive (link is in the first post) and try the new AutoHotkeyRemoteControlDLL.ahk
Now you shouldn't have 2 keys with the same value or keys with changing values each time you press them.
You can see the number of the device which sent the latest data.
If you still have problems, please post them
Ciao
Micha
(feeling ashamed for answering soooo late) |
|
| Back to top |
|
 |
boulder
Joined: 28 Jul 2007 Posts: 3
|
Posted: Tue Aug 28, 2007 6:02 pm Post subject: Using the MCE remote in mulitple programs |
|
|
I 've written 2 separate AHK files, based on Micha's great DLL and script (thanks Micha for your great work) one for using my MCE remote in Mediacenter (reusing the coloured Teletext buttons at the bottom, as well as the * and # key), and another one for Media Player Classic, in which I reuse almost all keys on the remote.
Now, the difficulty I have is in using the IfWinActive or #IfWinActive functions, so that I can have one set of functions in one program, and another in the other program.
It seems that they simply have no effect, and if I press the red button in a command prompt with Mediacenter not running, it still triggers the function I mapped to that button.
So I am wondering, does the fact that one is using an extra DLL make it impossible for those functions to work, or is it because of the Onmessage function ?
I suppose I made some beginner's mistakes, as this is only the second script I created.
BTW : this one does not contain the ones from Media Player Classic, just the MCE ones.
I did not know where to put the #IfWinActive, or whether it would be better to use a IfWinActive instead.
While experimenting, I often got errors about not being able to call a function from within a function.
| Code: | ;HomePath=F:\myprg\Win\Autohotkeyremote\AutohotkeyRemoteControl\release\AutohotkeyRemoteControl.dll
;Path to the dll
HomePath="C:\Program Files\Autohotkey\AutohotkeyRemoteControl.dll
"
;Load the dll
hModule := DllCall("LoadLibrary", "str", HomePath) ; Avoids the need for DllCall() in
;If a WM_INPUT-message arrives, call the funtion InputMsg
#IfWinActive ahk_class eHome Render Window
OnMessage(0x00FF, "InputMsg")
#IfWinActive
DetectHiddenWindows, on
;When you change the source of this script, it is reloading automaticly
SetTimer,UPDATEDSCRIPT,1000
;IMPORTANT: These are the values for the device. Use the other script to find the correct values for your device
EditUsage = 136
EditUsagePage = 65468
;As written at the homepage, you must pass a HWND to the Registerdevice-function. I cheated by creating a new
;windows and hiding it. Chris wrote that the following lines workes without my cheat
DetectHiddenWindows On
HWND := WinExist(A_ScriptFullPath . " ahk_class AutoHotkey")
;Gui, Show, x0 y0 h0 w0, Autohotkey HID-Support
;HWND := WinExist("Autohotkey HID-Support")
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox RegisterDevice fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
;My Remotecontrol is shown as two devices. A block of the remote control is initialized few line above, here
;I initialize the second block of keys on the remote control.
EditUsage = 1
EditUsagePage = 12
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
Winhide, Autohotkey HID-Support
return
;This function is called, when an WM_INPUT-message arrives.
;You see a lot of msgbox-entries which are commented out. I used them for debugging
InputMsg(wParam, lParam, msg, hwnd)
{
local Vals
;Max Size of data we can process from a device. Should be enough
DataSize = 5000
VarSetCapacity(RawData, %DataSize%)
;MsgBox arrived %wParam% %lParam% %msg% %HWND%
nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDData", UINT, wParam, UINT, lParam, "UINT *" , DataSize, "UINT *", RawData, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
loop, %DataSize%
{
Zeichen := ExtractInteger(RawData, A_Index, false, 1)
ifless, Zeichen, 9
{
Zeichen= 0%Zeichen%
}
Vals = %Vals%%Zeichen%
}
;The var Vals contains the values of your remote control.
;In the next block you can jump to the function which sends keys to your app or is doing what you want
;if the desired message arrives. You can name the labels as you want. I used the chars of my remote ctrl
ifequal, Vals, 5150, gosub RED
ifequal, Vals, 5153, gosub GREEN
ifequal, Vals, 5156, gosub YELLOW
ifequal, Vals, 5248, gosub BLUE
}
return
RED:
;Red button is remapped to Ctrl+Shift+Z, which cycles through the zoom modes in Mediacenter
Send, ^+z
return
GREEN:
;Green button is remapped to Ctrl+shift+c, which turns on/off closed captions/TT subtitles
Send ^+c
return
YELLOW:
;Yellow button is remapped to Ctrl+A, which starts MCE's radio
Send ^a
return
BLUE:
;Blue button takesyou to the Scheduled recordings
Send ^o{Up}{Up}{Enter}
return
8::
;This actually refers to the asterisk key on the remote
;This button is now remapped to Alt+Enter, which toggles between fullscreen mode and windowed mode
Send !{ENTER}
return
3::
;This actually refers to the # key on the remote
;This button is now remapped to Alt+F4, which closes Mediacenter
Send!{F4}
return
cleanup:
DllCall("FreeLibrary", "UInt", hModule) ; It is best to unload the DLL after using it (or before the script exits).
ExitApp
ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
; The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
; pSource must be ByRef to avoid corruption during the formal-to-actual copying process
; (since pSource might contain valid data beyond its first binary zero).
{
SourceAddress := &pSource + pOffset ; Get address and apply the caller's offset.
result := 0 ; Init prior to accumulation in the loop.
Loop %pSize% ; For each byte in the integer:
{
result := result | (*SourceAddress << 8 * (A_Index - 1)) ; Build the integer from its bytes.
SourceAddress += 1 ; Move on to the next byte.
}
if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
return result ; Signed vs. unsigned doesn't matter in these cases.
; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
return -(0xFFFFFFFF - result + 1)
}
return
;reload the script if you changed it with your editor
UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Updated script,
Sleep,500
Reload
}
Return
|
|
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6560 Location: Pacific Northwest, US
|
Posted: Tue Aug 28, 2007 6:24 pm Post subject: |
|
|
#IfWinActive only affects hotkey labels (ending in ::); it does not affect your OnMessage. The label called by OnMessage should check the active window using IfWinActive. Don't put an IfWinActive above the OnMessage. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 433 Location: Germany
|
Posted: Tue Aug 28, 2007 8:55 pm Post subject: |
|
|
Hi,
I've written a sample script.
It uses an ini file.
| Code: | [RemoteControl]
Entrycount=9
1=Homepage;PSPad;Homepagebutton in PsPad
2=Homepage;Dokument1 - Microsoft Word;HomepageButton in Word
3=Homepage;Microsoft Excel;HomepageButton in Excel{enter}
4=RedButton;PSPad;RedButton in PsPad
5=RedButton;Dokument1 - Microsoft Word;RedButton Button in Word
6=RedButton;Microsoft Excel;RedButton in Excel{enter}
7=GreenButton;PSPad;GreenButton in PsPad
8=GreenButton;Dokument1 - Microsoft Word;GreenButton Button in Word
9=GreenButton;Microsoft Excel;GreenButton in Excel{enter} |
the first number is an incremental number
the values (after the equal sign) are seperated by the character ;
RedButton: Name of the Button
PsPad: Title of the application
textextext: This text is sent to the current application
The script calls the function DoKey with the name of the button as parameter (same value as in the ini file)
| Code: | Homepg:
DoKey("Homepage")
return
RED:
DoKey("RedButton")
return |
Please have a look at the scripts:
http://www.autohotkey.net/~Micha/HIDsupport/RemoteControlMultiWnd.ini
http://www.autohotkey.net/~Micha/HIDsupport/RemoteControlMultiWnd.ahk
Ciao
Micha |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Aug 30, 2007 11:42 am Post subject: |
|
|
It 's working a lot better now, most keys respond as I want them to.
There is just one thing which I would like to achieve that is quite complicated and I wonder if it can be done at all.
I would like to have the FFWD and REWD (double arrow keys) to respond as in Mediacenter.
In Mediacenter, if you press it once, it repeatedly skips a certain time interval.
You can release the key and it will keep skipping, until you press the pause or the play key.
If you press the same FFWD key again, it will skip in larger time intervals.
Again it will do this automatically until you press another key such as play or pause, or stop.
So there are 4 different speed settings.
I assume I could use a variable to keep track of the current speed.
Question is : how do I make it loop UNTIL another key is pressed ?
I would need to make a loop and in that loop, check the keys again.
If the same key is pressed I would need to change the value of the speed settings, and send a different keystroke to Media Player Classic.
If another key is pressed, then it should quit the loop and process that other key.
Do you think it can be done or is this too complex ? |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 433 Location: Germany
|
Posted: Thu Aug 30, 2007 8:20 pm Post subject: |
|
|
Hi "Guest",
this can be done in the script.
Whenever a key is pressed, the OnMessage function is called. Within this function you can call another function (i.e. AccelDeccel(key))
Within this function you can keep track the last used key.
*If there is no last key, start a timer which sends the desired key to the application
* If the key is the same, accelerate (Set timerintervall faster) (you have to know what keys to send to your application to achive fast forward)
* If the key is different stop the timer and remove the last used key
Hope this helps a little bit
Ciao
Micha |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|