Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch files to manipulate other programs  (Read 3897 times)

0 Members and 1 Guest are viewing this topic.

Ax8472

  • Guest
Batch files to manipulate other programs
« on: November 19, 2011, 11:12:50 AM »
Hi guys. Not sure if anyone can help me. I've never posted on here before but would appreciate any kind of help, you guys all seem so smart!

My problem is, I run software on my PC to help me host software for a videogame. I'm wanting to run a command inside this software automatically, so I'd need a batch file to do this for me, I believe. Then I'll get task scheduler to automatically run this and restart my PC at night.

What I can't seem to accomplish is getting a batch file to run a command in an already existing windows. Now there are two windows available. There's a java window which allows me to input commands (the command I'd like to input is simply "stop". This saves and shuts it down, avoiding corruption of the game map.  The other windows is a command line windows, and can also be used in just the same way.

It doesn't matter which the text is written into, so long as one of the windows has the text input to save and close the program. Then I'll look into creating a batch file to restart the machine.

I'm very, VERY new with command line. I've been trying to learn the best I can but I'm a little stuck now. Again, any help would be fantastic.

Many thanks in advance.

ulrichburke



    Greenhorn

    Re: Batch files to manipulate other programs
    « Reply #1 on: November 21, 2011, 12:02:15 AM »
    Hi!

    Why not do the whole thing from within a single batchfile? The following is just an idea, NOT THE RIGHT TECHIE WORDING, but it would look a little like this:

    CLS
    START hostsoftware
    STOP
    END

    The theory behind the above (and here's where a dozen supergeeks say 'Pratfeatures missed out Command X here...') is that STARTis EXACTLY THE SAME as double-clicking with a mouse on an icon. So it'll start the software . Now control will be taken over BY the started software, so the next line of the batchfile won't be reached until the game is exited. When the game/software is exited, THEN control will pass to the next line, the word STOP, which is what you want. END will just end the batchfile, or you could use RTS, which means Return To System.

    Most DOSes have a prog called EDLIN which wll let you create a batchfile while in DOS. Just type EDLIN from the C:\ prompt (root directory).

    Hope this helps, just remember the wording of the demo batchfile above is just for example purposes - I always have to pratt about with batchfiles to get them working with things so it is just to give you an idea, it prob. wont work straight off like that.

    If you want more help on yhe wording, tell me what the game is and if I can access it I Will do the best I can for you.

    Regards

    Ulrichburke


    quaxo



      Guru
    • Thanked: 127
      • Yes
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 11
    Re: Batch files to manipulate other programs
    « Reply #2 on: November 21, 2011, 01:32:03 AM »
    To my knowledge, there isn't a batch command that will type into another program. However, a keyboard/mouse macro program might be able to do it. (http://www.autohotkey.com/ for example.) Autohotkey has a feature to create an EXE of the macro. Potentially with that you could create a batch to run it or even have it scheduled to run at a certain time (through Task Scheduler or something similar).