Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHKHID - An AHK implementation of the HID functions


  • Please log in to reply
456 replies to this topic
KidSicarus
  • Members
  • 1 posts
  • Last active:
  • Joined: 19 Feb 2014

Hello. 

 

So, I just got a Huion tablet (Wacom killer) and am trying to use a pen button to map to erase (would be so handy).

 

So far, I have:

 

Mouse ID 128:

\??\HID#Vid_256c&Pid_006e&MI_00&Col02#7&2a239d61&0&0001#{378de44c-56ef-11d1-bc8c-00a0c91405dd}
\??\HID#Vid_256c&Pid_006e&MI_00&Col01#7&2a239d61&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}

 

Button: Down/up

Left: 1/2
Middle: 16/32
Right:  4/8
Left/Right:  5/10

 

Could anyone help me with a simple script to bind the middle button (16/32) to any keyboard key?  I'm over my head a bit but I believe I'm on the right track.  This would help me and my workflow out tremendously.

 

Thank you!



RageMachinist
  • Members
  • 3 posts
  • Last active: Mar 05 2014 08:41 PM
  • Joined: 20 Feb 2014

I'm having a hard time with this, trying to do something similar to KidSicarus.

 

Tried to decipher the examples scripts, but contrary to the authors belief they're not quite as self-explanatory as one would hope :)

 

I'd really appreciate an answer to the post above, an example how to go about doing a most basic thing like mapping a single button on a particular device would be beyond awesome.

 

Thanks! :)



evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005
Could this code potentially be used to detect how many joysticks are currently connected?

ie such that we would know which buttons were available?

ie joy 3 is connected, so 3Joy1 is a detectable button.

even better, to be able to find out "Joy 3 is connected and has 32 buttons".

If not, any ideas on how that would be achievable?

RageMachinist
  • Members
  • 3 posts
  • Last active: Mar 05 2014 08:41 PM
  • Joined: 20 Feb 2014

OK...I actually managed it after many hours :X

AHKHID_UseConstants()
;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_AddRegister(1)
r := AHKHID_AddRegister(1, 6, hGui, RIDEV_INPUTSINK)
AHKHID_Register()
Return
   


InputMsg(wParam, lParam) {
Local devh, iKey, sLabel


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_KBD_NUMBEROFKEYSTOTAL, True) = 154){
;Get data
iKey := AHKHID_GetInputData(lParam, uData)
       
;Check for error
If (iKey <> -1) {
  
;Get keycode (located at the 6th byte)
iKey := AHKHID_GetInputInfo(lParam, II_KBD_VKEY)
;Call the appropriate sub if it exists
sLabel := iKey
If IsLabel(sLabel)
Gosub, %sLabel%
}
}
}


49: ; Key 1
SendInput f ; press "1", send "f"
Return

I'm identifying the device by # of keys (it's a keypad) and it works...kind of. It dumps an "Out of Memory" error now, and triggers "f" twice.

 

now how do I stop the default key from firing? :(

 

I'd like to map "1" to "ctrl+c" for example, without triggering "1"

 

Edit: To be clear, I want to disable the "1" key only on the keypad. I don't like the idea of uninstalling the device to do that since I'd like to use it as a normal keypad without AHK too :)



RageMachinist
  • Members
  • 3 posts
  • Last active: Mar 05 2014 08:41 PM
  • Joined: 20 Feb 2014

edit: sorry for double post :(



andreidi
  • Members
  • 2 posts
  • Last active: Feb 26 2014 11:32 PM
  • Joined: 06 Nov 2013

I have an A4Tech 8 button mouse. Buttons 4 and 5 are side buttons (back and forward in browser and explorer). Buttons 6 and 7 are top buttons for Officebutton commands (programable to Copy/Paste or Vol+/Vol-). Button 8 is Officebutton to toggle programabile commands for Buttons 6 and 7. What I really want is to map Buttons 6 and Buttons 7 in order to them as hotkeys for another script (that controls the volume control of Breakaway Audio Enhancer, a virtual sound card app). It seems the Buttons 6 and 7 work by byte changes to the HID (and are not virtual keys like regular Left/Right Button). So I guess those byte changes have to be mapped to a virtual key (F13-F24) in order to use the mapped keys within the script to control Breakaway. Or maybe you can help me with another solution to do this.

 

I can find the HID Mouse with Example 1. I also have response when pressing Buttons 6 and 7 within Example 2. What should I do next?



Benjamin Holland
  • Members
  • 1 posts
  • Last active: Jun 15 2014 02:21 AM
  • Joined: 13 Jun 2014

Hi, 

 

I have a very Noobish question. I have downloaded AHKHID.ahk and also example_1, There was an error, on trying to run example_1, with the AHKHID_UseConstants(), so I commented it out and instead used #include "C:\Users\BHolland\Desktop\ahk\ahkhid\AHKHID.ahk.

 

Now it runs fine, but it doesn't list any HID devices connected to my computer. I have a mouse, a trackball, and a keyboard connected. I don't know if the above will have anything to do with this, but I thought I should mention everything I did. Can anyone help me get this working?

 

Thank you,

Benjamin



thexennon
  • Members
  • 8 posts
  • Last active: Jan 27 2019 08:09 AM
  • Joined: 20 Jun 2014

Hi, 

 

I have a very Noobish question. I have downloaded AHKHID.ahk and also example_1, There was an error, on trying to run example_1, with the AHKHID_UseConstants(), so I commented it out and instead used #include "C:\Users\BHolland\Desktop\ahk\ahkhid\AHKHID.ahk.

 

Now it runs fine, but it doesn't list any HID devices connected to my computer. I have a mouse, a trackball, and a keyboard connected. I don't know if the above will have anything to do with this, but I thought I should mention everything I did. Can anyone help me get this working?

 

Thank you,

Benjamin

 

I would un-comment that line and insert the #include before it.  You got the error because that line was/is referring to code inside AHKHID.ahk so placing the #include before it effectively allows that line of code to work properly.



Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

Hi, I Looking for help.
Example 1 can obtain a list of HID, how do monitor all HID it?
I want to find out the touch screen.



b0dhikey
  • Members
  • 44 posts
  • Last active: Nov 06 2015 02:43 AM
  • Joined: 26 Jan 2014

Hi, I Looking for help.
Example 1 can obtain a list of HID, how do monitor all HID it?
I want to find out the touch screen.

Hi Larctic I'm not sure if you can use your touchscreen but you may be able to use buttons if it connects to your computer.

Use the first two examples to find out the specific TLC of your device. Just put all the examples and the ahkhid.ahk in the same folder and then at the top of each example write down #Include ahkhid.ahk

And then run the 1st example, find out which one is your device by deduction and turning your device on and off
Once you find the TLC out, use example 2 to find out the button codes

Then use the example that author put in the 1st post, making a new AHK out of it, just edit and tweak it around, putting in the codes you wrote down from example 2. You gotta read the whole program and re-write the whole thing for your particular needs!

Took me 5 hours to do but finally got it all to work out!



rhr
  • Members
  • 217 posts
  • Last active: Feb 13 2015 02:41 AM
  • Joined: 28 Jun 2012

Final, work my Microsoft Keyboard with Fingerprint Reader (same Digital Media Pro)

 

single press "My Picture", "my Music", fav1~5 etc.. it is fine

 

but I want double

 

like

SC132 & e:: Run iexplore.exe https://plus.google.com/109875447375460840230/posts,,max
SC132 & g:: Run %x86%Google\Chrome\Application\chrome.exe ,,max
SC132:: Run Firefox.exe ,,max

 

that press hold web key + e for IE, press hold web key and g for Google Chrome, press web for Firefox

 

I need

press hold pic key and 1

press hold pic key and 2

press pic key

 

Gui, +LastFound
hGui := WinExist()
WM_INPUT := 0xFF
OnMessage(WM_INPUT, "InputMsg")
r := AHKHID_Register(12, 1, hGui, RIDEV_INPUTSINK)
InputMsg(wParam, lParam)
{
 Local devh, iKey, sLabel
 Critical
 devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
 If (devh <> -1) 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) = 187) And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 256)
 {
  iKey := AHKHID_GetInputData(lParam, uData)
  If (iKey <> -1)
   {
   byte1 := NumGet(uData, 1, "UChar")
   byte2 := NumGet(uData, 2, "UChar")
   byte3 := NumGet(uData, 3, "UChar")
   byte4 := NumGet(uData, 4, "UChar")

   ; msgbox %byte1% - %byte2% - %byte3% - %byte4%

   sLabel := "UNDEFINED"

   If(byte1 = 0x0 And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
   sLabel := "MSK_RELEASE"

   If(byte1 = 182 And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0)
   sLabel := "MSK_Pic"

   If(byte1 = 183 And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0)
   sLabel := "MSK_Mus"

   If IsLabel(sLabel)  
   Gosub, %sLabel%

  }
 }
}

MSK_RELEASE:
Return

MSK_Pic:
 MSGBOX *** PICTURE ***
Return

MSK_Mus:
 MSGBOX *** MUSIC ***
Return

 

would add

MSK_PIC1
 msgbox *** Pic 1 ***
return
 
MSK_Pic2
 msgbox *** Pic ***
return
 
MSK_Pic3 ***
msgbox *** Pic3 ***

 

but not work " GetKeyState("1")"

   If(byte1 = 182 And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0) And GetKeyState("1")
   sLabel := "MSK_Pic"

 

how fix it?


ЯHR

 

 

 

 

 


rhr
  • Members
  • 217 posts
  • Last active: Feb 13 2015 02:41 AM
  • Joined: 28 Jun 2012

Final, I hard and study, AHKHID, I got understand now
work two AHKHID same time
Keyboard (1,6) and Media (12,1)

i test

Pic Key + 1
Pic key + a
work !!!

#Include C:\Users\rhr\AHK\AHKHID\AHKHID.AHK

;Create GUI to receive messages
Gui, +LastFound
hGui := WinExist()
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(12, 1, hGui, RIDEV_INPUTSINK)
 k := AHKHID_Register(1, 6, hGui, RIDEV_INPUTSINK)

InputMsg(wParam, lParam)
{
 Local devh, iKey, sLabel
 Critical
    
 ;Get handle of device
 devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
   
 ;Check for error

 If (devh <> -1) 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) = 187) And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 256)
 {
  iKey := AHKHID_GetInputData(lParam, uData)

  If (iKey <> -1)
  {
   iKey1 := NumGet(uData, 1, "UChar")

   iKey5 := NumGet(uData, 5, "UChar")

   if (iKey1 = 0) and (iKey5 = 5)
    gosub Fav1
   else if (iKey1 = 0) and (iKey5 = 9)
    gosub Fav2
   else if (iKey1 = 0) and (iKey5 = 17)
    gosub Fav3
   else if (iKey1 = 0) and (iKey5 = 33)
    gosub Fav4
   else if (iKey1 = 0) and (iKey5 = 65)
    gosub Fav5
  }
 }
 if (devh <> -1) And (AHKHID_GetDevInfo(devh, DI_KBD_TYPE, True) <> 8)
  iKey2 := AHKHID_GetInputInfo(lParam, II_KBD_VKEY) ;Get Vkey code

 char := chr(iKey2)
 sLabel = %iKey1%-%char%
 if IsLabel(sLabel)
  {
   iKey1 = 0
   iKey2 = 0
   Gosub, %sLabel%
  }
}

0: ; RELEASE
Return

167-a: ; DOC
 MSGBOX *** Doc A ***
Return

182-1:
 MSGBOX *** PIC 1 ***
Return

182-a:
 MSGBOX *** PIC 2 ***
Return

183-a: ; Music
 MSGBOX *** MUSIC 1 ***
Return

183-b: ; Music
 MSGBOX *** MUSIC 2 ***
Return

153-a:
 MSGBOX *** CHAT A ***
Return

153-g:
 MSGBOX *** CHAT G ***
Return

Fav1:
 msgbox *** Fav 1 ***
Return

Fav2:
 msgbox *** Fav 2 ***
Return

Fav3:
 msgbox *** Fav 3 ***
Return

Fav4:
 msgbox *** Fav 4 ***
Return

Fav5:
 msgbox *** Fav 5 ***
Return

I am sad not work both Single and double key, they are hard, I am sad only double key, I will try find both single and double key or if you know how use them?
 

ЯHR

 

 

 

 

 


rhr
  • Members
  • 217 posts
  • Last active: Feb 13 2015 02:41 AM
  • Joined: 28 Jun 2012

I got problem,

 

open any document, notepad, wordpad

 

I press PIC + 1

show "1", I need hide

 

I test Win +1, Ctrl + 1, ALT +1, or sc(any) & (any):: they are hide, not snow on document

 

how AHKHID key hide?


ЯHR

 

 

 

 

 


TheUgly
  • Members
  • 1 posts
  • Last active: Oct 30 2014 01:12 AM
  • Joined: 29 Oct 2014

To anybody having trouble getting Example 1 to populate please be aware that you need to get the latest version of AHK from http://ahkscript.org/ 

 

If you are attempting to use Example 1 with the version of AHK from www.autohotkey.com (currently 104805) it will not work.  This is a giant PITA and I wasted a few hours banging my head against the wall. 

 

The version of AHK on this site... www.autohotkey.com returns nothing for the built in variable A_PtrSize (and others)   Load up the version from ahkscript.org and you're in business.

 

Thanks for the fine work from everyone.  This is such a great tool, but the website business... what's that about?  What's the story that lead to the separate .org and .com sites. 

 

<Tips hat to TheGood>



hoppfrosch
  • Members
  • 399 posts
  • Last active: Feb 26 2016 05:31 AM
  • Joined: 25 Jan 2006

Thanks for the fine work from everyone.  This is such a great tool, but the website business... what's that about?  What's the story that lead to the separate .org and .com sites. 

 

Read here: http://ahkscript.org...c.php?f=2&t=466 or http://www.autohotke...with-this-site/ or http://www.autohotke...the-forum-poll/ or ... or ... or ...

 

It's a long time annoyance yet, which story has been told many times ...