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.

Changes to System.DeviceAttached/System.DeviceRemoved

Got a good idea? You can suggest new features here.

Add device names and other device data to System.DeviceAttached/System.DeviceRemoved

Yes
14
100%
No
0
No votes
Have no clue what I am talking about
0
No votes
Don't care
0
No votes
 
Total votes: 14

User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

no it's just that there are so many different device types. and each device type actually houses the devices. so essentially what i am doing is going to a "house address" which is an apartment building. and then looking at the name (vendor id) on the mailbox next to each door.. if it matches then i knock on the door and the device answers and just like people everyone is different same goes for devices they have different attributes. some will have DeviceId. others DeviceID and other HardwareId and I have the list of who has what but there are so many of them I could have gotten a couple mixed up a little. Now i only tried to provide the key attributes for a device in the payload. but what i also included in the payload is the actual device it's self. so if there is something you may want to ask the device that i didn't already ask it. (because some devices literally have 40-50 different things you can ask it) you can. i will post the help for ya. but it's going to be incorporated into the GetDevice Action. once i finish it up. the help file is a zip with a py file in it. the variable names in the py file match up to the 3rd section of the event. which is the device type..

the events are as follows

System.DeviceAttached.SOME_DEVICE_TYPE.SOME_DEVICE_NAME
System.DeviceRemoved.SOME_DEVICE_TYPE.SOME_DEVICE_NAME
System.DriveMounted..SOME_DEVICE_TYPE.SOME_DEVICE_NAME.DRIVE_LETTER
System.DriveRemoved.SOME_DEVICE_TYPE.SOME_DEVICE_NAME.DRIVE_LETTER
Attachments
Help.zip
(78.34 KiB) Downloaded 93 times
If you like the work I have been doing then feel free to Image
Diz
Experienced User
Posts: 121
Joined: Tue Jan 10, 2017 4:49 pm

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by Diz »

yeah... ummm... i have no idea what im supposed to do with that! lol. what about the plugin not running for me until i edited it? it ran for you right?
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

here is an updated version with corrected attribute names. there were a couple that were mixed up. i haven't gone through all of the available device types yet. i checked about 35% of them and corrected what errors i have found thus far.
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

it ran for me yes. but i did not have a device plugged in that used that specific device type. so i would not have encountered the error. what you did was correct. I just went back and verified as to what device types were supposed to have it and which ones not.

Oh that's right.. the help files are in code...


here i have a set broken up.. attached is a zip full of html files
Attachments
saved help files.zip
(348.52 KiB) Downloaded 77 times
If you like the work I have been doing then feel free to Image
Diz
Experienced User
Posts: 121
Joined: Tue Jan 10, 2017 4:49 pm

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by Diz »

aah ok, i see. but even with that newest version i need to comment out the 'FirmwareRevision' line in the 'attr_names' section of the 'DiskDrive' device to make it work
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

that's verry odd because according to the win32 api it states that the firmware should be in there. But again you are running windows XP. and there could lie the issue. So i will set up a pull request for windows version checking. because i need to access the same code from multiple places I think it should be added to it's own file and a little "fluff" added to it to make it easy to use. Because i can see we need to have a reliable and easy way to check windows versions that is easy to add onto. So I am going to make that up right snappy. and submit it to be added to the core code.
If you like the work I have been doing then feel free to Image
Diz
Experienced User
Posts: 121
Joined: Tue Jan 10, 2017 4:49 pm

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by Diz »

yeah, i saw it in the help myself... weird huh? lol. do you think all the false tv tuner hits can be fixed at some point?
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

ok I made some changes.. but you are going to have to follow the comments for each file.. there are 2 of them now.

this adds a nice little utility to check windows versions. So if you wanted to use it in a script it would be

Code: Select all

eg.WindowsVersion.IsXP()
eg.WindowsVersion.IsVista()
eg.WindowsVersion.Is7()
eg.WindowsVersion.Is8()
eg.WindowsVersion.Is10()
It returns a True or False so it can be used in an if/elif statement very easily

Code: Select all

if eg.WindowsVersion.IsXP():
    DO YOUR XP CODE HERE
elif eg.WindowsVersion.Is7():
    DO YOUR 7 CODE HERE
But see if this fixes the issue. I had already commented the GUID's that are supported by windows XP i just had not implemented the version checking.. so now that is done as well as the Firmware thing.
Attachments
WindowsVersion.py
Place this file in your C:\Program Files(x86)\EventGhost\eg\Classes folder
(1.69 KiB) Downloaded 69 times
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

it's not a fault. it's what the makers of a device have registered their device driver to. I am not sure as to why it is registered to the TV Tuner.. but it is.. it only happens when i plug my phone in.. I will check just to make sure i didn't mix up something somewhere along the lines.
If you like the work I have been doing then feel free to Image
Diz
Experienced User
Posts: 121
Joined: Tue Jan 10, 2017 4:49 pm

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by Diz »

ok it works as is for me now. the tv tuner false hit thing happens on both my phones and my memory stick. you say its not a fault? ok, but, ummm... it doesnt exactly seem like the 'correct' behaviour either does it? lol :mrgreen:
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

I have found a better way...!!! and is going to make the mounting/unmounting of a volume work properly.
If you like the work I have been doing then feel free to Image
Diz
Experienced User
Posts: 121
Joined: Tue Jan 10, 2017 4:49 pm

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by Diz »

nice ;)
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

Issue with the TV tuner is also sorted out. It's hard to get it right because the notification only contains the device type GUID and the hardware ID. And I am using WMI to poll the devices. The issue is the device types for the notification dont all have a direct line to a WMI device type. I can pull all of the devices on the system. But because you can have a single device that has 4 entries. The chance of grabbing the wrong one is pretty high. So I am trying to find unique identifiers that I can search for that would identify it to the proper device type the notification is for. And this is really difficult because I don't own all of the various different devices. So to be honest some of it is a guessing game. I am going to have to see if I can find a device emulator program that way I won't have to keep on adding to it if someone has a device that doesn't show up properly
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by kgschlosser »

ok.. this is a massive upgrade.. actually almost a whole rewrite. i still have to sort out the GetDevices Action. and I know of one glitch with network mapped drives and only when disconnecting them not sure what is causing it as of yet. i will poke around some more and get it fixed. But I am liking the way it is working thus far.. and it's fast too. and provides all kinds of good metrics that can be used in scripting. like volume names, disk sizes. free space. max monitor resolution. i don't even know what else I have added so much functionality to it.

went from 137 lines of code to 1276 lines.
Attachments
DeviceChangeNotifier.py
(41.99 KiB) Downloaded 75 times
If you like the work I have been doing then feel free to Image
Diz
Experienced User
Posts: 121
Joined: Tue Jan 10, 2017 4:49 pm

Re: Changes to System.DeviceAttached/System.DeviceRemoved

Post by Diz »

looks good so far... much better without all the tv tuner hits! :mrgreen:
Post Reply