nobbe Posted May 20, 2008 Share Posted May 20, 2008 (edited) hi how can i retrieve / change the window title, when i have only the process id of the started process? here is my sample code what i tried - processlist() only shows "exe" path name (e.g. "calc.exe" , not windows title "calculator"?? i would like to change the windows title like ; WinSetTitle($process_name[$irun], "", "test") thanks.. $process_id[$irun] = Run($process_path[$irun] & " " & $process_parameters[$irun], $process_path_execute[$irun]) If @error <> 1 Then ; no error ?? _get_process_real_name($process_id[$irun]); ; ; how to get "name " of process? ; func _get_process_real_name($process) ; List all processes local $list = ProcessList() local $i for $i = 1 to $list[0][0] if $list[$i][1] == $process then msgbox(0, $list[$i][0], $list[$i][1]) ; show only "exe" path name , not windows title?? endif next Edited May 20, 2008 by nobbe Link to comment Share on other sites More sharing options...
weaponx Posted May 20, 2008 Share Posted May 20, 2008 You need to get the process's window's:#497937 Link to comment Share on other sites More sharing options...
Monamo Posted May 20, 2008 Share Posted May 20, 2008 (edited) Here's a quick method (basically modified from a recent example of matching a window handle to a PID): CODE $hWnd = "" $iPID = ProcessExists("calc.exe") $aWinList = WinList() For $i = 1 To $aWinList[0][0] If WinGetProcess($aWinList[$i][0]) = $iPID Then $hWnd = $aWinList[$i][1] ExitLoop EndIf Next If $hWnd <> "" Then WinSetTitle($hWnd,"","Calculator of Doom") Else MsgBox(64,"Not Found", "No matching process found.") EndIf and if you happen to already have the PID from some previous portion of code in your script, you can just swap out the ProcessExists() assignment for $iPID Edited May 20, 2008 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
nobbe Posted May 20, 2008 Author Share Posted May 20, 2008 ok thanks alot the "trick" was to add a "sleep" or the winlist() call ist too slow and doesnt include the currently started window! $process_id[$irun] = Run($process_path[$irun] & " " & $process_parameters[$irun], $process_path_execute[$irun]) If @error <> 1 Then ; no error ?? ; get process_real_name $name = _get_process_real_name($process_id[$irun]); WinSetTitle($name, "", $process_name[$irun]) ; ; retrieves process "window title" by given process ID ; Func _get_process_real_name($PId) ; needs to sleep or process name is not returnd !! Sleep(300) ; !!! sleep !! or process is NOT in the list yet !! Local $WinList = WinList() For $i = 1 To $WinList[0][0] If WinGetProcess($WinList[$i][1], "") = $PId And $WinList[$i][0] <> "" Then ; msgbox(0, $WinList[$i][0], $WinList[$i][1]) Return $WinList[$i][0]; --> name of title EndIf Next EndFunc ;==>_get_process_real_name 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