0

I want to make keys combination to file exmp:

ctrl+alt+1

  • make this combination to file, then click on file do this key combination. I used an kvm switch, so I want to make files combinations.
Tejas Pandya
  • 3,987
  • 1
  • 26
  • 51
Oz.
  • 1
  • 2
    Can you give more context about what you want to achieve and what you tried so far? – Nico Haase Dec 19 '17 at 11:26
  • i want to add my microsoft keyboard to an empty keys uses, this file, to change computer in kvm switch. exmp: for change cumputer number1: i need ctrl+alt+1, computer num2 ctrl+alt+2 etc... so i want make this combination to file then assign this to keyboard. i very sorry for my english – Oz. Dec 19 '17 at 12:29

1 Answers1

0

Pure batch is not able to simulate any keystrokes. However, you can use a different scripting language for this. In this example, I will use VBScript and call this script from a batch file:

Set Wsh=WScript.CreateObject("WScript.Shell")
Wsh.SendKeys "<what ever key combination you need>"

Store this code in a file, say KVM1.vbs. Now create a batch file wich will cann the vbs file:

@ECHO OFF
wscript "C:\some_path_to\KVM1.vsb"

Now the last thing: how to send CTRL+ALT+1? In VBScript ^ means CTRL, % means ALT so CTRL+ALT+1 would be ^%1. So the last thing to do is to replace <what ever key combination you need> in the script above with ^%1. This should simulate pressing CTRL+ALT+1 on the keyboard.

However, depending on you KVM this won't help you. Some KVMs will recognize keystrokes simulated by the OS but some won't. As you keyboard is usually connected directly to the KVM the KVM itself will recognize the combination pressed on the keyboard. Any simulated keystrokes from the OS take place _IN_THE_OS_ so they won't be visible to the KVM.

MichaelS
  • 5,941
  • 6
  • 31
  • 46
  • Thanks. I made there files: https://imgur.com/a/oUS2M I get this error: there is no script engine for file extension .vbs (I know KVM recognzie keyboard, but i have kvm software that allow me use ctrl+alt+NUMBER. big thanks – Oz. Dec 19 '17 at 13:51
  • That's strange. This means that your os doesn't know how to run visual basic script files - but it should! Check this link, plz: https://stackoverflow.com/questions/17757248/error-there-is-no-script-engine-for-file-extension-vbs-when-using-git-bash – MichaelS Dec 19 '17 at 13:56