Search code examples
batch-filebatch-processingbatch-rename

Keyboard inputs to application using batch script


Can any one help me to know how to give inputs to an application using batch script?

Explanation:

I have an application which enables logging when we press F1 key and disables logging when we press the Alt+L key from the keyboard. These key's only work when the application is in active state(Active in TaskBar)/ it is front in the screen. What i mean is we need give these inputs on that application.

Can any one help me with the batch script where the i can enable logging it by pressing F1 and should disable it after 50 Sec by pressing the Alt+L on the active application window?

Thanks in advance.


Solution

  • Batch can't. VBScript can

    Set sh = WScript.CreateObject("WScript.Shell")
    sh.Run "notepad.exe", 9
    WScript.Sleep 1000 'wait a while to load notepad app'
    AppActivate "Untitled - Notepad"
    sh.SendKeys "Hello World!"  
    sh.SendKeys "{ENTER}"
    WScript.Sleep 100'
    sh.SendKeys "^p"
    
    ^=control
    +=shift
    %=Alt
    {F1}=F1
    %L=Alt + L