herman Posted January 8, 2009 Share Posted January 8, 2009 sorry , my english is very poor I need use Autoit3 to control multi cmd.exe windows. but I can't switch windows between two cmd.exe with same title. How can I do ??? help me. Link to comment Share on other sites More sharing options...
qazwsx Posted January 8, 2009 Share Posted January 8, 2009 process ids or window handles or text on the windows? Link to comment Share on other sites More sharing options...
herman Posted January 8, 2009 Author Share Posted January 8, 2009 thanks . windows Infos between two cmd.exe with same title are same. only defferent is Handle. but the Handle will change when start a new cmd.exe. I need know how to find and control each cmd.exe when I start a new cmd.exe. Link to comment Share on other sites More sharing options...
martin Posted January 8, 2009 Share Posted January 8, 2009 thanks . windows Infos between two cmd.exe with same title are same. only defferent is Handle.but the Handle will change when start a new cmd.exe.I need know how to find and control each cmd.exe when I start a new cmd.exe.If you use Run it returns the PID. I would use that to identify the window. 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. Link to comment Share on other sites More sharing options...
ResNullius Posted January 8, 2009 Share Posted January 8, 2009 sorry , my english is very poor I need use Autoit3 to control multi cmd.exe windows. but I can't switch windows between two cmd.exe with same title. How can I do ??? help me.If you want to use different Window titles, you could try this trick using the "start" command: $cmd1 = _RunTitledComspec("cmd1") $DirList = _RunTitledComspec("DirList", "Dir C:\*.*") WinActivate("cmd1") Sleep(300) WinActivate("DirList") Sleep(300) WinActivate("cmd1") Sleep(300) WinMove("DirList","",0,0) Winmove("cmd1","",200,200) MsgBox(4096, "", "cmd1's pid: " & $cmd1 & @crlf & "DirList's pid: " & $DirList) WinClose("DirList") WinClose("cmd1") Func _RunTitledComspec($sWinTitle, $sCmdToRun = "") ; $sWinName : Title for console window ;$sCmdToRun : Optional command line command to execute in new console ; return: PID of console process on success creation of console window, ; -1 if can't create window, no other error checking/returns (yet!) If $sCmdToRun = "" Then $pid = Run(@ComSpec & ' /c Start "' & $sWinTitle & '"' & @ComSpec, "", @SW_HIDE) Else $pid = Run(@ComSpec & ' /c Start "' & $sWinTitle & '" ' & @ComSpec & ' /k "' & $sCmdToRun & '"', "", @SW_HIDE) EndIf WinWait($sWinTitle, "", 5) $pid = WinGetProcess($sWinTitle) Return $pid EndFunc Link to comment Share on other sites More sharing options...
martin Posted January 8, 2009 Share Posted January 8, 2009 If you want to use different Window titles, you could try this trick using the "start" command: $cmd1 = _RunTitledComspec("cmd1") $DirList = _RunTitledComspec("DirList", "Dir C:\*.*") WinActivate("cmd1") Sleep(300) WinActivate("DirList") Sleep(300) WinActivate("cmd1") Sleep(300) WinMove("DirList","",0,0) Winmove("cmd1","",200,200) MsgBox(4096, "", "cmd1's pid: " & $cmd1 & @crlf & "DirList's pid: " & $DirList) WinClose("DirList") WinClose("cmd1") Func _RunTitledComspec($sWinTitle, $sCmdToRun = "") ; $sWinName : Title for console window ;$sCmdToRun : Optional command line command to execute in new console ; return: PID of console process on success creation of console window, ; -1 if can't create window, no other error checking/returns (yet!) If $sCmdToRun = "" Then $pid = Run(@ComSpec & ' /c Start "' & $sWinTitle & '"' & @ComSpec, "", @SW_HIDE) Else $pid = Run(@ComSpec & ' /c Start "' & $sWinTitle & '" ' & @ComSpec & ' /k "' & $sCmdToRun & '"', "", @SW_HIDE) EndIf WinWait($sWinTitle, "", 5) $pid = WinGetProcess($sWinTitle) Return $pid EndFunc Thanks ResNullius, I didn't know about that. I thought that the window always changed back to "cmd.exe" or similar when you entered a new command and I have been setting the title back to what I wanted it to be. Now it's much easier and better. 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. Link to comment Share on other sites More sharing options...
ProgAndy Posted January 8, 2009 Share Posted January 8, 2009 you acn send the command "title Newtitle" too Run(@ComSpec & " /k title " & $title & " | " & $Command) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
martin Posted January 8, 2009 Share Posted January 8, 2009 you acn send the command "title Newtitle" too Run(@ComSpec & " /k title " & $title & " | " & $Command)Thanks ProgAndy it works! That's another command I had ignored for the last 20 plus years. At least it shows you can teach an old dog new tricks. 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. Link to comment Share on other sites More sharing options...
TinyBoy Posted January 8, 2009 Share Posted January 8, 2009 you acn send the command "title Newtitle" too Run(@ComSpec & " /k title " & $title & " | " & $Command)Ok, this works, but the correct syntax would be: $title = "Title 1" $Command="help cmd" Run(@ComSpec & " /k title " & $title & " && " & $Command) The vertical bar "|" is the pipe operator and the "&&" is the command chaining operator. Since the title command has no output, there is no harm. And Martin, it was a pleasure to teach an old dog new tricks Tinyboy Link to comment Share on other sites More sharing options...
ResNullius Posted January 9, 2009 Share Posted January 9, 2009 you acn send the command "title Newtitle" too Run(@ComSpec & " /k title " & $title & " | " & $Command)The things you forget you knew! At least I think I forgot that once... thanks for the reminder ProgAndy. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now