How Can I Emulate a Key Press in Windows to Enable Character Repeat?

0
4
Asked By GamerGal123 On

Hey everyone!

I'm working on a pretty unique project and could use some assistance. I'm trying to create a program that will remap my mouse's right-click to the keyboard key 'C', but I need it to trigger the Windows character repeat feature. Essentially, I want to be able to hold down the right mouse button in Notepad and have it repeatedly input 'C', just like if I were holding down the 'C' key on my keyboard.

I've done some research, and there are plenty of guides out there about using hooks for remapping keys, but none seem to cover how to actually make the character repeat happen.

Here's the context: I'm getting into speedrunning the game *Ori and the Blind Forest*, and runners usually rebind right-click to 'C' using their mouse software, which allows for that auto-repeat effect. I've found that this repeat functionality is key to making a specific glitch work consistently. While I could just hit 'C' on the keyboard, using the right-click feels more comfortable.

I got a new mouse, but unfortunately, I can't use the vendor's software to remap right-click to 'C'. Other remapping software works but doesn't trigger the key repeat behavior, which is a bummer.

I've looked into the Win32 API a bit; I tried sending a WM_KEYDOWN message followed by a WM_KEYUP, but this doesn't cause the repeat to kick in. It seems like you'd need to spam multiple WM_KEYDOWN messages to get repeat behavior, but that might not be allowed according to leaderboard rules. The community has advised that I should stick to using Windows character repeat, which is a bit odd but seems necessary for consistency.

So in a nutshell, I need to write a program that:
- Remaps right-click to 'C'
- Activates Windows character repeat
- Doesn't introduce any timing delays because those aren't permitted in my case
- Ideally does this all in userspace without needing a kernel driver.

Thanks for any help you can provide!

3 Answers

Answered By InputMaster57 On

Have you tried the SendInput API or the keybd_event function? Those might help you achieve the character repeat action you’re looking for.

Answered By TechWizard99 On

You might want to give Autohotkey a shot! If simply substituting the key doesn’t work, you can directly remap the down and up events for the right-click. Plus, Autohotkey allows you to filter the remaps to only activate in certain software, making it pretty flexible.

Answered By CleverKeyz On

It's worth noting that 'Windows character repeat' isn't exactly a system feature—it's actually a function of your keyboard hardware. Windows does have an accessibility feature called FilterKeys, which helps manage repeated inputs, but it doesn’t generate them on its own.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.