csavalas / HotkeyMapper

Hotkey Mapper for Lenovo Thinkpads
23 stars 0 forks source link

Question: Remapping F8 Mode Key #9

Open technolph opened 1 month ago

technolph commented 1 month ago

Hi,

I'm trying to remap the F8 special function (Special function of F8 is "Mode" on my Lenovo Thinkpad P1 Gen7). Normal behavior is when I press that button the System -> Power & Battery window opens, but I'd like to remap it to something else.

My settings are:

Not sure what I'm doing incorrectly? Thanks for any guidance/support.

csavalas commented 1 month ago

Hey there,

Yeah, let's see what we can do here! I have a P1 Gen 6, and I know it works for the Gen 4 and Gen 5 too. Haven't tried it on the Gen 7's yet, so we'll need to investigate a little bit. Out of curiosity, is F8 the only key that doesn't work or is it all of them? Either way, check out my post here for instructions on how to get me the info I would need to get it working on your machine:

https://github.com/csavalas/HotkeyMapper/issues/1#issuecomment-2161856210

technolph commented 1 month ago

Thanks for the reply! Ok, I think this is helping to diagnose the issue. I downloaded process monitor and only a handfull of my F keys are showing up when I press them:

F12: Ex_90 F11: the phone link app launches (nothing shows up in process monitor) F10: Ex_91 F09: print screen (nothing shows up in process monitor) F08: the power and battery system settings page opens (nothing shows up in process monitor) F07: 7 F6: Ex_0F F5: Ex_10 F4: EX_1A F3: the volume increases (nothing shows up in process monitor) F2: the volume decreases (nothing shows up in process monitor) F1: the volume is muted (nothing shows up in process monitor)

Apologies in advance -- I'm a long time Mac user so I'm less familiar with Windows, but happy to provide as much info/details to get this diagnosed.

csavalas commented 1 month ago

Hey there,

Hmmmm... I suppose it's possible that Lenovo changed things up a bit with the Gen 7, though that would be unfortunate. Are absolutely, 100% positive that nothing showed up for those keys? If you are, then we're venturing into uncharted territory!

technolph commented 1 month ago

Unfortunately nothing does seem to be popping up. I even tried by running this Python script and the keys that I didn't get hex codes for didn't register when I was running the Python code:

import keyboard

def print_hex(e):
    hex_value = hex(e.scan_code)
    print(f'Key: {e.name}, Hex Value: {hex_value}')

# Listen for keypresses
keyboard.hook(print_hex)

# Keep the program running
keyboard.wait()
csavalas commented 1 month ago

Regarding your Python script, yeah, that's actually the whole reason why I had to make the program in the first place, because Windows cannot pick up the keystrokes directly, rather, the Lenovo driver mediates them with shtctky.exe. It's why Autohotkey or Powertoys don't work, for example.

So, clearly something is working slightly differently on the Gen 7's. What's strange though, is that it actually uses the exact driver (and version of the driver) as my Gen6; I just checked for you: Lenovo Base Utility.

I wish I had a Gen 7 to mess around with directly, but I could help you figure it out on your end, then integrate the findings into the utility to help other people with Gen 7's. If you are down, I think a good first step would be to broaden the filters in process monitor to include these executables from within the Lenovo driver package, and see if anything interesting comes up:

C:\DRIVERS\HOTKEY\20242710.11123074\driver>dir *.exe
Volume in drive C has no label.
Volume Serial Number is 6202-A493

Directory of C:\DRIVERS\HOTKEY\20242710.11123074\driver

08/15/2024  05:23 PM           183,776 ACButton.exe
08/15/2024  05:23 PM           162,272 errmsg.exe
08/15/2024  05:23 PM           113,632 fnf3.exe
08/15/2024  05:23 PM           114,144 fnf6.exe
08/15/2024  05:23 PM           116,600 FnHotkeyWidget.exe
08/15/2024  05:23 PM           242,144 hlp8.exe
08/15/2024  05:23 PM           355,704 shtctky.exe
08/15/2024  05:23 PM           170,976 toast.exe
08/15/2024  05:23 PM           256,480 tphkload.exe
08/15/2024  05:23 PM           265,584 tpnumlkd.exe
08/15/2024  05:23 PM         1,020,792 tposd.exe
technolph commented 1 month ago

Hey @csavalas -- apologies for my delayed response.

Ok, I added those processes to Process Monitor. Some of the keys trigger a lot of output, so I've attached log files for them. The shorter ones I've included here.

Columns for the below output:

Time of Day; Process Name; PID; Operation; Path; Result; Detail; Event Class; Sequence

When I press F9:

5:57:20.3586172 AM  SHTCTKY.EXE 8668    Thread Create       SUCCESS Thread ID: 15148    Process 9
5:57:20.3622320 AM  SHTCTKY.EXE 8668    Thread Create       SUCCESS Thread ID: 29428    Process 10
5:57:21.1907034 AM  TPHKLOAD.exe    6180    Process Profiling       SUCCESS User Time: 0.2031250 seconds, Kernel Time: 0.3437500 seconds, Private Bytes: 4,075,520, Working Set: 10,825,728 Profiling   11
5:57:21.1909528 AM  TPOSD.EXE   2568    Process Profiling       SUCCESS User Time: 0.0312500 seconds, Kernel Time: 0.0468750 seconds, Private Bytes: 2,416,640, Working Set: 9,289,728  Profiling   12
5:57:21.1909539 AM  SHTCTKY.EXE 8668    Process Profiling       SUCCESS User Time: 0.0781250 seconds, Kernel Time: 0.6718750 seconds, Private Bytes: 3,260,416, Working Set: 12,722,176 Profiling   13
5:57:22.1922491 AM  TPHKLOAD.exe    6180    Process Profiling       SUCCESS User Time: 0.2031250 seconds, Kernel Time: 0.3437500 seconds, Private Bytes: 4,075,520, Working Set: 10,825,728 Profiling   14
5:57:22.1923150 AM  TPOSD.EXE   2568    Process Profiling       SUCCESS User Time: 0.0312500 seconds, Kernel Time: 0.0468750 seconds, Private Bytes: 2,416,640, Working Set: 9,289,728  Profiling   15
5:57:22.1923159 AM  SHTCTKY.EXE 8668    Process Profiling       SUCCESS User Time: 0.0781250 seconds, Kernel Time: 0.6718750 seconds, Private Bytes: 3,260,416, Working Set: 12,722,176 Profiling   16
5:57:22.4397735 AM  TPOSD.EXE   2568    RegQueryKey HKLM    SUCCESS Query: HandleTags, HandleTags: 0x0  Registry    17
5:57:22.4398052 AM  TPOSD.EXE   2568    RegOpenKey  HKLM\System\CurrentControlSet\Services\SmartSense\Parameters\AutomaticKeyboardLight REPARSE Desired Access: Read    Registry    18
5:57:22.4398370 AM  TPOSD.EXE   2568    RegOpenKey  HKLM\System\CurrentControlSet\Services\SmartSense\Parameters\AutomaticKeyboardLight NAME NOT FOUND  Desired Access: Read    Registry    19

Let me know what else I can provide to help diagnose this. Thanks again!

Logfile F1.CSV Logfile F2.CSV Logfile F3.CSV Logfile F8.CSV Logfile F10.CSV Logfile F11.CSV

csavalas commented 1 month ago

Hey again, two things:

  1. Did you definitely add hlp8.exe to your filters before doing this experiment? I'm sure you probably did, just wanted to be sure.

  2. Can you send me a backup of this key in your registry: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo

technolph commented 1 month ago

Yep, just confirmed that hlp8.ex was included.

Here's a backup of those registry keys:

Lenovo_backup.zip

csavalas commented 1 month ago

Ok, as a preliminary troubleshooting step, try deleting this key:

HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\ShortcutKey\AppLaunch\3

The hope is that, after doing so, the power window will no longer open when pressing F8, let me know!