AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AHKHID - An AHK implementation of the HID functions
Goto page Previous  1, 2, 3 ... 5, 6, 7 ... 24, 25, 26  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
bidomo



Joined: 05 Feb 2009
Posts: 59

PostPosted: Sat Jun 13, 2009 9:19 am    Post subject: Reply with quote

I like AHKHID for my remote that much, I refuse to not use it! Thanks for AHKHID.

The Play and pause buttons should be separated for MCE, allows me to remove the playback OSD (pressing play twice, and I get my Thumb workout too!!!), unless I find a nice replacement for MCE (tried a lot of them, but MCE stills ahead), and if some other Software convinces me, MCE will have to pray for his life (and bye to my badass thumb...).

I will be digging a lot more in my free time.


Forgot to say, ControlSend doesn't work with MCE, and I don't see how PostMessage can help, as I get nothing from winspector, and that's how I found that info, thanks to failure.
Back to top
View user's profile Send private message
bxr



Joined: 07 Mar 2009
Posts: 9

PostPosted: Mon Jun 15, 2009 2:41 pm    Post subject: MCE remote - How do you make AHKHID pressed exclusive? Reply with quote

In another words, how do you disable the original key presses of the MCE remote such as 0-9 numbers and replace them?
Back to top
View user's profile Send private message
MonsterMash
Guest





PostPosted: Tue Jun 16, 2009 3:27 pm    Post subject: Reply with quote

Hi,
i don't know if this is the right place to ask for, but i need help.
I want to intercept the press of special keys on my Media center remote controller (as the red, green, yellow and blue keys), and use them in a autohotkey script. Is it possible? And how?

Thank you.

Bye.
Back to top
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Tue Jun 16, 2009 4:34 pm    Post subject: Reply with quote

bidomo wrote:
Forgot to say, ControlSend doesn't work with MCE, and I don't see how PostMessage can help, as I get nothing from winspector, and that's how I found that info, thanks to failure.

Can't you use SendInput? Or is the MCE interface not always in the foreground? I don't see why ControlSend shouldn't work. Did you check with Winspector to make sure that MCE receives the keys sent by ControlSend? Try also doing (for example if you're trying to send the A key):
Code:
        Send {a Down}
        Sleep 50
        Send {a Up}


bxr wrote:
In another words, how do you disable the original key presses of the MCE remote such as 0-9 numbers and replace them?

Look here. Smile
And here's the relevant section:
Quote:
On the other hand, if you do end up finding an entry in the Other section of Example 1, then you can make the remote stop generating those keyboard presses by doing the following steps:
1. Go to Device Manager
2. Expand the "Keyboards" tree
3. You should find a device (ie. your remote registered as a keyboard) other than your usual keyboard there. To make sure it is indeed your remote, you can compare the name you found in Example 1 with the name you'll find when you right-click>Properties>Details on the keyboard item in Device Manager.
4. Once you found the keyboard entry associated to your Kensington Presentation remote, right-click the item and select Uninstall


MonsterMash wrote:
Hi,
i don't know if this is the right place to ask for, but i need help.
I want to intercept the press of special keys on my Media center remote controller (as the red, green, yellow and blue keys), and use them in a autohotkey script. Is it possible? And how?

Hello MonsterMash,
Please follow the tutorial you'll find in the second post of this thread.
Back to top
View user's profile Send private message Visit poster's website
MonsterMash
Guest





PostPosted: Tue Jun 16, 2009 9:14 pm    Post subject: Reply with quote

TheGood wrote:

MonsterMash wrote:
Hi,
i don't know if this is the right place to ask for, but i need help.
I want to intercept the press of special keys on my Media center remote controller (as the red, green, yellow and blue keys), and use them in a autohotkey script. Is it possible? And how?

Hello MonsterMash,
Please follow the tutorial you'll find in the second post of this thread.


Hi, thank you! But i need much help. If i'm right, the following function is the most important:

Code:
InputMsg(wParam, lParam) {
    Local devh, iKey, sLabel
   
    Critical
   
    ;Get handle of device
    devh := HID_GetInputInfo(lParam, II_DEVHANDLE)
   
    ;Check for error
    If (devh <> -1) ;Check that it is my HP remote
        And (HID_GetDevInfo(devh, DI_DEVTYPE, True) = RIM_TYPEHID)
        And (HID_GetDevInfo(devh, DI_HID_VENDORID, True) = 1118)
        And (HID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 109)
        And (HID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 272) {
       
        ;Get data
        iKey := HID_GetInputData(lParam, uData)
       
        ;Check for error
        If (iKey <> -1) {
           
            ;Get keycode (located at the 6th byte)
            iKey := NumGet(uData, 5, "UChar")
           
            ;Call the appropriate sub if it exists
            sLabel := sPrefix "_" iKey
            If IsLabel(sLabel)
                Gosub, %sLabel%
        }
    }
}


First of all, i don't understand what are wParam and lParam passed to this function. Can you light me?
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Wed Jun 17, 2009 7:06 am    Post subject: Reply with quote

Example 2 contains OnMessage(0x00FF, "InputMsg"); this causes InputMsg() to be called whenever the script receives a WM_INPUT message. 0x00FF is the numerical value of WM_INPUT as defined in the Windows SDK. The script must register for Raw Input before it will receive WM_INPUT messages; Example 2 demonstrates how. You should not be calling InputMsg() directly. WM_INPUT Notification at MSDN describes how lParam and wParam may be interpreted and Raw Input contains an overview of the Raw Input/HID API. You probably don't need that much detail if you're using TheGood's script, though.
Back to top
View user's profile Send private message Visit poster's website
MonsterMash
Guest





PostPosted: Wed Jun 17, 2009 10:38 am    Post subject: Reply with quote

Lexikos wrote:
Example 2 contains OnMessage(0x00FF, "InputMsg"); this causes InputMsg() to be called whenever the script receives a WM_INPUT message. 0x00FF is the numerical value of WM_INPUT as defined in the Windows SDK. The script must register for Raw Input before it will receive WM_INPUT messages; Example 2 demonstrates how. You should not be calling InputMsg() directly. WM_INPUT Notification at MSDN describes how lParam and wParam may be interpreted and Raw Input contains an overview of the Raw Input/HID API. You probably don't need that much detail if you're using TheGood's script, though.


Thank you! Finally i began to understand something Very Happy.

I made some experiment, and wrote this code:

Code:

#Include %A_ScriptDir%\AHKHID.ahk


hGui := WinExist()

;Intercept WM_INPUT messages
WM_INPUT := 0xFF
OnMessage(WM_INPUT, "InputMsg")

;Register Remote Control with RIDEV_INPUTSINK (so that data is received even in the background)
r := HID_Register(65468, 137, hGui, RIDEV_INPUTSINK)


InputMsg(wParam, lParam) {
    Local devh, iKey, sLabel
   
    Critical
   
    ;Get handle of device
    devh := HID_GetInputInfo(lParam, II_DEVHANDLE)
   
    ;Check for error
    If (devh <> -1) ;Check that it is my HP remote
        And (HID_GetDevInfo(devh, DI_DEVTYPE, True) = RIM_TYPEHID)
        And (HID_GetDevInfo(devh, DI_HID_VENDORID, True) = 1118)
        And (HID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 109)
        And (HID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 272) {
       
        ;Get data
        iKey := HID_GetInputData(lParam, uData)
       
        ;Check for error
        If (iKey <> -1) {
           
            ;Get keycode (located at the 6th byte)
            iKey := NumGet(uData, 5, "UChar")
       inputChecker(iKey)
        }
    }
}

print(iKey, iDescription)
{
IfWinExist Magnifier
WinClose ; close magnifier if it's open
Progress, B2 fs24 zh0 WS700 CW0E4D9A CTFFFFFF, Key Code: %iKey% - Key Name: %iDescription%, , , Courier New ; show last keypress onscreen
SetTimer, RemoveNotice, 3000 ; remove key notice after 3 seconds
}

inputChecker(iKey)
{
if iKey = 36
iDescription := DVD Menu
else if iKey = 12
iDescription := Power
else if iKey = 70
iDescription := TV
else if iKey = 80
iDescription := Radio
else if iKey = 71
iDescription := Music
else if iKey = 73
iDescription := Pictures
else if iKey = 74
iDescription := Videos
else if iKey = 23
iDescription := Record
else if iKey = 21
iDescription := Rewind
else if iKey = 27
iDescription := Replay/Previous Track
else if iKey = 22
iDescription := Play
else if iKey = 24
iDescription := Pause
else if iKey = 25
iDescription := Stop
else if iKey = 20
iDescription := Forward
else if iKey = 26
iDescription := Skip/Next Track
else if iKey = 35
iDescription := Back
else if iKey = 15
iDescription := More/Information
else if iKey = 30
iDescription := Up Arrow
else if iKey = 32
iDescription := Left Arrow
else if iKey = 33
iDescription := Right Arrow
else if iKey = 31
iDescription := Down Arrow
else if iKey = 34
iDescription := OK
else if iKey = 16
iDescription := Volume Up
else if iKey = 17
iDescription := Volume Down
else if iKey = 13
iDescription := Windows Media Center
else if iKey = 14
iDescription := Mute
else if iKey = 18
iDescriptioin := Channel/Page Up
else if iKey = 19
iDescription := Channel/Page Down
else if iKey = 71
iDescription := Live TV
else if iKey = 38
iDescription := Guide
else if iKey = 72
iDescription := Recorded TV
else if iKey = 1
iDescription := 1
else if iKey = 2
iDescription := 2/ABC
else if iKey = 3
iDescription := 3/DEF
else if iKey = 4
iDescription := 4/GHI
else if iKey = 5
iDescription := 5/JKL
else if iKey = 6
iDescription := 6/MNO
else if iKey = 7
iDescription := 7/PQRS
else if iKey = 8
iDescription := 8/TUV
else if iKey = 9
iDescription := 9/WXYZ
else if iKey = 29
iDescription := *
else if iKey = 0
iDescription := 0
else if iKey = 28
iDescription := #
else if iKey = 10
iDescription := Clear
else if iKey = 78
iDescription := Print
else if iKey = 11
iDescription := Enter
print(iKey, iDescription)
Return
}

RemoveNotice:
SetTimer, RemoveNotice, Off
Progress, Off
return


In my mind this must notify on screen every time i press a key on my remote controller, and write the key code and a key description. But it does not work.
What did i wrong?

Thank you again.
Bye.
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Wed Jun 17, 2009 11:16 am    Post subject: Reply with quote

The most obvious problem is the recurring syntax error:
Code:
iDescription := DVD Menu   ; bad
iDescription := "DVD Menu" ; good
iDescription = DVD Menu    ; good
Back to top
View user's profile Send private message Visit poster's website
bidomo



Joined: 05 Feb 2009
Posts: 59

PostPosted: Wed Jun 17, 2009 4:53 pm    Post subject: Re: MCE remote - How do you make AHKHID pressed exclusive? Reply with quote

bxr wrote:
In another words, how do you disable the original key presses of the MCE remote such as 0-9 numbers and replace them?


You can find detailed info (which I'd tried to explain before in page 5) here http://mediacenterguides.com/sites/default/files/IRCodes_ReportMappingTable_InputINF.pdf (the pdf is not mine)

this reg file will disable 0-9 for you...


Code:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HidIr\Remotes\745a17a0-74d3-11d0-b6fe-00a0c90f57da]
"ReportMappingTable"=hex:01,00,00,00,00,00,00,02,00,00,00,00,00,00,03,00,00,00,\
    00,00,00,04,00,00,00,00,00,00,05,00,00,00,00,00,00,06,00,00,00,00,00,00,07,\
    00,00,00,00,00,00,08,00,00,00,00,00,00,09,00,00,00,00,00,00,00,00,00,00,00,\
    00,00,
0b,00,00,00,04,08,58,0a,00,00,00,04,00,29,1f,00,00,00,04,00,51,1e,00,\
    00,00,04,00,52,21,00,00,00,04,00,4f,20,00,00,00,04,00,50,22,00,00,00,04,00,\
    28,4e,00,00,00,04,08,45,0f,00,00,00,01,09,02,23,00,00,00,01,24,02,16,00,00,\
    00,01,b0,00,18,00,00,00,01,b1,00,17,00,00,00,04,08,52,14,00,00,00,01,b3,00,\
    15,00,00,00,01,b4,00,1a,00,00,00,01,b5,00,1b,00,00,00,01,b6,00,19,00,00,00,\
    01,b7,00,6e,00,00,00,01,cd,00,10,00,00,00,01,e9,00,11,00,00,00,01,ea,00,0e,\
    00,00,00,01,e2,00,26,00,00,00,01,8d,00,12,00,00,00,01,9c,00,13,00,00,00,01,\
    9d,00,0c,00,00,00,04,09,2b,2a,00,00,00,03,82,00,34,00,00,00,04,08,51,1c,00,\
    00,00,04,08,58,
"CodeSetNum0"=dword:00000001
"CodeSetNum1"=dword:00000002
"CodeSetNum2"=dword:00000003
"CodeSetNum3"=dword:00000004


NOTES:
Code:

In this reg file:
Power            = Ctrl + Win + Tab
Vizualization    = Ctrl + Esc
#                = Win + Intro
Rec              = Win + Up
Eject            = Win + Down



TheGood wrote:

Can't you use SendInput? Or is the MCE interface not always in the foreground?


Every send mode works while MCE is in the foreground, but ControlSend won't work in foreground neither background.

I'm gonna try again and check window spy


Last edited by bidomo on Wed Jun 17, 2009 10:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Wed Jun 17, 2009 5:37 pm    Post subject: Reply with quote

Thanks bidomo.
I haven't looked at the PDF file in-depth yet, but when I do, I will modify the first post to show how to use this method to disable keypresses.
Back to top
View user's profile Send private message Visit poster's website
MonsterMash
Guest





PostPosted: Wed Jun 17, 2009 6:30 pm    Post subject: Reply with quote

Lexikos wrote:
The most obvious problem is the recurring syntax error:
Code:
iDescription := DVD Menu   ; bad
iDescription := "DVD Menu" ; good
iDescription = DVD Menu    ; good


Thank you, i'm not so expert in this language.

But also with these modifications the script does not work. There must be something else...

Thank you.
Back to top
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Wed Jun 17, 2009 6:40 pm    Post subject: Reply with quote

MonsterMash,
Do you have exactly the same remote as me? (I see you're using the same ProductID, VendorID, etc... as me).
Also, you should debug it, using MsgBoxes or OutputDebug (more recommended), to see where exactly you lose contact.
Back to top
View user's profile Send private message Visit poster's website
MonsterMash
Guest





PostPosted: Wed Jun 17, 2009 8:43 pm    Post subject: Reply with quote

TheGood wrote:
MonsterMash,
Do you have exactly the same remote as me? (I see you're using the same ProductID, VendorID, etc... as me).
Also, you should debug it, using MsgBoxes or OutputDebug (more recommended), to see where exactly you lose contact.


My remote isn't the same of the your, but using your example2 i saw that all parameters are the same (ProductId, VendorId, VersionNumber, Usage Page and Usage).

I don't know most of IO functions, now i will look for some documentation about MshBox and OutputDebug.

Thank you, bye.
Back to top
MonsterMash
Guest





PostPosted: Thu Jun 18, 2009 12:50 am    Post subject: Reply with quote

I found my error: forgot
Code:
Gui, +LastFound

at the beginning of the script.

Now it works perfectly. Smile


Thank you all.


Bye
Back to top
Xizzzy



Joined: 06 Jun 2009
Posts: 9
Location: Here

PostPosted: Sat Jun 20, 2009 11:19 pm    Post subject: Example 2 problem Reply with quote

I followed the instructions through Example 1 and got the device's

Vendor ID = 2683
Product ID = 53248
Version Number = 1
Usage Page = 1
Usage = 4

Then I input the usage page and usage value into example 2 and added then called so I could start getting the raw data and data started flooding into the listbox. It never stopped. So I'm at a loss for what to do next since its almost impossible for me to extract any data from it.

This is the HID I want to bend to my will.
http://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Steel_Battalion_controllers.jpg/800px-Steel_Battalion_controllers.jpg

Certain buttons do accept commands from autohotkey but there are other areas of the Joystick that dont like the tuner dial + toggle switches + Communication buttons

This is where I got the drivers which were made specifically for connecting the Joystick to the computer.
http://vt.beckament.net/

I used a USB adapter that allows me to plug Xbox controls to the PC for the connection.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 5, 6, 7 ... 24, 25, 26  Next
Page 6 of 26

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group