Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 815427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:40:54+00:00 2026-05-15T01:40:54+00:00

I work on a project called UAWKS (Unofficial Apple Wireless Keyboard Support) that helps

  • 0

I work on a project called UAWKS (Unofficial Apple Wireless Keyboard Support) that helps Windows users use Apple’s bluetooth keyboard. One of the main goals of UAWKS is to swap the Cmd key (which behaves as Winkey in Windows) with Ctrl, allowing users to do Cmd+C for copy, Cmd+T for new tab, etc.

It is currently developed using AutoHotkey, which worked pretty well under Windows XP. However, on Vista and Windows 7, Cmd+L causes problems:

  • Regardless of low-level keyboard hooks, Win+L is always intercepted by Windows and normally locks the workstation…
  • You can disable workstation locking with this registry hack, but pressing Win+L still can’t be rebound in AHK
  • Pressing Win+L leaves Winkey in the Keydown state until the next (additional) Winkey Up. Simulating a Keyup event doesn’t seem to work either!

It seems that Win+L is a special chord that messes everything else up.

I’ve looked through the AHK source code, and they try to address this problem in SendKey() in keyboard_mouse.cpp (near line 883 in v1.0.48.05), but it doesn’t work. I wrote up my own low-level keyboard hook application in C#, and I see the same problem.

Has anyone else run into this? Is there a workaround?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:40:54+00:00Added an answer on May 15, 2026 at 1:40 am

    I figured out a way to do this in C#. There are four states involved in a possible Win+L keypress sequence (None, Win, Win+L, L). Whenever the Win+L state is reached, set a flag ("winLSet" below). Whenever all of the keys have been released, we check for this flag and simulate the press if it’s been set.

    The final piece of the puzzle is to simulate the WinKey’s KeyUp before the Ctrl–L (no KeyDown). I’ve tried similar approaches in AutoHotkey and it never worked, but it seems to work perfectly here.

    The code is below. Please see explanatory notes at the bottom if you plan to use this code.

    public partial class MainWindow : Window
    {
        LowLevelKeyboardHook hook;
    
        bool winKeyDown;
        bool lKeyDown;
        bool winLSet;
    
        public MainWindow()
        {
            InitializeComponent();
    
            hook = new LowLevelKeyboardHook();
    
            hook.KeyDown += OnKeyDown;
            hook.KeyUp += OnKeyUp;
        }
    
        void OnKeyDown(object sender, LowLevelKeyEventArgs e)
        {
            e.EventHandled = true;
    
            switch (e.Key)
            {
                case Key.L:
                    lKeyDown = true;
                    UpdateWinLState();
                    e.EventHandled = winKeyDown;
                    break;
    
                case Key.LWin:
                    winKeyDown = true;
                    UpdateWinLState();
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LCONTROL);
                    break;
    
                case Key.LeftCtrl:
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LWIN);
                    break;
    
                default:
                    e.EventHandled = false;
                    break;
            }
        }
    
        void OnKeyUp(object sender, LowLevelKeyEventArgs e)
        {
            e.EventHandled = true;
    
            switch (e.Key)
            {
                case Key.L:
                    lKeyDown = false;
                    UpdateWinLState();
                    e.EventHandled = winKeyDown;
                    break;
    
                case Key.LWin:
                    winKeyDown = false;
                    UpdateWinLState();
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LCONTROL);
                    break;
    
                case Key.LeftCtrl:
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LWIN);
                    break;
    
                default:
                    e.EventHandled = false;
                    break;
            }
        }
    
        void UpdateWinLState()
        {
            if (winKeyDown && lKeyDown)
            {
                winLSet = true;
            }
            else if (!winKeyDown && !lKeyDown && winLSet)
            {
                winLSet = false;
    
                InputSimulator.SimulateKeyUp(VirtualKeyCode.LWIN);
    
                InputSimulator.SimulateModifiedKeyStroke(
                    VirtualKeyCode.LCONTROL,
                    (VirtualKeyCode)'L');
            }
        }
    }
    

    For posterity: please note that this code uses InputSimulator and LowLevelKeyboardHook, which are not from the .NET Framework. LowLevelKeyboardHook is a class I wrote a while back that exposes global KeyDown and KeyUp events as C# events. There are similar examples here, here, and a bunch can be found here.

    Also notice that I’m using System.Windows.Input.Key, not System.Windows.Forms.Keys, which could confuse some people. System.Windows.Input.Key is the new enumeration of keys in .NET 3.0 and above, while System.Windows.Forms.Keys is the old enumeration from Windows Forms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to work this out. In my project, i have a file called
I work on a project that uses multiple open source Java libraries. When upgrades
I've started work on a project that will be primarily acting as a Sync
I'm trying to work through Project Euler and I'm hitting a barrier on problem
I'm starting work on a project using Rails, but I'm waiting for the 3rd
I recently had to work on a project where the previous developer modified the
I've been doing a project at work recently focused on an almost entirely client-driven
Programming Student here...trying to work on a project but I'm stuck. The project is
I am starting a new client/server project at work and I want to start
I recently got involved in a Java project at work: we're using MyEclipse for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.