Daydreamer067 Posted May 12, 2022 Posted May 12, 2022 Hello I have a number of command windows opened by Run("C:\Windows\System32\cmd.exe") I want to activate each window one after another. I can't use winactivate since they have the same title/name. How do I do it ? Thank you for your responses
argumentum Posted May 12, 2022 Posted May 12, 2022 you could https://www.google.com/search?q=set+cmd+title+name or with pics https://www.addictivetips.com/windows-tips/how-to-change-name-in-the-title-bar-of-command-prompt/ ...like and subscribe Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
rudi Posted May 16, 2022 Posted May 16, 2022 With this code https://www.autoitscript.com/forum/topic/19370-autoit-wrappers/?do=findComment&comment=417610 by @Valuater you can address your command boxes by preserving the PIDs, when launching them: expandcollapse popup#include <MsgBoxConstants.au3> Dim $aPIDs[4]=[3] for $i = 1 to $aPIDs[0] $aPIDs[$i]=Run("C:\Windows\System32\cmd.exe") Next for $i = 1 to $aPIDs[0] $hWin=_WinGetHandleByPID($aPIDs[$i],-1) WinActivate($hWin) MsgBox($MB_TOPMOST, '', "Activated #" & $i & " with PID " & $aPIDs[$i]) Next Func _WinGetHandleByPID($vProc, $nVisible = 1) $vProc = ProcessExists($vProc); If Not $vProc Then Return SetError(1, 0, 0) Local $aWL = WinList() Local $aTemp[UBound($aWL)][2], $nAdd = 0 For $iCC = 1 To $aWL[0][0] If $nVisible = -1 And WinGetProcess($aWL[$iCC][1]) = $vProc Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible = 0 And WinGetProcess($aWL[$iCC][1]) = $vProc And _ BitAND(WinGetState($aWL[$iCC][1]), 2) = 0 Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible > 0 And WinGetProcess($aWL[$iCC][1]) = $vProc And _ BitAND(WinGetState($aWL[$iCC][1]), 2) Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] EndIf Next If $nAdd = 0 Then Return SetError(2, 0, 0);No windows found ReDim $aTemp[$nAdd + 1][2] $aTemp[0][0] = $nAdd Return $aTemp EndFunc Earthshine 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE!
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