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 ... 11, 12, 13 ... 24, 25, 26  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Michael@Oz



Joined: 08 Nov 2009
Posts: 233
Location: Canberra Oz

PostPosted: Fri Apr 02, 2010 9:34 pm    Post subject: Reply with quote

Is there a special driver for it perhaps'
Back to top
View user's profile Send private message
msafi



Joined: 15 Apr 2009
Posts: 21

PostPosted: Fri Apr 02, 2010 10:25 pm    Post subject: Reply with quote

Michael@oz wrote:
Is there a special driver for it perhaps'

Yes, it is made by Lenovo. I don't want to remove it because I want to add to its functionality not rewrite it entirely.
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Sat Apr 03, 2010 2:24 pm    Post subject: Reply with quote

msafi wrote:
I have a ThinkPad laptop with a three button mouse. I couldn't find a way to detect the center button. When I press it, ButtonFlags, ButtonData, and every thing else shows 0. Any ideas how to detect that button?

Thanks,

Your issue sounds very familiar to this user's. Check my response here, which I've recopied here:

Quote:
This issue isn't isolated to your mouse. For example, the mouse wheel tilt isn't natively supported by XP. You need to install the IntelliMouse program in order to use it. Regardless (with or without IntelliMouse), AHKHID cannot differentiate the tilts, and only reports empty messages, exactly like in your case. Simply put, if AHKHID sends back empty messages, then it means that the button isn't natively supported by the raw input device interface.

Although using AHKHID is out of the window, you may be able to use the buttons by installing the proper software. For example, in the case of the mouse wheel tilt, installing IntelliMouse in XP/2000 allows programs to receive a WM_MOUSEHWHEEL message, which you can capture by using an OnMessage function in your script. Hope this helps!
Back to top
View user's profile Send private message Visit poster's website
msafi



Joined: 15 Apr 2009
Posts: 21

PostPosted: Sat Apr 03, 2010 8:19 pm    Post subject: Reply with quote

TheGood,

I have the drivers installed. But I don't know what they cause the button press to send. It's not a standard thing like WM_MOUSEWHEEL. How can I know what message is sent by this button and then capture that message with AHK?

Thanks,

MK
Back to top
View user's profile Send private message
Michael@Oz



Joined: 08 Nov 2009
Posts: 233
Location: Canberra Oz

PostPosted: Sat Apr 03, 2010 11:26 pm    Post subject: Reply with quote

See this for how to trace messages.

Note Winspector Spy is no longer available at that address, see the link at the bottom of SKANs post here.
Back to top
View user's profile Send private message
msafi



Joined: 15 Apr 2009
Posts: 21

PostPosted: Sun Apr 04, 2010 6:18 am    Post subject: Reply with quote

Michael,

Thanks for the links.

I used Winspector to monitor windows while I use the mystery button on them but simply pressing the mystery button doesn't send any messages to those windows.

The (mystery) center button is used for scrolling. It allows users to scroll by moving the pointing stick while it's pressed.

So, when I simply press the button, no messages are sent, but when I move the pointing stick while the button is pressed, WM_MOUSEWHEEL and sometimes WM_VSCROLL are sent. I'm not interested in those.

I think the driver listens for the button press, but I don't know what it's listening for. In Winspector, I opened a lot of the seemingly relevant processes and windows to see what messages are sent to them when the button is pressed, but I couldn't see anything...

Any more ideas? Sad
Back to top
View user's profile Send private message
Maiklas3000



Joined: 25 Mar 2010
Posts: 9

PostPosted: Sun Apr 04, 2010 12:04 pm    Post subject: Reply with quote

msafi wrote:

Any more ideas? Sad

Run AHKHID's example1.ahk, select "other", scroll to right, take note of Usage Page + Usage numbers. Run example2.ahk, input Usage Page and usage, press add and call, then press the mystery button. If you see nothing, repeat with next Usage Page and Usage.
Back to top
View user's profile Send private message
msafi



Joined: 15 Apr 2009
Posts: 21

PostPosted: Sun Apr 04, 2010 12:40 pm    Post subject: Reply with quote

Maiklas3000 wrote:
msafi wrote:

Any more ideas? Sad

Run AHKHID's example1.ahk, select "other", scroll to right, take note of Usage Page + Usage numbers. Run example2.ahk, input Usage Page and usage, press add and call, then press the mystery button. If you see nothing, repeat with next Usage Page and Usage.


There isn't anything in the "Other" tab. The laptop comes with two navigation devices. The TrackPoint, which is what I'm interested in, and a touchpad. Both devices show in the "Mice" tab. See screenshot:



I tried to use Example 2 script with 1 and 2 values for Usage Page and Usage. But like I said, everything shows 0.

EDIT: actually, I'm not sure the two records shown in the screenshot above represent the TrackPoint and the touchpad. Because one of them shows 5 buttons, which is the total number of buttons in both, the TrackPoint and the touchpad...


Last edited by msafi on Tue Apr 13, 2010 4:35 am; edited 1 time in total
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Sun Apr 04, 2010 2:55 pm    Post subject: Reply with quote

msafi wrote:
So, when I simply press the button, no messages are sent, but when I move the pointing stick while the button is pressed, WM_MOUSEWHEEL and sometimes WM_VSCROLL are sent. I'm not interested in those.

Whatever that button does is simply not supported by AHKHID. The driver you have installed is able to receive input from it at a lower level than AHKHID can, and translates that input into the proper scroll wheel event, like you mentioned. So those WM_MOUSEWHEEL and WM_VSCROLL messages are probably the only visible things that occur.

The best thing you can do in cases like these is to go in the driver's options and see if you can attach a hotkey combination/program launch/anything useable by AHK.
Back to top
View user's profile Send private message Visit poster's website
msafi



Joined: 15 Apr 2009
Posts: 21

PostPosted: Sun Apr 04, 2010 3:55 pm    Post subject: Reply with quote

TheGood wrote:
The best thing you can do in cases like these is to go in the driver's options and see if you can attach a hotkey combination/program launch/anything useable by AHK.

Assigning different functionality to the mystery button through the drivers options would disable the ability to use the scrolling functionality of it. That's not what I want.

The makers of this mouse, Synaptics, provide API to their drivers! Unfortunately, I don't know how to use this API with AHK or natively.

I hope some day before I die I'll finally get my head around Win API. Meanwhile, I posted a request/job on RentACoder.com.
Back to top
View user's profile Send private message
bidomo



Joined: 05 Feb 2009
Posts: 59

PostPosted: Sat Apr 10, 2010 1:54 am    Post subject: Reply with quote

A while ago a was saying there could be a problem with the way AHK handles Windows 7, something about AHKHID not working or something alike...


Well, found out something:

Code:

01 01 00 00 00 32 84 0F 80 20 00 00 00                                          Visualization for XP
IR code Goes from 00 to 12 byte length (13 bytes)
01 01 00 00 00 00 00 00 00 32 84 0F 80 00 00 00 00 20 00 00 00 80 FA FF FF      Visualization for Windows 7
IR code Goes from 00 to 24 byte length (25 bytes)


Already tried switching 6th byte for 9th for the remote code, and 7th byte for the 10th byte to check the verifier byte (if is HP Remote), wont work...

Code:

        If (NumGet(uData, 10, "UChar") = 132) or (NumGet(uData, 10, "UChar") = 4)
        {   ;IT'S THE REMOTE
            If (iKey <> -1)
            {
                ;Get keycode (located at the 6th byte)
                iKey := NumGet(uData, 9, "UChar")
               
               
                ;Set prefix
                sDevicePrefix := "HPRem"
               
                ;We're gonna have to call
                bCallEvent := True
               
            }
        }


What could still be wrong???
Anything else AHK works OK in 7, only Remote script is left.

Any help will be appreciated


.::Edit::.

Something changed... updated to latest version of everything (COM, AHKHID), no more 24 bytes, just 14.


Code:
01 01 00 00 00 00 00 00 00 1A 04 0F 80 00 00



Already updated script to reflect the functions names and I'm putting just the relevant part of the script

Code:

; 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 12 17 18 19 20 21 22 23 24
;
;01 01 00 00 00 00 00 00 00 32 84 0F 80 00 00 00 00 20 00 00 00 80 FA FF FF   Vizualize for Windows 7
;01 01 00 00 00 32 84 0F 80 20 00 00 00                              Vizualize for XP
;
;Must be in auto-execute section if I want to use the constants
#Include %A_ScriptDir%\AHKHID.ahk

;Create GUI to receive messages
Gui, +LastFound
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 := AHKHID_Register(65468, 137, hGui, RIDEV_INPUTSINK)

;Prefix loop
Loop
{
    Sleep 1000
    If WinActive("ahk_class Winamp v1.x") Or WinActive("ahk_class Winamp EQ") Or WinActive("ahk_class Winamp PE") Or WinActive("ahk_class Winamp Gen")
        sPrefix := "Winamp"
    Else If WinActive("ahk_class MediaPlayerClassicW")
        sPrefix := "MPC"
    Else If WinActive("ahk_class eHome Render Window")
        sPrefix := "VMC"
    Else If WinActive("ahk_class MozillaUIWindowClass")
        sPrefix := "Youtube"
    Else If WinActive("ahk_class ShockwaveFlashFullScreen")
        sPrefix := "YoutubeFS"
    Else
    {
        sPrefix  := "Default"
    }
}

Return

InputMsg(wParam, lParam)
{
    Local devh, iKey, sLabel, bCallEvent
   
    Critical
   
    ;Get handle of device
    devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
   
    ;Check for error
    If (devh <> -1) ;Check that it is my HP remote
        And (AHKHID_GetDevInfo(devh, DI_DEVTYPE, True) = RIM_TYPEHID)
        And (AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True) = 1118)
        And (AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 109)
        And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 272)
    {
       
        ;Get data
        iKey := AHKHID_GetInputData(lParam, uData)
       
        ;Check for error
     
        If (NumGet(uData, 10, "UChar") = 132) or (NumGet(uData, 10, "UChar") = 4)  ; Tried A instead of 10
        {   ;IT'S THE REMOTE

            If (iKey <> -1)
            {
                ;Get keycode (located at the 6th byte)
                iKey := NumGet(uData, 9, "UChar")
               
               
                ;Set prefix
                sDevicePrefix := "HPRem"
               
                ;We're gonna have to call
                bCallEvent := True
               
            }
        }
;;This part of the xbox 1 remote can be totally ignored, as I'll probably have to remove it.
        else If (NumGet(uData, 9, "UChar") = 24)
        {   ;IT'S THE XBOX1 controller
            If (iKey <> -1)
            {
                ;Get keycode (located at the 6th byte)
                iKey := NumGet(uData, 5, "UChar")
               
                ;Set prefix
                sDevicePrefix := "XBOX1"
               
                ;We're gonna have to call
                bCallEvent := True
               
            }

        }


        ;Check if we need to call
        If bCallEvent
        {
           
            ;Call the appropriate sub if it exists
            sLabel := sDevicePrefix "_" sPrefix "_" iKey
            If IsLabel(sLabel)
                Gosub, %sLabel%
            else ;If IsLabel(!sLabel)
            {
                sPrefix  := "Default"
                sLabel := sDevicePrefix "_" sPrefix "_" iKey               
                ;If IsLabel(sLabel)
                Gosub, %sLabel%               
                   
            }

        }
       
    }
}



HPRem_Default_12: ;Power
    ;
return

HPRem_MPC_1: ;1 Symbols
    Sendinput 1
return

HPRem_MPC_2: ;2 abc
    ControlSend, VideoRenderer1, {space}, ahk_class MediaPlayerClassicW
return

HPRem_MPC_3: ;3 def
    SendInput 3
return

HPRem_MPC_4: ;4 ghi
    SendInput 4
return

HPRem_MPC_5: ;5 jkl
    SendInput 5
return

HPRem_MPC_6: ;6 mno
    SendInput 6
return

HPRem_MPC_7: ;7 pqrs
    SendInput 7
return

HPRem_MPC_8: ;8 tuv
    SendInput 8
return

HPRem_MPC_9: ;9 wxyz
    SendInput 9
return

HPRem_MPC_29: ;*
    SendInput *
return

HPRem_MPC_0: ;0 space
    SendInput 0
return

HPRem_MPC_22: ;Play
    ControlSend, VideoRenderer1, {space}, ahk_class MediaPlayerClassicW
return


Still, nothing happens...
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Mon Apr 12, 2010 6:35 pm    Post subject: Reply with quote

Hey bidomo,

I'm glad to see you're making progress!

I just want to make sure I understand your situation.
Quote:
Code:
01 01 00 00 00 32 84 0F 80 20 00 00 00                                          Visualization for XP
IR code Goes from 00 to 12 byte length (13 bytes)
01 01 00 00 00 00 00 00 00 32 84 0F 80 00 00 00 00 20 00 00 00 80 FA FF FF      Visualization for Windows 7
IR code Goes from 00 to 24 byte length (25 bytes)

That's the output from Example 2 when you press the Visualize button, I suppose?

From your edit, you say that you're now receiving 14 bytes instead of the original 25? I find it strange that you can receive different numbers of bytes by just updating AHKHID.

Anyway, I suspect that there's an error occuring somewhere, and that's why it seems like nothing happens. Try this script, while monitoring OutputDebug with something like DebugView and see if any errors pop up. It's a simplified script (no labels to call) but with error "handling" (more like error reporting). If you successfully make it to the "Data received = " part, then it's just a matter of correctly extracting the byte from uData. Post your log here.

Code:
/*
 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 12 17 18 19 20 21 22 23 24
01 01 00 00 00 00 00 00 00 32 84 0F 80 00 00 00 00 20 00 00 00 80 FA FF FF   Vizualize for Windows 7
01 01 00 00 00 32 84 0F 80 20 00 00 00                                       Vizualize for XP
*/

;Must be in auto-execute section if I want to use the constants
#Include %A_ScriptDir%\AHKHID.ahk

;Create GUI to receive messages
Gui, +LastFound
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 := AHKHID_Register(65468, 137, hGui, RIDEV_INPUTSINK)

;Prefix loop
Loop {
    Sleep 1000
    If WinActive("ahk_class Winamp v1.x") Or WinActive("ahk_class Winamp EQ") Or WinActive("ahk_class Winamp PE") Or WinActive("ahk_class Winamp Gen")
        sPrefix := "Winamp"
    Else If WinActive("ahk_class MediaPlayerClassicW")
        sPrefix := "MPC"
    Else If WinActive("ahk_class eHome Render Window")
        sPrefix := "VMC"
    Else If WinActive("ahk_class MozillaUIWindowClass")
        sPrefix := "Youtube"
    Else If WinActive("ahk_class ShockwaveFlashFullScreen")
        sPrefix := "YoutubeFS"
    Else sPrefix  := "Default"
}

Return

InputMsg(wParam, lParam) {
    Local devh, iKey, uData, err
   
    Critical
   
    ;Get handle of device
    devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
    If (devh = -1) { ;Check for error
        OutputDebug, AHKHID_GetInputInfo failed. ErrorLevel = %ErrorLevel%
        Return
    }
   
    ;Check that it is my HP remote
    If ((err := AHKHID_GetDevInfo(devh, DI_DEVTYPE, True)) = RIM_TYPEHID)
        And ((err := AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True)) = 1118)
        And ((err := AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True)) = 109)
        And ((err := AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True)) = 272) {
       
        OutputDebug, HP remote event!
       
        ;Get the raw data received
        iKey := AHKHID_GetInputData(lParam, uData)
        If (iKey = -1) { ;Check for error
            OutputDebug, AHKHID_GetInputData failed. ErrorLevel = %ErrorLevel%
            Return
        }
       
        OutputDebug, % "Data received = " Bin2Hex(&uData, iKey)
       
        ;Extract keycode at 10th byte
        iKey := NumGet(uData, 9, "UChar")
       
        OutputDebug, % "Keycode = " iKey
       
    } Else If (err = -1) { ;Check for error
        OutputDebug, AHKHID_GetDevInfo failed. ErrorLevel = %ErrorLevel%
        Return
    }
}

;By Laszlo
;http://www.autohotkey.com/forum/viewtopic.php?p=135402#135402
Bin2Hex(addr, len) {
    Static fun
    If (fun = "") {
        h=8B54240C85D2568B7424087E3A53578B7C24148A07478AC8C0E90480F9090F97C3F6DB80E30702D980C330240F881E463C090F97C1F6D980E10702C880C130880E464A75CE5F5BC606005EC3
        VarSetCapacity(fun, 76)
        Loop 76
            NumPut("0x" . SubStr(h, 2 * A_Index - 1, 2), fun, A_Index - 1, "Char")
    }
    VarSetCapacity(hex, 2 * len + 1)
    DllCall(&fun, "uint", &hex, "uint", addr, "uint", len, "cdecl")
    VarSetCapacity(hex, -1) ;update StrLen
    Return hex
}
Back to top
View user's profile Send private message Visit poster's website
justinsmith2009



Joined: 30 Dec 2009
Posts: 6

PostPosted: Mon Apr 12, 2010 11:22 pm    Post subject: need help disabling a key Reply with quote

Hi,

First of all thanks for very helpful information. I am able to capture all the keys from my RF MCE Remote and able to take action.

I have a problem disabling default actions though: For example the "Windows Logo Button" sends a code that I am able to get. However, it also brings the media center program in focus.

Is there a way to disable this default functionality ?

Thanks.
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Mon Apr 12, 2010 11:35 pm    Post subject: Re: need help disabling a key Reply with quote

justinsmith2009 wrote:
Is there a way to disable this default functionality ?

Hi justinsmith2009,
Go to the 5th step in the tutorial (second post in this thread). It'll give you all the information you need!
Back to top
View user's profile Send private message Visit poster's website
justinsmith2009



Joined: 30 Dec 2009
Posts: 6

PostPosted: Mon Apr 12, 2010 11:46 pm    Post subject: rf remote Reply with quote

Hi TheGood.

I have already tried the Step 5. I have an RF remote so that doesn't apply to me Sad

Any pointers to where I can look to disable the RF Remote default actions?

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 11, 12, 13 ... 24, 25, 26  Next
Page 12 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