Jump to content
Sign in to follow this  
enaiman

Send command to "cmd.exe" window

Recommended Posts

enaiman

I'm trying to set cmd windows properties because I need the window bigger than usual.

I tried (manually) setting the properties of its shortcut first (silly mistake - shortcut properties and file properties are completely different things)

Did a bit of research and found how I can change the console's dimensions (MODE CON: COLS=120 LINES=50)

Run(@ComSpec & " /k MODE CON: COLS=120 LINES=50 ", "", @SW_SHOW)

makes a really nice window just the way I need it ... but ...

The problem now is: how can I send a second command to this window - without using "Send" command?

it works this way but I don't like this solution:

Run(@ComSpec & " /k MODE CON: COLS=120 LINES=50 ", "", @SW_SHOW)
        Sleep(300)
        Send('pathping '&_GUICtrlIpAddress_Get($IPAddress1)&" -q 10"&@CRLF)

Can you help me please to find another one?

Thanks


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
martin

I'm trying to set cmd windows properties because I need the window bigger than usual.

I tried (manually) setting the properties of its shortcut first (silly mistake - shortcut properties and file properties are completely different things)

Did a bit of research and found how I can change the console's dimensions (MODE CON: COLS=120 LINES=50)

Run(@ComSpec & " /k MODE CON: COLS=120 LINES=50 ", "", @SW_SHOW)

makes a really nice window just the way I need it ... but ...

The problem now is: how can I send a second command to this window - without using "Send" command?

it works this way but I don't like this solution:

Run(@ComSpec & " /k MODE CON: COLS=120 LINES=50 ", "", @SW_SHOW)
        Sleep(300)
        Send('pathping '&_GUICtrlIpAddress_Get($IPAddress1)&" -q 10"&@CRLF)

Can you help me please to find another one?

Thanks

You don't say why you don't want to use Send which might have helped, or even why you want to use the command screen. The only thing I can think of is to have the Run statement start a batch file which looks for the existence of a file and when it exists executes the instructions in it. Then your program can write to the file instead of using Send.

;batch file to run
:start
if EXIST STOPWORK.BAT goto end
if Exist DOTHIS.BAT CALL DOTHIS.BAT
DEL DOTHIS.BAT
sleep(2);sleep 2 sec say. Need a little program to do this or search for one
goto start
:end
exit

Then your script can do something like this

$dos = Run("begin.bat"....
While $stufftodo
  while FileExists("dothis.bat")
     sleep(200)
    if Not ProcessExists($dos) then exitloop
  wend
  if Not ProcessExists($dos) then exitloop
  FilewriteLine(dothis.bat",$command)
 ;get next command
wend
FileWrite("STOPWORK.BAT","all done")
while processExists($dos)
  sleep(100)
wend
FileDelete(STOPWORK.BAT")

This is just an idea which I haven't tried!


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Andreik

_RunDOS()


When the words fail... music speaks

Share this post


Link to post
Share on other sites
martin

_RunDOS()
How does that help do what was asked for?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
enaiman

Thank you martin for your help,

I'm not so happy to use "Send" because it sends the string to the active window; the use "might" click elsewhere "exactly" at the wrong moment - happens sometimes - and "Send" might fail because cmd window was not active at the moment.

The idea of running a batch file is brilliant and I will start working on it.

The reason why I do want to use command screen: I'm running a pathping and in the default console format the first entry is truncated - it's not looking good at all - so I've been tinking to resize the console so the first line will fit.

I know I can get the text and work on it and show the result in a messagebox, why I don't do it this way? because it needs some time to have it ready and the time is kinda short right now. But maybe I will do it that way - not sure though.

Thanks again for help,


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
martin

Thank you martin for your help,

I'm not so happy to use "Send" because it sends the string to the active window; the use "might" click elsewhere "exactly" at the wrong moment - happens sometimes - and "Send" might fail because cmd window was not active at the moment.

The idea of running a batch file is brilliant and I will start working on it.

The reason why I do want to use command screen: I'm running a pathping and in the default console format the first entry is truncated - it's not looking good at all - so I've been tinking to resize the console so the first line will fit.

I know I can get the text and work on it and show the result in a messagebox, why I don't do it this way? because it needs some time to have it ready and the time is kinda short right now. But maybe I will do it that way - not sure though.

Thanks again for help,

I understand your problem with Send because I had exactly the same concern. But recently a function was pointed out to me that I didn't know about which was SendKeepActive(""); it works really well. I also used BlockInput(1) and BlockInput(0) around some sections to make sure no-one messed things up. Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
enaiman

I understand your problem with Send because I had exactly the same concern. But recently a function was pointed out to me that I didn't know about which was SendKeepActive(""); it works really well. I also used BlockInput(1) and BlockInput(0) around some sections to make sure no-one messed things up.

Great advice muttley

SendKeepActive might do the trick.

Thanks again,


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.