Search This Blog

Showing posts with label Keyboard. Show all posts
Showing posts with label Keyboard. Show all posts

Friday, October 6, 2023

Keyboard: Remapping function keys

Looking at my keyboard I was wondering if there was a way for me to change the built in functions of the keyboard such as "open default mail app" or "play/pause music".

Seems like there is a way by editing the registry.

The following way will change the settings for all users of the computer, and as always, the registry is a dangerous place to edit if you aren't careful.

1. Open regedit as administrator and go to the following adress:  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\

2. You will see numbered folders (called "keys"). Folder number 16 is your media player, in my case it was preset to open Windows Media Player. Thus a good candidate to be replaced.

3. Within the folder of your choice create a string value (REG_SZ) called ShellExecute.
Open that file up and set its value to a path leading to your program, put within quotation marks.
In my case I chose the path to PowerShell: "C:\Program Files\PowerShell\7\pwsh.exe"


In my case the effect was immediate, no restart was required. However, the day after it was not working as intended. It seemed to be working only if I had an admin session of regedit open. Trying to add it to Current User hive did not seem to work either.

We know that folder number 16 equated to the media button. What other buttons might there be?
Well this article lists all the potential numbers, obviously your keyboard might not have the email button and you might not be able to remap the email button to another program. I only chose to inspect/modify the already existing registry keys (15, 16, 17, 18, 7) instead of creating new ones.

Based of the article we can see the following examples of registry keys and their inherent functions:

1 = Browser navigation backward, 2 = forward, 3 = refresh, 4 = stop, 5 = search, 6 = favorites, 7 = home.

8 = mute volume, 9 = volume down, 10 = volume up, 11 = next track, 12 = previous track, 13 = stop, 14 = play/pause

15 = mail, 16 = media, 17 = app 1, 18 = app 2, 19 = bass down, 20 = bass boost, 21 = bass up, 22 = treble down, 23 = treble up

The numbers are arbitrary, you have to look where the functions are located physically on your keyboard. In my case the number 16 (media) was located on fn + escape. Thus, when I pressed fn + escape it started my PowerShell window. Beware, it seems to be unstable and might stop working for you though.

Here is the reg file content that you can work with, as you can see I experimented with Current User.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AppKey\16]
"ShellExecute"="C:\\Program Files\\PowerShell\\7\\pwsh.exe"

Enjoy!

Sunday, September 17, 2023

Hardware: Finding device info using PowerShell

The hunt for more information began with a new keyboard I have. A wireless keyboard called "Deltaco TB-632". As an avid Deltaco fan I also knew that they rarely make their own products, but they rebrand devices that they source from other companies.

One example is their smart home devices that in at least one case seems to come from China.

So how did I go about finding more information about this keyboard? Well, old trusty PowerShell of course. After first trying to find a way using the control panel and settings to see a MAC address or other identifying information I simply turned to the command Get-Pnpdevice.

If you run this command you will discover practically all devices that has been connected to the computer since the last OS installation. They will be listed as Unknown if they aren't connected and OK if they are working fine.

This is the main code I ran: get-pnpdevice -Class USB | Select-Object status, friendlyname, instanceid | Sort-Object -Property friendlyname

First I ran the command without the USB wireless receiver attached.

Then I attached the receiver and ran the command again. By doing this I could see which device that turned from Unknown to OK.

In this specific case I got a result looking like this:

OK USB Composite Device USB\VID_248A&PID_8367\5&194485C0&0&1

Now that you have the VID (vendor ID) and PID (device ID) for your device you can simply Google these identifiers.

My result indicated that the Deltaco TB-632 seems to be provided by the company Maxxter and the USB device is called Telink Wireless Receiver.

Using the same method I tried looking for the keyboard unit itself as well in the list of PnP devices. I tested this theory by running the following command without and with the device plugged in.

(get-pnpdevice -Status OK).Count



The result was that 8 devices appeared when the receiver was plugged in.

To find out which devices that make up the difference you can combine Get-Pnpdevice with Compare-Object. Adapt the code after your individual situation.

First run this code with the device in:
 get-pnpdevice -Status OK | Sort-Object ClassGuid | Out-file -FilePath C:\temp\dev1.txt

Then run this code with the device out:
get-pnpdevice -Status OK | Sort-Object ClassGuid | Out-file -FilePath C:\temp\dev2.txt

To then compare the output run this comand:

Compare-Object -ReferenceObject (Get-content -path C:\temp\dev1.txt) -DifferenceObject (Get-Content -Path C:\temp\dev2.txt)

The output will look like this, the arrow shows that the result is present in the reference object, which in this case was to the left and missing in the difference object to the right, which means that they disappeared when we unplugged the device.


From here you can then investigate further from the VID and PID that you get.

Happy hunting :-)