2

I'm trying to send keystrokes to a program in windows (exactly 7 pro) using .bat files and I have come to this question: Press Keyboard keys using a batch file

It works really well, but specifically I can't use the ALT key. My idea is to open the notepad.exe and use the ALT button to go the the options in the top menu (archive, edit...). When I use it manually it works, but when I use the code %SendKeys% "%a" for example (or only the alt button %SendKeys% "%") it only writes a in the notepad, without ALT being pressed. What I'm doing wrong?

How to use SendKeys method: msdn microsoft

my code:

@if (@CodeSection == @Batch) @then


@echo off

::rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"

start "" /B C:\Windows\System32\notepad.exe
timeout 2
%SendKeys% "%a"

goto :EOF


@end


// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
Community
  • 1
  • 1
cloudy_fog
  • 35
  • 4

0 Answers0