How to Set Up a Key Sequence to Trigger a Script?

0
7
Asked By CuriousCoder47 On

I'm working on a script that needs to run continuously on a computer. The goal is to have it listen for a specific sequence of keys. When the user types this sequence, it should take the entire string they entered, paste it into Windows Explorer, and automatically press enter to open the corresponding file. I have a QR code scanner that will be used for input, and the codes will always start with the same 9 characters. I want to set this up so that it functions quietly in the background without showing an input box. Any tips on how to make this work?

5 Answers

Answered By TechieTom On

Honestly, PowerShell isn't ideal for this type of functionality, though it can technically work. You might find something like AutoHotkey easier to use, but I'm hesitant to install any third-party keyloggers on multiple machines. I just want a clean, native Windows solution, but I can't get it to respond to basic inputs like "abc" right now.

DevDude89 -

Totally get that. If you can avoid third-party programs while keeping it simple, that would be best. Have you tried making it constantly listen for input like a do-while loop? That might do the trick.

Answered By SolutionSeeker31 On

Consider simplifying your QR codes by integrating necessary key commands right into the barcode. Since the scanner functions like a keyboard, it might help to build the sequence straight into the code. Just make sure to test how it functions in practice.

CuriousCoder47 -

That's a great idea! I’m planning to input the key commands into the barcode, which should streamline things significantly. I'll work on that next!

Answered By CleverCoder22 On

This is definitely doable; I created something similar using .NET components before. However, be cautious, as most antivirus programs will treat it as a keylogger and flag it. You might want to try using a machine without antivirus to see if that helps with troubleshooting.

CuriousCoder47 -

Exactly! I think my own antivirus is causing issues. I'm looking for a simple trigger to show a message box when I type a specific sequence, but it's just not cooperating. I'll have to check the antivirus settings.

Answered By QRmasterX On

Does your QR scanner have a log feature to track the scans? You could set up something that triggers when a file update happens to get the latest entry, and use event listeners to open the file based on that.

CuriousCoder47 -

I can program the scanner to have a "prefix" before scanning, which could help. Also, I've found out how to type directly in the address bar, but I need to see if my scanner can handle special key commands.

Answered By DevDude89 On

You might want to consider setting up a service for this, but be mindful that what you're describing sounds a lot like keylogging, which antivirus software might flag. There are also tools like Watch Directory that could help you monitor folders for activity, possibly eliminating the need for complex coding.

CodeCrafter123 -

Good point about the antivirus. I plan to stick with PowerShell to avoid third-party keyloggers. I'm looking for a solution that only triggers on specific input, so I'm hoping to find a way to get that working without interference from antivirus.

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.