Knight Posted March 15, 2006 Share Posted March 15, 2006 (edited) I must be really having a brain freeze, but I need to get the active window's title. What I am really tring to do is to get the process of the currently active window. I can use WinGetProcess, but I need the active Window's title; and what am I to do if there is 2 of the same title window running but with different process', will it pick the correct one? Any suggestions? Thanks. Edited March 16, 2006 by Knight Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 16, 2006 Share Posted March 16, 2006 I must be really having a brain freeze, but I need to get the active window's title. What I am really tring to do is to get the process of the currently active window. I can use WinGetProcess, but I need the active Window's title; and what am I to do if there is 2 of the same title window running but with different process', will it pick the correct one? Any suggestions? Thanks. Hi, does that help? $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) MsgBox(64, "ProcessId: " , WinGetProcess($var[$i][0])) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 8) Then Return 1 Else Return 0 EndIf EndFunc So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Knight Posted March 16, 2006 Author Share Posted March 16, 2006 I want to get the title of the window that is currently active. Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 16, 2006 Share Posted March 16, 2006 I want to get the title of the window that is currently active. ??? Isn´t that what you want? $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then MsgBox(0, "Title of active Window: ", $var[$i][0]) ;MsgBox(64, "ProcessId: " , WinGetProcess($var[$i][0])) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 8) Then Return 1 Else Return 0 EndIf EndFunc So long, Mega P.S.: Or did I get it totally wrong? Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 16, 2006 Share Posted March 16, 2006 You can better test it if you put a sleep inftont of the func and then switch to a window and wait for the MsgBox. Look at this: $var = WinList() Sleep(5000) For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then MsgBox(0, "Title of active Window: ", $var[$i][0]) ;MsgBox(64, "ProcessId: " , WinGetProcess($var[$i][0])) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 8) Then Return 1 Else Return 0 EndIf EndFunc So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
nfwu Posted March 16, 2006 Share Posted March 16, 2006 A very simple way of geting the title of the currently active window that is most on top: $title = WinGetTitle("") here is the help file: WinGetTitle -------------------------------------------------------------------------------- Retrieves the full title from a window. WinGetTitle ( "title" [, "text"] ) Parameters title The title of the window to read. See Title special definition. text [optional] The text of the window to read. Return Value Success: Returns a string containing the complete window title. Failure: Returns numeric 0 if no title match. Remarks WinGetTitle("") returns the active window's title. WinGetTitle works on both minimized and hidden windows. If multiple windows match the criteria, the most recently active window is used. The help file is the way to go! Steps on solving a probelm 1) Check help file. 2) If still not sure, post it here! #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() 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