open and run program thru batchfile

December 20, 2010 at 00:04:47
Specs: Windows 7
im trying to create a batch file that will open an external program and access it's menu.
example: open fpti loader, then open cube fact data, then run all

See More: open and run program thru batchfile

Report •


#1
December 24, 2010 at 12:38:13
i dont think batch files can access GUI menues, However you can use combination of Batch and VBscript.
From VBscript you can read menu items and send appropriate keys.

Subhash Chandra.


Report •

#2
December 28, 2010 at 08:37:17
oh thank you.. now i need to know how to code that in VBscript. thanks. i'm just a newbie in programming :-)

Report •

#3
December 29, 2010 at 14:22:45
As example cretae a batch file and put below code.
++++++++++++++++++++++++++++++++++++++++++++

@echo off

echo Set WshShell = WScript.CreateObject("WScript.Shell") >temp.vbs

echo wshshell.run "Notepad" >>temp.vbs
echo wshshell.AppActivate "Notepad" >>temp.vbs
echo wscript.sleep 1000 >>temp.vbs
echo WshShell.SendKeys "test" >>temp.vbs

wscript temp.vbs

+++++++++++++++++++++++++++++++++++++++++++++++
it will open Notepad and then type "test".

Similierly. You can replace notepad with the full path of your application.
echo wshshell.AppActivate "Notepad" , here AppActivate will make sure the Application with title "notepad" is on keyboard focus. You can replace the title of your application here.
once you application is open and on focus you need to know which keys you want to send.
like to open "Open" dialog box a comoun key is "CTRL + O",

I will paste the list of keys below..


Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, use "A" for string. To represent more than one character, append each additional character to the one preceding it. To represent the letters A, B, and C, use "ABC" for string. The plus sign (+), caret (^),tilde (~), and parentheses ( ) have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use {+}. To specify brace characters, use {{} and {}}.

To specify characters that aren't displayed when you press a key, such as ENTER or TAB, and keys that represent actions rather than characters, use the codes shown below:

BACKSPACE {BACKSPACE}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER}
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}

To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:

SHIFT +
CTRL ^
ALT ~

To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while E and C are pressed, use "+(EC)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+EC".

Subhash Chandra.


Report •

Related Solutions

#4
January 2, 2011 at 20:59:35
i used it and was able to open "notepad".
question: how can i access edit and then paste fron the open notepad using the batch file/ script?

:-)


Report •

#5
January 3, 2011 at 14:54:57
You can access edit => Paste in 2 ways,
1) Send "Alt + E" and then 10 MS Pause and then send "P".
2) Directly send "CTRL + V".

Both will paste the clipboard text.


TO copy everythihng from existing notepad window, you can send "Ctrl+a" and then "Ctrl+C".

Let me know incase still questions.

Subhash Chandra.


Report •

#6
January 3, 2011 at 17:04:15
Super great. Thank you very much!!

Report •


Ask Question