AutoHotkey Community

It is currently May 27th, 2012, 5:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 398 posts ]  Go to page Previous  1 ... 13, 14, 15, 16, 17, 18, 19 ... 27  Next
Author Message
 Post subject:
PostPosted: November 16th, 2010, 2:14 pm 
Offline

Joined: November 14th, 2010, 2:09 pm
Posts: 10
hi,

thanks I will try your link

My device is a AP3000 from Elite simulation , see this link: http://www.flyelite.com/?page_id=953&shopp_pid=34

I can see it in windows 7 / START / DEVICES AND PRINTER; it is listed as UNKNWNON DEVICE with the following information:
name: Elite AP3000 USB
GENERAL:
Manufacturer: unavailable
model: elite AP3000 usb
model number: unavailable
Categories: unknown
Description: unavailable
HARDWARE:
Name: ELITE USB DEVICE (FA50)
Type: Universal Serial Bus controllers
Manufacturer: FTDI
Location: Port_#0002.Hub_#0004


I use it with x-plane 9 simulator, and with elite driver found here :
http://www.flyelite.com/?page_id=54

the problem I have is that some buttons on the device were not program in the driver provided by elite.
I would want to be able to program them my self , if I can get them to be key buttons then x-plane allows me to assign any function to them.

my system is Windows 7 pro

Thanks for your help

Regards,

Ian


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2010, 1:29 am 
Offline

Joined: January 15th, 2007, 2:37 pm
Posts: 573
I have no experience with with win7 but usually if it's seen as an unknown device then the driver did not load properly. Are you certain the driver is win7 compatible?

I would try EventGhost, it has several input controller types. It sound possible that this may be recognized as a joy stick. Although is the drivers are not loaded correctly EventGhost likely wont detect it either.

Let me know what you find.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2010, 4:22 am 
Offline

Joined: November 14th, 2010, 2:09 pm
Posts: 10
Hi,

I tryed eventghost but I do not know what plug in to use with evenghost, i added them all but still when pushing a button on the device eventghost does not report any event :(

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2010, 9:36 am 
Offline

Joined: January 15th, 2007, 2:37 pm
Posts: 573
Sorry, been away for a while. This device likely is not being seen as an HID device. If it's not seen under HID General, then try with mouse and joystick plugins. If that doesn't work just try any plugin that uses a usb input, other than the IR plugins.

You could post in the EventGhost forums and likely find someone more knowledgeable than me to help you. We should continue this discussion in the EG forums anyway since were not talking AHK anymore. Post over there and I'll watch for it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: frustrated
PostPosted: December 5th, 2010, 11:47 pm 
Ok, so I have searched, read, looked, modified, and scoured....I finally got all of the info, but No script will register?? So frustrating. I like what is going here but it's so aggravating when you can't figure out why somethings not working.

I have entered
;Register mouse with RIDEV_INPUTSINK (so that data is received even in the background)
r := AHKHID_Register(12, 1, hGui, RIDEV_INPUTSINK)
If Not r { ;Check for error
MsgBox, Registration failed!`n%ErrorLevel%
ExitApp
}

I know for certain the buttons are in Usage Page 12 and Usage 1 as verified by example 2 with no mods. No script I run will register. It always pops up Registration Failed! and 0 underneath that. I have tried registering mice 1/2 and keyboards 1/6 and all the Up/U pages that show up. None will register.
So, I am at a stand still. How is it everyone else has figured it out? Has something changed?

Finally, if anyone does respond here, I have another pertinent question. I have 2 mice and want one to use buttons for macros. I went through all of this to learn to assign specific calls to the specific mouse. But not getting anything to register kepps me from getting anywhere. Question: How do I assign specific macro to the specific mouse (based on the info here and assuming it will register)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2010, 3:13 pm 
Offline

Joined: January 15th, 2007, 2:37 pm
Posts: 573
Please see the new version in a post below.
http://www.autohotkey.com/forum/viewtopic.php?t=41397&start=234

I hope I'm not intruding on TheGood's post but I thought this would be a good project for me to learn more about programming in AHK.

I've developed a tool to easily get the glabel codes you need from your remotes using a GUI. It's an edited version of the "Creating a script" example, from page one of this topic, and needs input from "Example 1". Don't forget you will also need the AHKHID library for this

So far this is only for "Other" devices as per the tab in the script "Example 1" but as time permits I intend to add mice and keyboards too.

Here's an example using my Gyration remote. The remote gives me three "Usage page" and "Usage" numbers so I've included five edits in case some remotes give more.
Image

To use, start "Example 1" which is on the first page of this topic and this "Remote Info script". Get the information for the remote you are using and fill in the blanks of the "Remote Info" GUI. Leave any "Usage page" or "Usage" boxes you don't need blank.

Image
The "Prefix" box is your custom prefix to identify the application your wanting to control. In TheGood's example he developed a brilliant system to make the remote context sensitive using this prefix. This let's you use the same buttons on the remote to control many applications depending on which one is in focus. In my example I'm using VLC Media Player so I entered VLC but you can put whatever you wish here.

The "Key" text is the code being received from your remote and the label box is the final product.

When filled in start pushing buttons on your remote. If all works well the label you need will appear in the "Label" box. Cut and paste this label into your script for your gLabels.

Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

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

;Create GUI to receive messages

Gui, Add, Text, x5 y10 h20 w60, Vendor ID
Gui, Add, Text, x70 y10 h20 w60, Product ID
Gui, Add, Text, x135 y10 h20 w60, Version #

Gui, Add, Edit, x5 y25 h20 w60 vvid gvid,
Gui, Add, Edit, x70 y25 h20 w60 vpid gpid,
Gui, Add, Edit, x135 y25 h20 w60 vver gver,

Gui, Add, Text, x5 y50 h20 w90, Usage Page
Gui, Add, Text, x105 y50 h20 w90, Usage

Gui, Add, Edit, x5 y65 h20 w90 vup1 gup1,
Gui, Add, Edit, x105 y65 h20 w90 vusage1 gusage1,


Gui, Add, Edit, x5 y+5 h20 w90 vup2 gup2,
Gui, Add, Edit, x+10 h20 w90 vusage2 gusage2,

Gui, Add, Edit, x5 y+5 h20 w90 vup3 gup3,
Gui, Add, Edit, x+10 h20 w90 vusage3 gusage3,

Gui, Add, Edit, x5 y+5 h20 w90 vup4 gup4,
Gui, Add, Edit, x+10 h20 w90 vusage4 gusage4,

Gui, Add, Edit, x5 y+5 h20 w90 vup5 gup5,
Gui, Add, Edit, x+10 h20 w90 vusage5 gusage5,


Gui, Font, cBlack s8, Arial
Gui, Add, GroupBox, x5 y+10 w90 h40, Prefix
Gui, Add, GroupBox, x+10 w90 h40, Key

Gui, Add, Edit, x13 yp+15 w70 vprefix gprefix,
Gui, Add, Text, x113 yp+0 w70 vkey, Key

Gui, Add, GroupBox, x5 y+20 w190 h45, Label
Gui, Font, cBlack s10, Arial
Gui, Add, Edit, x15 yp+15 w170 vlabel,

Gui, Show, w200, Remote Info

Gui, Submit, NoHide

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)
register:
r := AHKHID_Register(up1, usage1, hGui, RIDEV_INPUTSINK)
r := AHKHID_Register(up2, usage2, hGui, RIDEV_INPUTSINK)
r := AHKHID_Register(up3, usage3, hGui, RIDEV_INPUTSINK)
r := AHKHID_Register(up4, usage4, hGui, RIDEV_INPUTSINK)
r := AHKHID_Register(up5, usage5, hGui, RIDEV_INPUTSINK)

;Prefix
sPrefix := prefix



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_DEVTYPE, True) = RIM_TYPEHID)
        And (AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True) = vid)
        And (AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = pid)
        And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = ver)
      {
       
        ;Get data
        iKey := AHKHID_GetInputData(lParam, uData)
       
        ;Check for error
        If (iKey <> -1) {
           
            ;Get keycode (located at the 6th byte)
            iKey := NumGet(uData, 1, "UChar")
            ;MsgBox, %iKey%
             
                     
           
         
         ;Call the appropriate sub if it exists
            sLabel := sPrefix "_" iKey
            If IsLabel(sLabel)
                Gosub, %sLabel%
            
            If %iKey% = 0
               Return
            Guicontrol, , prefix, %sPrefix%
            Guicontrol, , key, %iKey%
            Guicontrol, , label, %sLabel%   
            Return
         
      }
    }
}

;AHKHIDGUI===========
exit:
GuiClose:
Gui, Destroy
ExitApp
Return


vid:
pid:
ver:
up1:
up2:
up3:
up4:
up5:
usage1:
usage2:
usage3:
usage4:
usage5:
prefix:
Gui, Submit, NoHide
GoTo, register
Return


I hope this works as well for everyone as it seems to work for me. I'm going out of town for a few days but please leave bug reports or suggestions and I'll read them when I get back.


Last edited by specter333 on December 13th, 2010, 11:44 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: suggestions and help
PostPosted: December 13th, 2010, 4:14 am 
Nice little script. It works as described. It's like a slim/lite version of Ex 2.
Although, it simply outputs a label. (which is helpful in any case) Suggestion for making it better:
1.Rename "key" to Key Pressed
2.Rename "Label" to Label to Use in Script
3. A nice feature may be to have one more box that you enter your target command/key/key combo and it outputs the code for you to copy. SO, you could output the label and the code for making that label do that function. I know most will likely have figured that out, but as a copy and paste kind of thing that might be handy to include.

I think it's a nice layout though.
I still cannot get anything to "register" still have the same error. Any help? as you have obviously gotten remotes to work?

BTW- multiple Keyboards and Mice CANNOT (at this time) be distinguished as separate by AHK. Once a mouse button is mapped -all mice are mapped and respond the same. ONLY other HID devices/buttons can be distinguished as unique inputs from that particular device.( ie: mouse A left click can't act differently/independently than mouse B left click)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2010, 9:13 am 
Offline

Joined: November 9th, 2008, 7:48 pm
Posts: 25
Hello all, been away from AHK for a long time, but I now would like to see if anyone can help with the following:

I have a Bluetooth trackball (MacMice "The Ball") that shows up as a HID-compliant mouse in Windows 7. It works great except a pretty nasty issue where it seems to be sending a scroll right and scroll down command (not sure which one as I understand there are several) with EVERY mouse movement poll. As you might expect this is very undesired behavior :P

So I am looking at AHK to see if I can filter out the erroneous messages. I am using Micha's DLL and his first example script to view the data the mouse is sending, and comparing it to what another, non-problematic, mouse is sending.

It looks like the Bluetooth trackball is sending a BtnFlag of 2048 and a ButtonData of 6720 where the normal mouse has 0 for those.

Is there any way to filter out that data or does anyone have any other ideas of what I can do?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: suggestions and help
PostPosted: December 13th, 2010, 9:52 am 
Offline

Joined: January 15th, 2007, 2:37 pm
Posts: 573
curious1 wrote:
Suggestion for making it better:
1.Rename "key" to Key Pressed
2.Rename "Label" to Label to Use in Script
3. A nice feature may be to have one more box that you enter your target command/key/key combo and it outputs the code for you to copy. SO, you could output the label and the code for making that label do that function. I know most will likely have figured that out, but as a copy and paste kind of thing that might be handy to include.

Thank you those are good suggestions. I've been working on an easier to use version, I'll add these in before I post it.

curious1 wrote:
I still cannot get anything to "register" still have the same error. Any help? as you have obviously gotten remotes to work?


If it does show up in example 1 then I think we can figure this out. The problem may be with the NumGet command TheGood used on his script to ignore items that were identical in every keypress. On my remote this must be set to 1. My new script has an option to set this. I expect to be able to post it before morning. What type of remote was it again?

curious1 wrote:
BTW- multiple Keyboards and Mice CANNOT (at this time) be distinguished as separate by AHK. Once a mouse button is mapped -all mice are mapped and respond the same. ONLY other HID devices/buttons can be distinguished as unique inputs from that particular device.( ie: mouse A left click can't act differently/independently than mouse B left click)

Thanks for this information. Trying to learn how to do this was going to be my next project. I would have spent days trying to figure out why I couldn't make it work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Remote Info Script
PostPosted: December 13th, 2010, 11:38 am 
Offline

Joined: January 15th, 2007, 2:37 pm
Posts: 573
Here is a new version of my Remote Info script. It combines TheGood's "Example 1" and "Make a Script" examples from the first page.

Image

In this version you simply check the boxes to the left of the remote your wanting a code for and enter the optional prefix. The complete g-label appears in the "Label to Use in Script" box and the start of the g-label section appears in the large edit box below so you can finish the g-label and cut/paste it into your script.

The "+#" box is for the NumGet input, a value of 1 is needed for most remotes. To put it simply, increasing this value may cause the key press to be read differently but can also cause it to not be seen. You can experiment to see what setting is most effective with your remote. If the script seems to stall uncheck "-Up" and return the value to 1.

The "-Up" checkbox ignores key presses that are 0 or likely keyup events. This leaves the keydown event in the Label box instead of causing it to enter a 0.

Please be aware I don't claim to understand how everything in this script works, most of it is taken from TheGood's examples. I combined and edited the scripts to make it easier for people to get the keypresses from their "Other-HID" devices. Most everything I did was learned by trial and error so please let me know if something can be improved.

Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

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

Gui, Add, Tab2, Buttons, Keyboard||Mice|Other||?


;Create GUI to receive messages


Gui, Tab, 1
Gui, Add, ListView, x16 y40 w470 NoSortHdr LV0x10 Grid  vlvwKeyb gLV_Event AltSubmit, Name|Type|SubType|Keyboard Mode|Number of Function Keys|Number of Indicators|Number of Keys Total
Gui, Tab, 2
Gui, Add, ListView, x16 y40 w470 NoSortHdr LV0x10 Grid  vlvwMouse gLV_Event AltSubmit, Name|Mouse ID|Number of Buttons|Sample Rate
If bVista
    LV_InsertCol(5, "", "Has Horizontal Wheel")
Gui, Tab, 3
Gui, Add, ListView, x16 y40 w470 NoSortHdr LV0x10 Checked Grid AltSubmit vlvwOther gLV_Event, Name|Vendor ID|Product ID|Version Number|Usage Page|Usage

;Set up the constants
AHKHID_UseConstants()

;Get count
iCount := AHKHID_GetDevCount()
   
;Retrieve info for each device
Loop %iCount% {
   
    HID0 += 1
   
    ;Get device handle, type and name
    HID%HID0%_Handle := AHKHID_GetDevHandle(HID0)
    HID%HID0%_Type   := AHKHID_GetDevType(HID0)
    HID%HID0%_Name   := AHKHID_GetDevName(HID0)
   
    ;Get device info
    If (HID%HID0%_Type = RIM_TYPEMOUSE) {
        HID%HID0%_ID            := AHKHID_GetDevInfo(HID0, DI_MSE_ID)
        HID%HID0%_Buttons       := AHKHID_GetDevInfo(HID0, DI_MSE_NUMBEROFBUTTONS)
        HID%HID0%_SampleRate    := AHKHID_GetDevInfo(HID0, DI_MSE_SAMPLERATE)
        If bVista ;Only supported in Windows Vista and higher
            HID%HID0%_HWheel    := AHKHID_GetDevInfo(HID0, DI_MSE_HASHORIZONTALWHEEL)
    } Else If (HID%HID0%_Type = RIM_TYPEKEYBOARD) {
        HID%HID0%_KBType        := AHKHID_GetDevInfo(HID0, DI_KBD_TYPE)
        HID%HID0%_KBSubType     := AHKHID_GetDevInfo(HID0, DI_KBD_SUBTYPE)
        HID%HID0%_KeyboardMode  := AHKHID_GetDevInfo(HID0, DI_KBD_KEYBOARDMODE)
        HID%HID0%_FunctionKeys  := AHKHID_GetDevInfo(HID0, DI_KBD_NUMBEROFFUNCTIONKEYS)
        HID%HID0%_Indicators    := AHKHID_GetDevInfo(HID0, DI_KBD_NUMBEROFINDICATORS)
        HID%HID0%_KeysTotal     := AHKHID_GetDevInfo(HID0, DI_KBD_NUMBEROFKEYSTOTAL)
    } Else
If (HID%HID0%_Type = RIM_TYPEHID) {
        HID%HID0%_VendorID      := AHKHID_GetDevInfo(HID0, DI_HID_VENDORID)
        HID%HID0%_ProductID     := AHKHID_GetDevInfo(HID0, DI_HID_PRODUCTID)
        HID%HID0%_VersionNumber := AHKHID_GetDevInfo(HID0, DI_HID_VERSIONNUMBER)
        HID%HID0%_UsagePage     := AHKHID_GetDevInfo(HID0, DI_HID_USAGEPAGE)
        HID%HID0%_Usage         := AHKHID_GetDevInfo(HID0, DI_HID_USAGE)
    }
}

;Add to listviews according to type
Loop %HID0% {
    If (HID%A_Index%_Type = RIM_TYPEMOUSE) {
        Gui, ListView, lvwMouse
        If bVista ;Only supported in Windows Vista and higher
            LV_Add("",HID%A_Index%_Name, HID%A_Index%_ID, HID%A_Index%_Buttons, HID%A_Index%_SampleRate, HID%A_Index%_HWheel)
        Else LV_Add("",HID%A_Index%_Name, HID%A_Index%_ID, HID%A_Index%_Buttons, HID%A_Index%_SampleRate)
    } Else If (HID%A_Index%_Type = RIM_TYPEKEYBOARD) {
        Gui, ListView, lvwKeyb
        LV_Add("", HID%A_Index%_Name, HID%A_Index%_KBType, HID%A_Index%_KBSubType, HID%A_Index%_KeyboardMode
        , HID%A_Index%_FunctionKeys, HID%A_Index%_Indicators, HID%A_Index%_KeysTotal)
    } Else
If (HID%A_Index%_Type = RIM_TYPEHID) {
        Gui, ListView, lvwOther
        LV_Add("", HID%A_Index%_Name, HID%A_Index%_VendorID, HID%A_Index%_ProductID, HID%A_Index%_VersionNumber
        , HID%A_Index%_UsagePage, HID%A_Index%_Usage)
    }
}

;Adjust column width
Gui, ListView, lvwMouse
Loop 5
   LV_ModifyCol(A_Index+1, "AutoHdr")
LV_ModifyCol(1, 142)
   
Gui, ListView, lvwKeyb
Loop 7
    LV_ModifyCol(A_Index+1, "AutoHdr")
LV_ModifyCol(1, 142)   
   
Gui, ListView, lvwOther
Loop 6
    LV_ModifyCol(A_Index, "AutoHdr")
LV_ModifyCol(1, 142)
   
Gui, Add, GroupBox, w40 h40 Center, +#
Gui, Add, GroupBox, x+5 w90 h40, Prefix
Gui, Add, GroupBox, x+5 w95 h40, Key Pressed
Gui, Add, GroupBox, x+5 w35 h40 Center, -Up
Gui, Add, GroupBox, x+5 w190 h40,  Label to Use in Script

Gui, Add, Edit, xm+11 yp+15 w30 h40 R1 voffset goffset,
Gui, Add, UpDown, vMyUpDown Range1-10, 1
Gui, Add, Edit, x+15 w80 vprefix gprefix,
Gui, Add, Text, x+19 vkey, 000000000000
Gui, Add, CheckBox, xp+101 yp+3 w21 Checked vboxNo0 gNo0,
Gui, Add, Edit, xp+35 yp-3 w180 vlabel,
Gui, Add, Edit, xm+5 y+10 w470 h100 vcomp, Use this box to add your commands then copy/paste into your script.

Gui, Tab,
;Gui, Add, Button, xm+10 y+20 gReload, R

Gui, Tab, 4
Gui, Font, s10 cBlack, arial black
Gui, Add, Text, , AHKHID - An AHK implementation of the HID functions
Gui, Font, s8 cBlack, arial
Gui, Add, Text, y+3, Remote Info is an adaptation of the AHKHID project and examples from TheGood.
Gui, Font, s7 cBlack, arial
Gui, Add, Text, y+5 w470, Remote Info is designed to make it easy to find the key presses from "Other HID" devices and turn them into g-labels for your scripts.  keyboard and mice information is listed in thier respective tabs for reference.
Gui, Add, Text, y+7 w470, Instructions:
Gui, Add, Text, y+3 w470, The "Other" tab contains three sections, The listview of all "Other-HID" devices connected to your computer, Options and key press retrieved line and an edit box you can use to complete your g-label section.
Gui, Add, Text, y+5 w470, Check the box to the left of the HID device you wish to use.  Some devices will have more than one entry as seen by the Vendor ID-Product ID-Version #, you will likely need to check all that match.
Gui, Add, Text, y+5 w470, The "+#" box supplies input for the NumGet command.  1 is used for most devices but it may be useful to experiment for your device.  If the script seem to stall uncheck "-Up" and return to 1.
Gui, Add, Text, y+5 w470, The "-Up" check box ignores labels that are "0" which are likely KeyUp commands.
Gui, Add, Text, y+5 w470, Prefix(Optional) is used to assign a custom prefix to the key press.  This will allow the same key to be used for different g-labels such as "VLC_225" and "MPC_225". 
Gui, Add, Text, y+5 w470, With the device checked in listview and your optional prefix added press a key on your HID device.  The g-label will appear in the "Label to Use in Script" box and in the command edit box. 
Gui, Add, Text, y+5 w470, You may finish adding your command in the edit box and cut/paste it to your script.
Gui, Show, y0, Remote Info

Gui, Submit, NoHide
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)
register:

r := AHKHID_Register(up%A_EventInfo%, usage%A_EventInfo%, hGui, RIDEV_INPUTSINK)

;Prefix
sPrefix := prefix

   
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_DEVTYPE, True) = RIM_TYPEHID)
        And (AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True) = vid)
        And (AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = pid)
        And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = ver)
      {
       
        ;Get data
        iKey := AHKHID_GetInputData(lParam, uData)
       
        ;Check for error
        If (iKey <> -1) {
           
            ;Get keycode (located at the 6th byte) %oset%
            iKey := NumGet(uData,%oset%, "UChar")
            ;MsgBox, %iKey%
             
                     
           
         
         ;Call the appropriate sub if it exists
            sLabel := sPrefix "" iKey
            If IsLabel(sLabel)
                Gosub, %sLabel%
            If BoxNo0 = 0
         GoTo KeyLabel
            If iKey = 0
               Return
         KeyLabel:
            Guicontrol, , prefix, %sPrefix%
            Guicontrol, , key, %iKey%
            Guicontrol, , label, %sLabel%
         Guicontrol, , comp, %sLabel%:`n`nReturn
            Return
         
      }
    }
}

;AHKHIDGUI===========
exit:
GuiClose:
Gui, Destroy
ExitApp
Return

No0:
Gui, Submit, NoHide
Return

offset:
oset = offset
Return

prefix:
Gui, Submit, NoHide
GoTo, register
Return

Reload:
Reload
Return

GuiSize:
    Anchor("MyTabs", "wh")
    Anchor("lvwKeyb", "wh")
    Anchor("lvwMouse", "wh")
    Anchor("lvwOther", "wh")
Return


LV_Event:
Critical
;up4 :=

   If InStr(ErrorLevel, "c", true)
      {
      AHKHID_Register( up%A_EventInfo%, usage%A_EventInfo%, hGui, RIDEV_REMOVE)
      up%A_EventInfo% :=
      usage%A_EventInfo% :=
      ;MsgBox, vid   pid   ver   event   error`n%vid%   %pid%   %ver%   %A_GuiEvent%   %ErrorLevel%`n`nup1   up2   up3   up4   up5`n%up1%   %up2%   %up3%   %up4%   %up5%`n`nu1   u2   u3   u4   u5`n%usage1%   %usage2%   %usage3%   %usage4%   %usage5%
      Return
        }
   
   If InStr(ErrorLevel, "C", true)
      {
      LV_GetText(vid, A_EventInfo, 2)
      LV_GetText(pid, A_EventInfo, 3)
      LV_GetText(ver, A_EventInfo, 4)
      LV_GetText(up%A_EventInfo%, A_EventInfo, 5)
      LV_GetText(usage%A_EventInfo%, A_EventInfo, 6)
      ;MsgBox, vid   pid   ver   event   error`n%vid%   %pid%   %ver%   %A_GuiEvent%   %ErrorLevel%`n`nup1   up2   up3   up4   up5`n%up1%   %up2%   %up3%   %up4%   %up5%`n`nu1   u2   u3   u4   u5`n%usage1%   %usage2%   %usage3%   %usage4%   %usage5%
      Goto register
        }

Return

;Anchor by Titan, adapted by TheGood
;http://www.autohotkey.com/forum/viewtopic.php?p=377395#377395
Anchor(i, a = "", r = false) {
   static c, cs = 12, cx = 255, cl = 0, g, gs = 8, gl = 0, gpi, gw, gh, z = 0, k = 0xffff, ptr
   If z = 0
      VarSetCapacity(g, gs * 99, 0), VarSetCapacity(c, cs * cx, 0), ptr := A_PtrSize ? "Ptr" : "UInt", z := true
   If (!WinExist("ahk_id" . i)) {
      GuiControlGet, t, Hwnd, %i%
      If ErrorLevel = 0
         i := t
      Else ControlGet, i, Hwnd, , %i%
   }
   VarSetCapacity(gi, 68, 0), DllCall("GetWindowInfo", "UInt", gp := DllCall("GetParent", "UInt", i), ptr, &gi)
      , giw := NumGet(gi, 28, "Int") - NumGet(gi, 20, "Int"), gih := NumGet(gi, 32, "Int") - NumGet(gi, 24, "Int")
   If (gp != gpi) {
      gpi := gp
      Loop, %gl%
         If (NumGet(g, cb := gs * (A_Index - 1)) == gp, "UInt") {
            gw := NumGet(g, cb + 4, "Short"), gh := NumGet(g, cb + 6, "Short"), gf := 1
            Break
         }
      If (!gf)
         NumPut(gp, g, gl, "UInt"), NumPut(gw := giw, g, gl + 4, "Short"), NumPut(gh := gih, g, gl + 6, "Short"), gl += gs
   }
   ControlGetPos, dx, dy, dw, dh, , ahk_id %i%
   Loop, %cl%
      If (NumGet(c, cb := cs * (A_Index - 1), "UInt") == i) {
         If a =
         {
            cf = 1
            Break
         }
         giw -= gw, gih -= gh, as := 1, dx := NumGet(c, cb + 4, "Short"), dy := NumGet(c, cb + 6, "Short")
            , cw := dw, dw := NumGet(c, cb + 8, "Short"), ch := dh, dh := NumGet(c, cb + 10, "Short")
         Loop, Parse, a, xywh
            If A_Index > 1
               av := SubStr(a, as, 1), as += 1 + StrLen(A_LoopField)
                  , d%av% += (InStr("yh", av) ? gih : giw) * (A_LoopField + 0 ? A_LoopField : 1)
         DllCall("SetWindowPos", "UInt", i, "UInt", 0, "Int", dx, "Int", dy
            , "Int", InStr(a, "w") ? dw : cw, "Int", InStr(a, "h") ? dh : ch, "Int", 4)
         If r != 0
            DllCall("RedrawWindow", "UInt", i, "UInt", 0, "UInt", 0, "UInt", 0x0101) ; RDW_UPDATENOW | RDW_INVALIDATE
         Return
      }
   If cf != 1
      cb := cl, cl += cs
   bx := NumGet(gi, 48, "UInt"), by := NumGet(gi, 16, "Int") - NumGet(gi, 8, "Int") - gih - NumGet(gi, 52, "UInt")
   If cf = 1
      dw -= giw - gw, dh -= gih - gh
   NumPut(i, c, cb, "UInt"), NumPut(dx - bx, c, cb + 4, "Short"), NumPut(dy - by, c, cb + 6, "Short")
      , NumPut(dw, c, cb + 8, "Short"), NumPut(dh, c, cb + 10, "Short")
   Return, true
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2010, 1:29 am 
Specter333, that is great! Simple and intuitive now. I will try it later and let you know if I run into anything.

On the register issue...I see in your code you are not using a "verify" code to your register. This is what I am using:

;Register mouse-device-remote with RIDEV_INPUTSINK (so that data is received even in the background)
r := AHKHID_Register(12, 1, hGui, RIDEV_INPUTSINK)
If Not r { ;Check for error
MsgBox, Registration failed!`n%ErrorLevel%
ExitApp
}

And so, my script won't get past this error checking because r doesn't seem to be registering-Therefore, I get the message box saying registration failed. But the error level is 0? So, maybe it's a problem with the error checking script?? The "remote" is actually the extra buttons on my keyboard.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2010, 3:57 am 
Offline

Joined: November 9th, 2008, 7:48 pm
Posts: 25
Blahman wrote:
Hello all, been away from AHK for a long time, but I now would like to see if anyone can help with the following:

I have a Bluetooth trackball (MacMice "The Ball") that shows up as a HID-compliant mouse in Windows 7. It works great except a pretty nasty issue where it seems to be sending a scroll right and scroll down command (not sure which one as I understand there are several) with EVERY mouse movement poll. As you might expect this is very undesired behavior :P

So I am looking at AHK to see if I can filter out the erroneous messages. I am using Micha's DLL and his first example script to view the data the mouse is sending, and comparing it to what another, non-problematic, mouse is sending.

It looks like the Bluetooth trackball is sending a BtnFlag of 2048 and a ButtonData of 6720 where the normal mouse has 0 for those.

Is there any way to filter out that data or does anyone have any other ideas of what I can do?


So I went back to my old WinXP notebook to test why I never noticed this behavior with it, used Micha's DLL to inspect the data and on XP it sends BtnFlag and ButtonData of 0 -- what does that mean? Driver issue in Windows 7? Anyway, doubtful there is any updated drivers for this hardware as the manufacturer no longer sells it (great, unique product though).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2010, 4:31 am 
Offline

Joined: January 15th, 2007, 2:37 pm
Posts: 573
Blahman wrote:
Driver issue in Windows 7? Anyway, doubtful there is any updated drivers for this hardware as the manufacturer no longer sells it (great, unique product though).


I have had fairly good luck in the past finding custom made drivers at places like driversguide.com. May be worth a shot.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2010, 4:49 am 
Offline

Joined: November 9th, 2008, 7:48 pm
Posts: 25
Thanks for the reply but I'm way beyond certain that there are no drivers for this... the company that made it is very small, probably defunct now. Their website is macmice.ca but it's down.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2010, 5:01 am 
Offline

Joined: January 15th, 2007, 2:37 pm
Posts: 573
curious1 wrote:
I see in your code you are not using a "verify" code to your register.


As I said before this is not my code and looking back at the original script provided by TheGood I don't see the verify there either. I would say that could likely be the problem. Try running without it.

I really don't understand the verify code your using, of course I don't understand most of the code in this script. To my uneducated mind I would think the verification would be if you received the key press. Please let me know if I'm off base here, I am trying to learn anything I can.

Just to be clear the whole point behind putting these scripts into one easy to use gui is because I don't understand them. I spent hours going through the original scripts and never completely understood how or why the "convert the data to hex format" or how to get the codes from it. I just stumbled on catching them in a message box by luck.

So hopefully with this format other uneducated people will be able to make use of their "Other HID" devices without spending hours figuring it out. And now that I'm in this mindset there are other AHK ideas I'm going to try to make accessible to the uneducated masses.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 398 posts ]  Go to page Previous  1 ... 13, 14, 15, 16, 17, 18, 19 ... 27  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group