Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Check if my USB mouse is Connected.

If you have a question or need help, this is the place to be.
okys10
Posts: 9
Joined: Tue Jun 05, 2018 11:12 pm

Re: Check if my USB mouse is Connected.

Post by okys10 »

this event is a bit buggy cause its not always working.

Code: Select all

    <Event Name="System.Device.Removed.PointingDevice.HID-compliant mouse" >
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Check if my USB mouse is Connected.

Post by kgschlosser »

when you plug your mouse in and out an event gets triggeed with the name of the mouse. if you have more then one device with the same name then use this code.

place whatever actions you want to run for that device after the script. add the event for the device and away you go.

Code: Select all

device = eg.event.payload

if 'VID_09DA&PID_C10A' not in device.DeviceId:
    eg.StopMacro()
    eg.Exit()
    
okys10 wrote: Sat Jun 09, 2018 7:28 pm this event is a bit buggy cause its not always working.

Code: Select all

    <Event Name="System.Device.Removed.PointingDevice.HID-compliant mouse" >
the plugin is experimental. and i made it over a year ago. my knowledge of python and windows has grown vastly since then and I need to go over the plugin again ( probably a complete rewrite)
If you like the work I have been doing then feel free to Image
okys10
Posts: 9
Joined: Tue Jun 05, 2018 11:12 pm

Re: Check if my USB mouse is Connected.

Post by okys10 »

Hello kgschlosser,

there's an error i dont know what to do.

Code: Select all

                  Traceback (most recent call last):
           Python script "16", line 3, in <module>
             if 'VID_1C4F&PID_0003' not in device.DeviceId:
         AttributeError: 'list' object has no attribute 'DeviceId'
it seems DeviceId missing in the payload?
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Check if my USB mouse is Connected.

Post by kgschlosser »

Code: Select all

device = eg.event.payload[0]

if 'VID_09DA&PID_C10A' not in device.DeviceId:
    eg.StopMacro()
    eg.Exit()
    
If you like the work I have been doing then feel free to Image
Post Reply