Sign in to follow this  
Followers 0
Diana (Cda)

WinSetOnTop not working.

10 posts in this topic

I've tried several times in last couple of months and this is third attempt. WinSetOnTop not working.

Here is my script as it stands. It's messy. I've tried putting WinActivate (which a post in this forum said might be useful to add) and WinSetOnTop in different spots before and after the app launch command. App launches just fine but window state not affected at all. Need it to always remain in the foreground. The code is messy, but it was a last ditch attempt. I put the 2 lines of code initially before the app launch line and then after. Nothing. So in desperation, put all of these codes before _and_ then after <lol>. Nothing. So know that it might need paring down:

******************************

;

; AutoIt v3.0

;

WinActivate("Open Thousands of Apps - Drag - Drop - Click", "")

WinSetOnTop("Open Thousands of Apps - Drag - Drop - Click", "", 1)

WinActivate("Open Thousands of Apps - Drag - Drop - Click", "")

Run("D:\AGENTF~1\000-LA~1\OPENTAPP.EXE")

WinActivate("Open Thousands of Apps - Drag - Drop - Click", "")

WinSetOnTop("Open Thousands of Apps - Drag - Drop - Click", "", 1)

WinActivate("Open Thousands of Apps - Drag - Drop - Click", "")

Exit

; finished

******************************

Thanks in advance for any help. ;)

Share this post


Link to post
Share on other sites



Darn, forgot to mention. I got the window title with Window Spy so know it's correct and that error in script doesn't come from bad window name. Tx!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I hope you meant "AU3Info.exe" for Window Spy... could you show us (post) the actual copy of the information screen??

also... based on what you have said

Remarks

Third-party programs which add an "Always On Top" context menu entry might not update their menu entry to reflect the AutoIt-induced change in TOPMOST status.

is from help

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I have no idea what you meant there by the third part app.

Anyway, after installing AutoIt v3 there is a utility labelled, exactly, "AutoIt Window Spy". I use that whenever I need a window title and I've been using this for quite a while. Actually, the window titles always end up being what we see as a title on any particular window so it isn't totally necessary to use, but I use it anyway to make sure I've got the exact title. i.e., I use Window Spy whenever I need to add a WinWait. As you know, if there is an error in the syntax anywhere in a script, that script won't work at all no matter where the error is. I get no such error for this script. The app launches. It's just that it doesn't stay forced on top which it must do. So out of the entire launching script, only the part that forces on "on top" doesn't work.

I don't know what you mean by any third party apps re launching, or whatever. Have no idea as to their relevance to this issue at all. I'm trying to launch a program, that's it. I need it to stay on top, that's all.

Thanks much! :oD

Share this post


Link to post
Share on other sites

Hi Diana,

The idea of what Valuater posted is basically this: if you get AutoIt to designate a window as 'on-top', and that window has its own way of displaying whether the window is being displayed as on-top, then what the window says may not be in sync with the actual on-top-ness of the window after AutoIt has had its way with the window.

It's a handy thing to know if e.g. you're testing that a window's on-top by looking at the window's readout instead of e.g. trying to cover the window with another one. Anyway, based on your original code I would suggest trying this:

Local $Title = "Open Thousands of Apps - Drag - Drop - Click"
Run("D:\AGENTF~1\000-LA~1\OPENTAPP.EXE")
WinWait($Title)
WinSetOnTop($Title, "", 1)

I moved the window title into a variable since it is used multiple times, and I instruct AutoIt to wait for the window to exist before trying to set its on-top attribute.

Share this post


Link to post
Share on other sites

The "Topmost" flag will keep the app visible above other "normal" windows, but other windows can still take focus.

If I understand your request correctly, you want the app to always have focus.

How does this work for you?

Local $Title = "Open Thousands of Apps - Drag - Drop - Click"
Run("D:\AGENTF~1\000-LA~1\OPENTAPP.EXE")
WinWait($Title)
WinSetOnTop($Title, "", 1)
  While WinExists($Title) 
    Sleep(500)
    WinActivate($Title)
  Wend

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

That's an interesting possibility. Here's another way of doing this:

Local $Title = "Open Thousands of Apps - Drag - Drop - Click"
Run("D:\AGENTF~1\000-LA~1\OPENTAPP.EXE")
WinWait($Title)
WinSetOnTop($Title, "", 1)

Opt("WinWaitDelay", 0)
While WinExists($Title)
    WinActivate($Title)
    WinWaitNotActive($Title)
WEnd

It essentially offers the same functionality as Skruge's code, but instead returns focus back to the window immediately instead of waiting up to half a second. A Sleep() isn't required here because the WinWaitNotActive() blocks execution until the window is made inactive.

Share this post


Link to post
Share on other sites

Excellent work, Alex.

Diana, do you still need help with this?


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Excellent work, Alex.

Diana, do you still need help with this?

Alex, thank you so much! Your code seems to work perfectly! I didn't try yours yet, Skruge, but I will just to see if it does the trick.

This will be a great thing to have. I've needed an app that allows me to choose what to launch. Up till now I've been using a batch file written esp. for me but it's a pain in the neck to edit. Also, I have to press letters on keyboard to launch items rather than clicking with the mouse. It's just way too cumbersome. A couple of freeware apps, one called "Open Thousands of Apps" allow me to just drag 'n drop EXEs and even link files (i.e., shortcuts) into the interface and I can pick and choose what to launch. The only trouble is that it doesn't have a built-in "on top" command so after each item is launched I have to hunt for the app again amongst all the stuff on my taskbar in order to launch the next item. With your code above, Alex, it stays on top and I can continue launching as needed.

Why would one need this? I use Forté Agent to read newsgroup mail, for example. I have separate instances created of the app that are handled through each shortcut. I have needed to launch different instances at any given time according to what groups I've recently posted messages to and this app now allows me to do this much more easily than the batch file.

Also, another use for this 1000's of apps is for my backup system. I always need to launch my backup app, but not always the same folders related to where the backups are going to as I need to date the backups aftewards or to access them to drag to my CD burner app. I'll now be able to do so easily with a copy of the 1000's of app and the AI code above just changing the path to the EXE. Awesome!

I must admit that my goal is to one day write an AI launching app with a GUI that will do what I need all by itself, but that's some time off. I'm only at the rudimentary stage of developing in regular AI right now!

Thanks so much! Cheers. :oD

Share this post


Link to post
Share on other sites

Local $Title = "Open Thousands of Apps - Drag - Drop - Click"
Run("D:\AGENTF~1\000-LA~1\OPENTAPP.EXE")
WinWait($Title)
WinSetOnTop($Title, "", 1)

Opt("WinWaitDelay", 0)
While WinExists($Title)
    WinActivate($Title)
    WinWaitNotActive($Title)
WEnd

LxP, this worked like a charm. I thought I'd get back to the group with feedback. This does the trick. Nothing else can be opened, however, just a word of caution. This makes the OPENTAPP.EXE topmost over everything, but that is perfectly fine. Once I launch whatever is needed with this app, it gets closed anyway and makes all other processes available.

I've had several days to work with the app with this code and am so pleased with it. It's made my life easier. There is no app that is a "multiple choice launcher". "Open Thousands of Apps" comes close. You drag-'n-drop shortcuts, and/or paths of whatever else you want and you can launch them from this app. But it was a pain when it didn't stay on top. With the above AI code in concert with this freeware launcher, it's perfect!

I have several instances of this combination now. Just changed the path to the exe involved and that's it!

Thanks.

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  
Followers 0