Frank_O Posted January 25, 2008 Share Posted January 25, 2008 Hi all, I want to run a dos-script (with an endless lopp) and make it visible or hide it from time to time. I don't want to use the window-title, because it's the same as @comspec and there could exist more than 1 process with that name ... Can't I use the PID? Or is there a way to get the WinHandle of that PID? thanks in advance frank CODE#comments-start rem loop.cmd @echo off if not exist sleep.exe goto end :loop echo %time% sleep 1 goto loop :end #comments-end $pid = Run(@ComSpec & " /c " & 'loop.cmd') ; , "", @SW_HIDE $rc = ProcessWait( $pid, 5 ) If $rc = 1 Then MsgBox( 0, "Info", "loop.cmd was stated. PID=" & $pid, 5 ) Else MsgBox( 0, "Info", "loop.cmd could not be started") Exit EndIf sleep( 5000 ) WinSetState( $pid, "", @SW_HIDE ) msgbox( 0, "Info", "Window is hiden" ) sleep( 5000 ) WinSetState( $pid, "", @SW_SHOW ) msgbox( 0, "Info", "Window is shown again" ) Link to comment Share on other sites More sharing options...
Developers Jos Posted January 25, 2008 Developers Share Posted January 25, 2008 added some code to retrieve the Window Handle that belongs to the ran PID which enables you to use that in stead of the title: expandcollapse popup#comments-start rem loop.cmd @echo off if not exist sleep.exe goto end :loop echo %time% sleep 1 goto loop :end #comments-end $pid = Run(@ComSpec & ' /k Dir *.*') ; , "", @SW_HIDE $rc = ProcessWait($pid, 5) ; get window handle $wintitle = "" $WinHnd = 0 $list = WinList() for $i = 1 to $list[0][0] If $list[$i][0] = "" Then ContinueLoop If WinGetProcess($list[$i][0]) = $pid Then $winTitle = $list[$i][0] $WinHnd = $list[$i][1] ExitLoop EndIf next ; If $rc = 1 Then MsgBox(0, "Info", "loop.cmd was stated. PID=" & $pid, 5) Else MsgBox(0, "Info", "loop.cmd could not be started") Exit EndIf Sleep(5000) WinSetState($WinHnd, "", @SW_HIDE) MsgBox(0, "Info", "Window is hiden") Sleep(5000) WinSetState($WinHnd, "", @SW_SHOW) MsgBox(0, "Info", "Window is shown again") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Frank_O Posted January 25, 2008 Author Share Posted January 25, 2008 Hi Jos, thank you, now it's clear Just combining winlist with wingetprocess ... frank 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