Jump to content

Window on top not the active window...


TJ123
 Share

Recommended Posts

I have used AutoIt quite a bit with lots of success. Today I encountered an issue I have not seen before.

I am working with a program that has several windows open at the same time.

The program will automatically cause one of the windows to come into focus, so it will be the upper most window.

However it seems to take a very long time (if ever) for this to be recognized as the active window by AutoIt, despite the fact that the window appears to be "on top" of the other windows, and accepts input from the keyboard right away.

Clicking on the window causes it to become the active window almost instantly. (I wrote a script to test this) Having the script click on the window is not practical because the postion of the window(s) changes.

The AutoIt Window Info tool defines the class of this window as "QWidget". I have not seen this before.

Does anyone know how I can get AutoIt to recognize the uppermost window as the active window right away? In the past AutoIt has always seemed to automatically recognize the window on top as the active window. I am not sure why it doesn't work with this particular software.

Any suggestions or advice on how to get AutoIt to recognize the window on top as the active window right away would be greatly appreciated.

Thanks for any ideas.

TJ.

Link to comment
Share on other sites

Hi MKISH,

Thank you for your reply. It is greatly appreciated.

The info you provided might help. The problem I face is that there are multiple QWidget windows running and I want to "Activate" the one which the software has brought to focus and appears on top of all other windows.

Unfortunately AutoIt does not seem to recognize this as the active window until I click on it. Even though the window appears on top, the last window I worked with remains as the "Active" window until I click on the new window which the 3rd party program has moved to the top.

I was trying to use this bit of code to see if WinGetTitle would return the name of the window on top, but it keeps returning the name of the previous window I used which is no longer on top. I just added the message box for diagnostic purposes, so I could quickly see which window WinGetTitle was returning.

$active1 = WinGetTitle("", "")
   WinActivate( $active1, "")
   MsgBox ( 4096, "test", $active1 )

I notice that with other window classes AutoIt seems to recognize the top window as Active as soon as it is moved to the top. I am wondering why it does not work this way for QWidget windows. I was thinking if I knew why it is not recognizing the window on top as active it might help me figure out a solution.

Thanks again for your suggestion. If anyone has any ideas about how to make this work I really appreciate any ideas you can provide.

TJ.

Link to comment
Share on other sites

I tried this script for VLC player:

WinActivate('[CLASS:QWidget; TITLE:VLC media player]')

VLC player has class QWidget, so if it works on VLC, it can work for you. Just change the title as per your requirement. ;)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Hi MKISH,

Thanks again for your help. I tried the code you last posted and it does work on QWidget windows like VLC.

My problem is I have several QWidget windows with different titles. I do not know which one the software will place on top next, so I cannot use the window title because I don't know which QWidget window will come up next.

I need a way to make AutoIt recognize the QWidget window that appears on top as the "Active" window. If I could get the window title with WinGetTitle or similar, then I could have the script activate the uppermost window.

I am not sure why AutoIt seems to have difficulty recognizing the top QWidget window as active, this has always worked automatically with other window types.

Thanks again for your replies, they are truly appreciated.

TJ

Edited by TJ123
Link to comment
Share on other sites

Hi MKISH,

Thanks again for your reply. The problem I am having with WinGetTitle("[active]") is that AutoIt considers the last window used to be the "Active" window, not the window that is currently on top.

I wrote a diagnostic script to test this. It uses WinGetTitle to get the title of the active window and then shows you the title in a MsgBox. I have a hotkey that runs the script. After the 3rd party program brings a new window to the front I press the hotkey and see in the MsgBox that AutoIt still thinks the last window I used is the active one, not the window currently on top.

It is strange to me because with other window types AutoIt seems to automatically recognize the window on top as the active window. For these QWidget windows AutoIt seems to have trouble recognizing that a new window has been brought into focus and is now on top.

Although I have still not solved this issue I want to thank you for your time and efforts in assisting me. When I get the time I intend to try and answer some noob questions here (the only kind I am likely to have the answers for) and try to help someone else the way you have helped me.

TJ.

Link to comment
Share on other sites

:mellow: Strange, I did the same for VLC Player and it works for me... Perhaps, could someone put some light :idea: on this issue?

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

This should get the topmost QWidget window

#include <WinAPI.au3>
#include <Constants.au3>
$hWnd = WinActivate('[CLASS:QWidget]')
$hWndTopmost = _WinAPI_GetWindow($hWnd, $GW_HWNDFIRST)
WinActivate($hWndTopmost)
$hWnd =WinWaitActive($hWndTopmost,10)
MsgBox(0,"Top Window",WinGetTitle($hWnd))

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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