Simulate a keyboard shortcut in batch
souwari
Posted messages
38
Status
Member
-
bricomachin Posted messages 245 Registration date Status Member Last intervention -
bricomachin Posted messages 245 Registration date Status Member Last intervention -
Hi,
I want to simulate a keyboard shortcut. With the help of a batch script for example. It’s to launch a shortcut on the desktop that itself is triggered by a keyboard shortcut.
Since I can’t launch this shortcut in batch, I came up with this idea.
How does it work?
Thank you.
I want to simulate a keyboard shortcut. With the help of a batch script for example. It’s to launch a shortcut on the desktop that itself is triggered by a keyboard shortcut.
Since I can’t launch this shortcut in batch, I came up with this idea.
How does it work?
Thank you.
1 answer
-
Hi,
So two possibilities:
To launch a shortcut using a batch file, you need to do it like this:@echo off start shortcut.lnk
It's the .lnk that matters. This way, Windows knows it's a shortcut file you're trying to launch. lnk is short for link. However, no spaces in the name, sorry ^^.
Otherwise, you can create a .vbs file that will contain a SendKeys instruction. I'm not a pro in vbs so check the (slim) documentation on MSDN: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys?redirectedfrom=MSDN&view=netframework-4.8#Y0