Need Help with PowerShell Script for Sending Modifier Keys

0
0
Asked By CuriousCoder42 On

I'm looking for a way to create a PowerShell script that can send modifier keys like Ctrl, Shift, Alt, or Win for a duration of 800ms. The tricky part is that it should stop immediately if the Esc key is pressed by the user. I'd like it to work alongside other keyboard or mouse inputs, for example, sending Ctrl along with scrolling the mouse to zoom in and out.

Previously, I tried using ChatGPT for help, but I got lost in the explanations. I'm considering sharing my code if that would help.

I've also asked around on AutoHotkey, and I was told that modifying keys might not be able to be sent alone. Is that a universal limitation or just specific to AutoHotkey? In my experiments with F-Key Sender using certain virtual key codes, I found that it is possible to send Ctrl and Shift alone, and that worked for zoom and scrolling.

I have two versions of the script I'm working on, which I would be happy to share for any insights or improvements!

2 Answers

Answered By MacroMaster On

Just a heads up, there are macro functions in many gaming keyboards that can do what you're trying to achieve in a second. It might be worth looking into those instead of coding from scratch!

EfficiencyEnthusiast -

Very true! Sometimes the simplest solution is just using the tools we already have.

Answered By ScriptSeeker On

Looks like you're missing the point of mixing modifier keys and mouse actions. PowerShell isn't built for this kind of automation as effectively as others. You might want to check out AutoHotkey instead; it's specifically designed for tasks like sending key presses along with mouse actions. Plus, you should try to format your code properly when asking questions—makes it easier for others to help!

HelpfulCoder -

Totally! Proper formatting can change how people perceive your question and help them assist you better.

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.