-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
- HP Community
- Notebooks
- Notebook Software and How To Questions
- Useful AutoHotKey script to map Insert and Context Menu on a...

Create an account on the HP Community to personalize your profile and ask a question
09-27-2024 10:04 PM
Hello,
I recently purchased a 13" HP Envy x360 2-in-1 laptop, and I realized that it's missing both the Ins key and the Context Menu key.
After researching a lot I found AutoHotKey as a tool to map the keys I'm missing. Primarily I decided to reuse the new "Copilot" key which is on the keyboard but I don't care for it.
I am sharing below the script that I used, which you can reuse (or borrow from) if you also download and install AutoHotKeys. Just save this script as C:\USers\<yourself>\Documents\AutoHotKey\capture-keys.ahk, then create a shortcut to this script and place it in the Startup folder.
Here is how I mapped my keys:
Copilot Key -> Context menu
Left Ctrl + Copilot Key -> Ctrl-Ins (copy)
Right Shift + Copilot Key -> Shift-Ins (paste)
Right Alt + Copilot Key -> Ins (toggle insert)
Note: due to the built-in mapping, I could not use the Left Shift key.
Here below is my AHK script; hope it's useful for everyone!
Paul
-----
#Requires AutoHotkey v2.0
#SingleInstance
; The "Copilot" key on the HP Envy x360 laptop is mapped as LShift LWin F23.
; We will remap it as follows:
; Copilot -> Apps context menu ("AppKey")
; Ctrl-Copilot -> Ctrl-Ins (copy)
; RShift-Copilot -> Shift-Ins (paste)
; RAlt-Copilot -> Ins (toggle insert)
; Ctrl-Copilot
<^<#<+F23::
{
Send "{LShift up}{LWin up}{LControl up}"
Send "{Ctrl down}{Ins}{Ctrl up}"
Return
}
; RShift-Copilot
>+<#<+F23::
{
Send "{LShift up}{LWin up}{RShift up}"
Send "{Shift down}{Ins}{Shift up}"
Return
}
; RAlt-Copilot
>!<#<+F23::
{
Send "{LShift up}{LWin up}{RAlt up}"
Send "{Ins}"
Return
}
; Place the main rule last, so it won't fire in the above cases
; Copilot (only by itself, without additional modifiers)
<#<+F23::
{
If !GetKeyState("LControl", "P") && !GetKeyState("RShift", "P") {
Send "{LShift up}{LWin up}"
Send "{AppsKey}"
}
Return
}
09-30-2024 11:46 AM
Hi @paul-k-me,
Welcome to HP Support Community.
Thank you for posting your query, I will be glad to help you.
Your AutoHotKey script for remapping the keys on your HP Envy x360 looks great! It’s a clever way to utilize the Copilot key for additional functionality, especially since the laptop lacks the Insert and Context Menu keys. Here’s a concise breakdown of your script along with a few enhancements you might consider for clarity and efficiency.
Breakdown of the Script
Basic Setup:
- The script uses AutoHotkey v2.0 syntax and sets it to single instance mode.
- It defines the Copilot key (F23) for use in remapping.
Key Mappings:
- Copilot Key: Opens the context menu.
- Ctrl + Copilot: Simulates Ctrl + Insert (copy).
- Right Shift + Copilot: Simulates Shift + Insert (paste).
- Right Alt + Copilot: Toggles the Insert mode.
Your AHK Script
#Requires AutoHotkey v2.0 #SingleInstance
; The "Copilot" key on the HP Envy x360 laptop is mapped as LShift LWin F23.
; We will remap it as follows:
; Copilot -> Apps context menu ("AppKey")
; Ctrl-Copilot -> Ctrl-Ins (copy)
; RShift-Copilot -> Shift-Ins (paste)
; RAlt-Copilot -> Ins (toggle insert)
; Ctrl-Copilot
<^<#<+F23:: {
Send "{LShift up}{LWin up}{LControl up}"
Send "{Ctrl down}{Ins}{Ctrl up}"
Return
}
; RShift-Copilot >+<#<+F23::
{
Send "{LShift up}{LWin up}{RShift up}"
Send "{Shift down}{Ins}{Shift up}"
Return
}
; RAlt-Copilot >!<#<+F23:: {
Send "{LShift up}{LWin up}{RAlt up}"
Send "{Ins}"
Return
}
; Place the main rule last, so it won't fire in the above cases
; Copilot (only by itself, without additional modifiers)
<#<+F23:: {
If !GetKeyState("LControl", "P") && !GetKeyState("RShift", "P") {
Send "{LShift up}{LWin up}"
Send "{AppsKey}" }
Return
}
HP Support Community Moderator
09-30-2024 11:46 AM
Potential Enhancements
- Add Comments: You've done a great job with comments. Ensure that each section clearly explains its purpose, especially for others who may use your script.
- Error Handling: Consider adding error handling to notify if the key mapping fails or if the AutoHotkey script is not running.
- Customizing Keys: If you find you need different key mappings in the future, you can easily modify the key combinations at the top of the script.
- Dynamic Key Assignment: If you're familiar with other keys that might serve a better purpose, you can explore using different keys in place of the Copilot key or add additional functionalities.
- Script Activation/Deactivation: You might want to add a toggle key to activate or deactivate the script quickly without having to close it entirely.
How to Use Your Script
- Save the Script: Make sure you save your script as C:\Users\<yourself>\Documents\AutoHotKey\capture-keys.ahk.
- Create a Shortcut: Right-click on the script file, select Create Shortcut, and place the shortcut in your Startup folder to run it automatically at startup.
- Run the Script: Double-click the script or use the shortcut you created to run it whenever you need it.
Your script is an excellent solution for users of the HP Envy x360 looking to regain the functionality of missing keys. Thanks for sharing it!
I hope this helps.
Take care and have a good day.
Please click “Accepted Solution” if you feel my post solved your issue, it will help others find the solution. Click the “Kudos/Thumbs Up" on the bottom right to say “Thanks” for helping!
Alden4
HP Support
HP Support Community Moderator