Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Execute CTRL + O , Windows key + M, ALT + S using a batch file

9,895 views
Skip to first unread message

mus...@gmail.com

unread,
Oct 19, 2008, 2:06:18 AM10/19/08
to mannoj.s...@igate.com
Hi All,

How to have access on Keboard keys using batch files -

I need to execute CTRL+o or Windows key+ M to minimize all open
windows and ALT + TAB to switch between windows using a single batch
file.

I'm trying to fix it terribly. Any help on this..?

Thanks in advance....

Robert Roland

unread,
Oct 19, 2008, 4:51:57 AM10/19/08
to
On Sat, 18 Oct 2008 23:06:18 -0700 (PDT), mus...@gmail.com wrote:

>How to have access on Keboard keys using batch files -

Batch has no inherent way of doing that. You can do it with VBscript,
but AutoIt is easier to use:
http://www.autoitscript.com/autoit3/index.shtml

>I'm trying to fix it terribly. Any help on this..?

Yes, sending keystrokes is always a terrible solution. There is
usually a better way to solve a specific problem.
--
RoRo

Richard Bonner

unread,
Oct 19, 2008, 8:06:43 AM10/19/08
to
Robert Roland (fa...@ddress.no) wrote:

> On Sat, 18 Oct 2008 23:06:18 -0700 (PDT), mus...@gmail.com wrote:
> >How to have access on Keboard keys using batch files -

> Batch has no inherent way of doing that. You can do it with VBscript,
> but AutoIt is easier to use:
> http://www.autoitscript.com/autoit3/index.shtml

*** One might also use a keystacker. I have done that within batch
files. One might also use CHOICE or XSET to accept user keyboard input,
but I suspect that is not what the original poster wants.


> >I'm trying to fix it terribly. Any help on this..?

> Yes, sending keystrokes is always a terrible solution. There is
> usually a better way to solve a specific problem.
> --
> RoRo

*** You are probably right, but I have used the above methods for so
long, that I have never thought about an alternate technique.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

Tom Lavedas

unread,
Oct 20, 2008, 9:21:29 AM10/20/08
to
On Oct 19, 4:51 am, Robert Roland <f...@ddress.no> wrote:

For example, using a little Windows Scripting in a hybrid batch
procedure ...

@echo off
echo CreateObject("Shell.Applications").MinimizeAll > %temp%\tmp.vbs
echo CreateObject("Wscript.Shell").Sendkeys "%%{TAB}" >> %temp%
\tmp.vbs
for %%a in (cscript del) do %%a %temp%\tmp.vbs

Of course, a VBS script could do this just as well, without resorting
to a batch (but this is a batch group).

If we knew exactly what the desired outcome was, it might be possible
to better tailor the script/batch to the problem.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

FileGod

unread,
Oct 21, 2008, 4:54:27 AM10/21/08
to
mus...@gmail.com wrote:
>Hi All,coHow to have access on Keboard keys using batch files -ooI need to
execute CTRL+o or
>Windows key+ M to minimize all openkwindows and ALT + TAB to switch between

windows using a
>single batch file.
>I'm trying to fix it terribly. Any help on this..? Thanks in advance....

There are programs to control Windows & DOS programs both, a great help for
you should be to search for Sendkeys, if you have Visual Basic you can write
a program using Sendkeys to control Windows programs, when I wrote one of my
batch files I just needed to have the batch file send the return key to a
antivirus program, oh, it was Avira Antivir & this worked:
echo ~| "C:\Program Files\Avira\AntiVir PersonalEdition Classic\avcls.exe"
%1

In Visual Basic it is easy to make a program to automate the Windows
programs, you would use Paint to use this...
Private Sub Form_Load()
RetVal = Shell("C:\Program Files\Norton Utilities\WINDOC.EXE", 1) 'Run
Norton WinDoctor.
SendKeys "{ENTER}", True 'Hit Enter
Unload Form1

I never did try doing Sendkeys in any Basic version for DOS but it uses
Shell instead of RetVal

Well, have a good one!
http://www.filegod.netfirms.com

mus...@gmail.com

unread,
Oct 21, 2008, 7:07:43 AM10/21/08
to
On Oct 21, 1:54 pm, 0...@0.0 (FileGod) wrote:

YEAH..
Im the author of this thread..

Atlast I have no other option to use rather that sendkeys..

It worked with vbs only..

Thanks to every one..

Regards,
Mannoj

Robert Roland

unread,
Oct 21, 2008, 11:46:15 AM10/21/08
to
On Mon, 20 Oct 2008 06:21:29 -0700 (PDT), Tom Lavedas
<tglb...@cox.net> wrote:

>For example, using a little Windows Scripting in a hybrid batch
>procedure ...

Here is another way to make a hybrid BAT/VBS file:

Write the VBS, but save it with .BAT as file extension, and insert
this line at the very top(single line):

set dummy=nothing:rem&cscript "%0" //E:VBS //NOLOGO&set dummy=&GOTO
:EOF

Although it leaves a few problems, and is not obviously useful, I
still think it's a little cool.
--
RoRo

20798...@gmail.com

unread,
Oct 15, 2017, 3:40:00 PM10/15/17
to
How would i make a file that would basically hold the ctrl key down. I'm trying to make it as a prank.

sanjaym...@gmail.com

unread,
Apr 2, 2020, 1:14:53 PM4/2/20
to
hey even i need same function i need ctrl-'s' to be pressed on execution of bat file
any one help

Robert Roland

unread,
Apr 3, 2020, 3:27:58 AM4/3/20
to
On Thu, 2 Apr 2020 10:14:49 -0700 (PDT), sanjaym...@gmail.com
wrote:

>hey even i need same function i need ctrl-'s' to be pressed on execution of bat file
>any one help

While automation is a good thing, sending keystrokes is a terrible way
to do it. In addition to sending the proper keystrokes, you will need
to ensure the correct application maintains focus while the keystrokes
are being sent. An interactive user can very easily mess up the
process.

Plain batch has no built-in way to send keystrokes. You can use a
hybrid VBscript or PowerShell method, but it is risky, since the
VBscript or PowerShell process could accidentally grab focus.

If sending keystrokes is truly the only option, I would take a look at
AutoIt. It has very powerful features, such as setting focus and
waiting for focus. It is a full featured scripting language, and it
can even compile the scripts into standalone EXE files.
--
RoRo
0 new messages