Jump to content
Sign in to follow this  
atomman

WinGetHandle / WinGetTitle

Recommended Posts

atomman

why do these only work for AutoIt GUI's?

Case $GUI_EVENT_PRIMARYDOWN

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

or...

Case $GUI_EVENT_PRIMARYDOWN

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

Share this post


Link to post
Share on other sites
atomman

NEVER MIND

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

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
BrettF
martin

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.

Share this post


Link to post
Share on other sites
FreeFry

Gui events only work in your own gui(unless you've hooked into another process by using dll calls n stuff), because autoit only handles gui messages for it's own gui's.

Share this post


Link to post
Share on other sites
atomman

@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.

Share this post


Link to post
Share on other sites
FreeFry

I'm sorry, I didn't quite understand that last part, can you explain what exactly you're trying to do?

Share this post


Link to post
Share on other sites
atomman

i want to WinGetHandle("") (or WinGetTitle("")) of the non-AU3 window which receives a mouse L-click so i have the handle/title to use in further operations.

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
atomman

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

Share this post


Link to post
Share on other sites
FreeFry

Hmm, from what I know, the active window doesn't have to be topmost, so the WinGet* using "" as title parameter or [ACTIVE] (advanced title mode), should work... hmm

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
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
Sign in to follow this  

×