Jump to content

WinGetHandle / WinGetTitle


atomman
 Share

Recommended Posts

NEVER MIND

everyone's allowed one dumb-ass question a day :/

Easy, easy... :D

MsgBox(0, "", WinGetTitle(""))

This code return title of current active window. So if you get MsgId from created GUI, what returned WinGetTitle("")? Title of current active window.

:P

Edited by rasim
Link to comment
Share on other sites

why do these only work for AutoIt GUI's?

Case $GUI_EVENT_PRIMARYDOWN

MsgBox(0, "", WinGetTitle(""))

or...

Case $GUI_EVENT_PRIMARYDOWN

MsgBox(0, "", WinGetHandle(""))

In case you haven't discovered, I think what you want is

#include <misc.au3>
while 1

if _IsPressed("1") then MsgBox(0,'current window = ', WinGetTitle(""))
 
Switch GuiGetMsg()
 case ...
.
.
 EndSwitch  
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@martin -- yeah, that's what i want, but my problem is that i have one AU3 GUI which is always on top, so that's the only one i'm getting titles/handles for.

i need to ignore all the GUI's created in the script and get the title/handle of the one clicked on.

Link to comment
Share on other sites

Then doing something like this should work:

If _IsPressed("1") Then $Handle = WinGetHandle("")
Yes, as post #5.

Maybe

If _IsPressed("1") Then 
 if Not( WinActive($gui1) Or Winactive($Gui2) Or WinActive($Gui3)) then  $Handle = WinGetHandle("")
endif
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

ah! sorry guys!

i meant i need to get the handle of the non-AU3 window even if the AU3 window is topmost. i stated that in a post earlier, but i didn't carry it over to my last post. sorry.

@martin - using your code works fine, but it only returns info from the topmost AU3 window (unless i'm doing something way wrong, because i haven't tested any of this thoroughly yet -- i'm involved in another struggle at the moment :D

Link to comment
Share on other sites

ah! sorry guys!

i meant i need to get the handle of the non-AU3 window even if the AU3 window is topmost. i stated that in a post earlier, but i didn't carry it over to my last post. sorry.

@martin - using your code works fine, but it only returns info from the topmost AU3 window (unless i'm doing something way wrong, because i haven't tested any of this thoroughly yet -- i'm involved in another struggle at the moment :D

I think I see. Try this example

#include <constants.au3>
#include <misc.au3>

$g1 = GUICreate("top",400,400,0,0,-1,$WS_EX_TOPMOST)
GUISetState()

while 1
    
if _IsPressed("1") Then
    $a = WinGetTitle("")
    if $a <> "top" then MsgBox(0,'active window is',$a)
EndIf

 If GUIGetMsg() = -3 then exit
WEnd

For the case where you have 3 AutoIt guis you will need to say something like

if $a <> $Title1 And $a <> $Title2 and $a <> $Title3 then $LastActive = $a

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...