Core Function WinGetHandle
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> WinGetHandle ( <title>, <text> ) </pre> === Description === Retrieves the internal handle of a window. === Parameters === ==== Title ==== The title of the window. ==...") |
(→Example) |
||
Line 38: | Line 38: | ||
Opt("WinTitleMatchMode", 4); | Opt("WinTitleMatchMode", 4); | ||
// Get the handle of a notepad window that contains "this one" | // Get the handle of a notepad window that contains "this one" | ||
− | $handle = WinGetHandle(" | + | $handle = WinGetHandle("[class=Notepad]", "this one"); |
If ( $handle ) | If ( $handle ) | ||
{ | { |
Revision as of 18:25, 19 August 2013
WinGetHandle ( <title>, <text> )
Contents |
Description
Retrieves the internal handle of a window.
Parameters
Title
The title of the window.
Text
Optional; The text of the window to read.
Return Value
Success: Returns a string containing the window handle value.
Failure: Returns "" (blank string).
Remarks
This function is for use with the advanced WinTitleMatchMode options that allow you to use classnames and handles to specify windows rather than "title" and "text".
Once you have obtained the handle you can access the required window even if its title changes.
See "WinTitleMatchMode" in Opt
Example
// Identify the Notepad window that contains the text "this one" and get a handle to it // Change into the WinTitleMatchMode that supports classnames and handles Opt("WinTitleMatchMode", 4); // Get the handle of a notepad window that contains "this one" $handle = WinGetHandle("[class=Notepad]", "this one"); If ( $handle ) { // Send some text directly to this window's edit control ControlSend($handle, "", "Edit1", "AbCdE"); } Else { MsgBox("Could not find the correct window"); }