0000 Posted December 12, 2007 Share Posted December 12, 2007 Can I get a Window name, then I know PID ? If Yes, how? Link to comment Share on other sites More sharing options...
weaponx Posted December 12, 2007 Share Posted December 12, 2007 WinGetProcess ( "title" [, "text"] ) Link to comment Share on other sites More sharing options...
0000 Posted December 12, 2007 Author Share Posted December 12, 2007 Give little example how to use, because for my it's not working with PID Link to comment Share on other sites More sharing options...
weaponx Posted December 12, 2007 Share Posted December 12, 2007 Run("Notepad.exe") $pid = WinGetProcess("Untitled - Notepad") MsgBox(0,"",$pid) Link to comment Share on other sites More sharing options...
0000 Posted December 13, 2007 Author Share Posted December 13, 2007 Hehe... I need smthing like that $pid=1111 $name = "" [some Function] = $pid MsgBox(0,$pid,"Window Name: "&$name) Some Functions will find from the PID window name ? So how about that? Link to comment Share on other sites More sharing options...
Glyph Posted December 13, 2007 Share Posted December 13, 2007 (edited) You want to get the window name of a PID? Edited December 13, 2007 by BackStabbed tolle indicium Link to comment Share on other sites More sharing options...
BrettF Posted December 13, 2007 Share Posted December 13, 2007 See how it was done in this function: Func _SetParentWindowPID($PID, $hGUI) $hWnd = 0 $stPID = DllStructCreate("int") Do $winlist2 = WinList() For $i = 1 To $winlist2[0][0] If $winlist2[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1] ExitLoop EndIf EndIf Next Sleep(100) Until $hWnd <> 0 $stPID = 0 If $hWnd <> 0 Then $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20) $nExStyle = $nExStyle[0] DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOR($nExStyle, $WS_EX_MDICHILD)) DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI) WinSetState($hWnd, "", @SW_SHOW) _WinAPI_RedrawWindow ($hWnd) EndIf GUISetState() EndFunc ;==>_SetParentWindowPID Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
0000 Posted December 13, 2007 Author Share Posted December 13, 2007 You want to get the window name of a PID?Yes...So how about that? Link to comment Share on other sites More sharing options...
weaponx Posted December 13, 2007 Share Posted December 13, 2007 See here for an example:http://www.autoitscript.com/forum/index.ph...=ProcessGetHWndHere is the UDF you will need for the example:http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd.au3 Link to comment Share on other sites More sharing options...
BrettF Posted December 13, 2007 Share Posted December 13, 2007 Wow... It was like what I said was forgottern. Which also indicated the the OP wanted it handed to them on a shiny silver plate... $PID = Run ("Notepad.exe") Sleep (250) $HWND = _GETHwndFromPID ($PID) WinWaitActive ($HWND) WinKill($HWND) MsgBox (0, "", "Window was killed") Func _GetHwndFromPID ($PID) $hWnd = 0 $stPID = DllStructCreate("int") Do $winlist2 = WinList() For $i = 1 To $winlist2[0][0] If $winlist2[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1] ExitLoop EndIf EndIf Next Sleep(100) Until $hWnd <> 0 Return $hWnd EndFunc Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 13, 2007 Moderators Share Posted December 13, 2007 Wow... It was like what I said was forgottern. Which also indicated the the OP wanted it handed to them on a shiny silver plate... $PID = Run ("Notepad.exe") Sleep (250) $HWND = _GETHwndFromPID ($PID) WinWaitActive ($HWND) WinKill($HWND) MsgBox (0, "", "Window was killed") Func _GetHwndFromPID ($PID) $hWnd = 0 $stPID = DllStructCreate("int") Do $winlist2 = WinList() For $i = 1 To $winlist2[0][0] If $winlist2[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1] ExitLoop EndIf EndIf Next Sleep(100) Until $hWnd <> 0 Return $hWnd EndFuncWhat's the point of DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1]?? WinGetProcess() not good enough? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BrettF Posted December 13, 2007 Share Posted December 13, 2007 What's the point of DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1]?? WinGetProcess() not good enough?Nope Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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