It is currently April 27th, 2024, 8:48 pm

Detect if a keyboard/headphone is attached

Get help with creating, editing & fixing problems with skins
TristanVos
Posts: 1
Joined: February 4th, 2024, 5:28 pm

Detect if a keyboard/headphone is attached

Post by TristanVos »

Hello everyone!

I'm utilizing Rainmeter to create a straightforward touchscreen interface for the horse stable where I work, primarily for playing music during events and competitions.

I recently designed an "Alert" image to notify users when the charger is not connected, as I've received reports of the tablet seemingly turning off unexpectedly. The device is set up to initiate Rainmeter upon startup and immediately close explorer.exe (the Windows UI).

Currently, I'm working on implementing a dialogue box that displays essential information:

Charging: Indicates whether the charger is plugged in or not (I've already figured out how to implement this).

Speakers: Shows whether the audio cable is attached or not.

Keyboard: Indicates if the keyboard is connected. We're running this on a Microsoft Surface Go.

USB: Shows if any USB devices are connected; it should not indicate "yes" if only the keyboard is connected.

I appreciate any assistance you can provide!

Thanks in advance for any help!
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Detect if a keyboard/headphone is attached

Post by Yincognito »

TristanVos wrote: February 4th, 2024, 5:37 pm Hello everyone!

I'm utilizing Rainmeter to create a straightforward touchscreen interface for the horse stable where I work, primarily for playing music during events and competitions.

I recently designed an "Alert" image to notify users when the charger is not connected, as I've received reports of the tablet seemingly turning off unexpectedly. The device is set up to initiate Rainmeter upon startup and immediately close explorer.exe (the Windows UI).

Currently, I'm working on implementing a dialogue box that displays essential information:

Charging: Indicates whether the charger is plugged in or not (I've already figured out how to implement this).

Speakers: Shows whether the audio cable is attached or not.

Keyboard: Indicates if the keyboard is connected. We're running this on a Microsoft Surface Go.

USB: Shows if any USB devices are connected; it should not indicate "yes" if only the keyboard is connected.

I appreciate any assistance you can provide!

Thanks in advance for any help!
By itself, Rainmeter does not provide these values, so you might want to go WMI or PowerShell (runnable via RunCommand measures) or some other way of monitoring these (HWINFO64?) and try your luck that way. As for headphones, if the above approaches don't yield what you need, you could check the Device related values for AudioLevel measures. For USB drives, there could be limited success by using the IgnoreRemovable option of FreeDiskSpace measures, though I'm not sure if it's what you're looking for.

Something to start with:
https://docs.rainmeter.net/manual/plugins/runcommand/
https://docs.rainmeter.net/manual/plugins/audiolevel/
https://docs.rainmeter.net/manual/measures/freediskspace/
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth