# Batch script - Spacebar keypress, possible?



## campain (Oct 17, 2005)

I'm after a batch script that can perform a single keypress. For all intents and purposes, I need something that appears to the computer to be a regular keypress as it needs to be performed inside a maximised window ( a game to be specific ).

I'm not even sure if this can be done, but any help at all would be greatly appreciated.


----------



## Ent (Apr 11, 2009)

I do not believe that this is possible with pure batch. You might be able to find a third party program to do this for you.

Other environments are more usable however. For example in VB script the following short code will send a spacebar signal to the running application every 1000 milliseconds (1 second). The downside is that it is, in its present form, an infinite loop. If you test it as is the only way to stop it is to kill the wscript.exe process from task manager or restart. You would paste that code into notepad and save as spacebars.vbs.


```
Set ws = CreateObject("WScript.Shell")
Do
Wscript.Sleep 1000
ws.SendKeys " "
Loop
```
If you prefer I could build it into a tiny exe file for you, but if you chose that option you'll have to say exactly what you need before you begin.


----------

