Jump to content

handle of window


 Share

Recommended Posts

Hi guys..

Please, could someone help me..

Have a window with nonconstant title. Can get handle of this window just one time.

Writed this handle in .ini file for use it when it will be need.

But it not working if I read it from file and not from window directly.

Maybe I can't understand something..

This is example that not working too:

$get_win_han = WinGetHandle ("D:\MM2.txt - Notepad2")
IniWrite (@ScriptDir&"\test.ini", "test", "key", $get_win_han)
$get_temp_win_handle = IniRead (@ScriptDir&"\test.ini", "test", "key", "")
$get_win_pos = WinGetPos ($get_temp_win_handle)
If @error Then Exit
MsgBox (4096, "Info", $get_win_pos[0], 5)
Link to comment
Share on other sites

Hi guys..

Please, could someone help me..

Have a window with nonconstant title. Can get handle of this window just one time.

Writed this handle in .ini file for use it when it will be need.

But it not working if I read it from file and not from window directly.

Maybe I can't understand something..

This is example that not working too:

$get_win_han = WinGetHandle ("D:\MM2.txt - Notepad2")
IniWrite (@ScriptDir&"\test.ini", "test", "key", $get_win_han)
$get_temp_win_handle = IniRead (@ScriptDir&"\test.ini", "test", "key", "")
$get_win_pos = WinGetPos ($get_temp_win_handle)
If @error Then Exit
MsgBox (4096, "Info", $get_win_pos[0], 5)
The handle will be different every time Notepad gets launched, so the value you stored will only work until that instance of Notepad get closed. With that limitation in mind, the handle was saved as a string conversion of an integer value, you just convert the string-int back to a handle with Hwnd():
Run("Notepad.exe")
WinWait("Untitled - Notepad")
$get_win_han = WinGetHandle("Untitled - Notepad")
IniWrite(@ScriptDir & "\test.ini", "Test", "Key", $get_win_han)
$get_temp_win_handle = IniRead(@ScriptDir & "\test.ini", "test", "key", "")
$hNotepad = HWnd($get_temp_win_handle)
$get_win_title = WinGetTitle($hNotepad)
If @error Then
    MsgBox(16, "Error", "Error on WinGetTitle(" & $hNotepad & ")")
Else
    MsgBox(4096, "Title", $get_win_title)
EndIf

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The handle will be different every time Notepad gets launched, so the value you stored will only work until that instance of Notepad get closed. With that limitation in mind, the handle was saved as a string conversion of an integer value, you just convert the string-int back to a handle with Hwnd():

:D

Thank's..

You gave me great idea..

Thank's a lot..

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...