1.

Solve : starting program in dos?

Answer»

Hi guys,

Im using windows XP.

i am really intrested in this. I can obviously start a program in dos with start command. But, when the program starts say for example superscan, i want to be able to execute commands in the program through dos.

for example, superscan has a command that says "lookup" and "scan" ect.. and say, another program like calc on the machine has NUMBERS to press, i was wanting to understand a method to start commands from the actual gui of the program, from inside the dos window.

Another great example is a port scanner. to be able to load it up which ive DONE, then issue a dos command to enter my ip and port and hit scan.

can you help me? Thankyou.I'm a bit confused. By 'dos', do you mean Command Prompt? If so, are you trying to get it to open a program like calc and have it press the numbers for you? because that's not possible.yeah thats what i was hoping for. Or is there some 3rd party program i can use to do this?I don't know of a program that can do this for you but I am sure Command Prompt isn't the way to go.
One thing I do know is you are looking for some type of script or macro. I'm afraid I don't know of any though...

Sit tight and maybe someone will point you in the RIGHT direction.There are a couple of ways to do what you're asking. The first would be to send keystrokes to the application. This example uses the Windows Calc program:

Code: [Select]set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "1{+}"
WScript.Sleep 500
WshShell.SendKeys "2"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "*3"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 2500
Source: Windows Scripting Technologies

The other is to mimic logical MOUSE actions. An example was posted here

Some applications provide their own COM objects which makes scripting the application very easy. In other situations it depends on the specific program and how it behaves in the Windows environment.

Generally if a program presents a window and waits on the user, scripting the GUI may be possible. If a program presents a window and immediately starts doing it's thing, scripting the application probably is not possible.

Good luck.

Ah yes, I forgot about those.

Just save the script Sidewinder posted as .vbs from Notepad.Thankyou for you exellent answers widewinder, you too carbon. That script works perfect. I have a slight problem tho. I want to understand how it works, because when i look at the 1+ 2 command, obviously this is + key, but what is the ~ for?

also, when i try this on say, superscan, i start it fine and now am able to input info in the box, but what would the command be to make a button click CALLED "Me" under the ip address i entered.


EDIT///


Now if i do this..

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "scanner.exe"
WScript.Sleep 100
WshShell.AppActivate "scanner.exe"
WScript.Sleep 100
WshShell.SendKeys "me"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500


How would i be able to not enter any word text, but skip out the buttons and just click the "ME" button, because the above sript hits the lookup button.



please see example below.

http://img120.imageshack.us/img120/7543/test55hm3.jpgThe "~" (tilde) is the enter key. A full list of the key strokes is here

Quote

also, when i try this on say, superscan, i start it fine and now am able to input info in the box, but what would the command be to make a button click called "Me" under the ip address i entered.

Using only the keyboard, what actions do you have to take to give the "Me" button focus? It is these actions you need to script. Once the "Me" button has focus, sending the enter key will produce the button click.



Note: If your application is updated, your script may break. Just something to be aware of.

PS. I've always called the tilde a squiggle, but you won't find that in any reference.

Nice site, Sidewinder.

Mobzy, I think you will want to try the following right now:

WshShell.SendKeys "~" or WshShell.SendKeys "ENTER"
and
WshShell.SendKeys "TAB"

Just imagine you don't have a mouse and you have to use your keyboard but record all the keystrokes you make and turn it into a script.Thanks for your answer and trying to help me.

ive added:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "scanner.exe"
WScript.Sleep 100
WshShell.AppActivate "scanner"
WScript.Sleep 100
WshShell.SendKeys "Me"
WScript.Sleep 100
WshShell.SendKeys "~"
WScript.Sleep 100
WshShell.SendKeys "TAB"
WScript.Sleep 2500


and


set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "scanner.exe"
WScript.Sleep 100
WshShell.AppActivate "scanner"
WScript.Sleep 100
WshShell.SendKeys "Me"
WshShell.SendKeys "TAB"
WScript.Sleep 100
WshShell.SendKeys "~"
WScript.Sleep 100


and still the same thing. you say imagine i have no mouse, but when i try and press keys to see what buttons activate i just hear error sounds. Am i doing it right?

thanks again .SOMETHING great happened thanks to you sir. ill post more in a bit. i thankyou so much!!!!you way works perfect and i understand about the imagine no mouse thing

i was curious, say i wanted to enter an ip into the box normally id use WshShell.SendKeys "192.168.0.1"
WScript.Sleep 100

how .. now this i think is confusing, would i be able to have a small dialog popup, and user enter an IP into that, and click ok, and it echos the info back into the superscan.

hah, hard 1 ay?Glad you got it working.

Quote
how .. now this i think is confusing, would i be able to have a small dialog popup, and user enter an IP into that, and click ok, and it echos the info back into the superscan.

Why the confusion? Typing into a small dialog popup is no different from typing into the scanner GUI.

Quote
hah, hard 1 ay?

Not nearly as difficult as you might imagine. Check out this site for some ideas.

thanks for advice above mate, ill check it out in a bit.

I need some help guys.

if used TAB to cycle through menus, and also ctrl+tab..
i found more menus, n cant seem to get anywhere, no commands seem to work to cycle through. any idears?

maybe they arnt true gui buttons, but they link to say, start scan and they scan. ( not superscan ). Ive hiy a brick wall!:(

any ideas? id really appreciated it!!!

The plot thickens. With Windows objects, this can be accomplished by first writing a script to display all the verb names for an object and their values. With this information, you can work backwards to script the GUI. This was demonstrated in the second example.

If your application supplied a COM object, you may have to research either the registry or an object browser for the program id and go from there.

The sendkeys method has codes for almost every key or key combination except PRNTSCRN. You'll have to manually go through the key sequences needed to accomplish your task and then script every single keystroke. This can be a bit tedious so check out if your application has command line parameters where you can accomplish your task from the command prompt.

If you give us more info on the superscan program, exact name and version, perhaps one the the members will have some experience with this specific software.

Good luck.


Discussion

No Comment Found