Jump to content

Always On Top Opendialog Window.


Recommended Posts

I have a script that ask the user to select one or more files.

The file open dialogue is summoned by a hotkey and so far so good.

Unluckly the windows often appear UNDER other opened windos, so it is unvisible. it is a problem since every user thinks that do not pressed well the key and press again.

I tried WinActivate the Program Manager in order to remove the focus to the other windows, but this solved the problem only in part because the window appear topmost but also deactivated so it is still needed a ALT+TAB or a mouse click.

Since the FileOpenDialog is a function that stops autoit I really do not know what to do... Any advice?

Link to comment
Share on other sites

Try this code-sample :

If $CmdLine[0] = 1 AND $CmdLine[1] = "move"  Then
Sleep(10)
WinWaitActive("FileOpen Dialog")
WinMove ("FileOpen Dialog", "", 100, 100)
Exit
Else
;Continue..
EndIf

Run("MyScript.exe " & "move")
FileOpenDialog ("FileOpen Dialog", "c:\", "All (*.*)", 1)
;Continue your script..

(EDIT : Should work..)

Untested though.. :whistle:

Edited by Helge
Link to comment
Share on other sites

If you don't mind a brief flash, do something as follows:

Opt("WinWaitDelay", 1)
WinActivate(AutoItWinGetTitle())
WinSetState(AutoItWinGetTitle(), "", @SW_HIDE)
FileOpenDialog()

Something like that will always bring the FileOpenDialog window out on top. AutoIt's hidden window will flash briefly, though...

Link to comment
Share on other sites

This is an interesting issue.

WinGetState returns 21 which means that the AutoIt window is enabled/exists/minimized but is inactive and hidden. If you set its state to @SW_RESTORE it loses its hidden status. Because the window is minimized, WinMove will not let you move the window out of the way before it flashes on screen.... Here are some other discoveries:

Window is on top but deactivated (lacks focus)

WinSetOnTop ( AutoItWinGetTitle(), "", 1 )
FileOpenDialog("foo", "", "All (*.*)", 1 + 4 )
WinSetOnTop ( AutoItWinGetTitle(), "", 0 )

Window is on top and active

MsgBox(4096,"","Wait 1 second",1)
FileOpenDialog("foo", "", "All (*.*)", 1 + 4 )

Valik's way works best, but I'd consider removing the @SW_HIDE line:

WinActivate(AutoItWinGetTitle())
FileOpenDialog("foo", "", "All (*.*)", 1 + 4 )

Edit: I mean that Valik has the best one-script solution. Helge's secondary-script idea is generally the best accepted workaround.

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

B):whistle:

Here we are the best solution, IMNSHO

;Optional
AutoItWinSetTitle("Select the file(s) you want")
;//Optional

Opt("WinWaitDelay", 1)
WinActivate(AutoItWinGetTitle())
$Alpha = FileOpenDialog("Select the file(s) you want","c:\","All files (*.*)",5)
WinSetState(AutoItWinGetTitle(), "", @SW_HIDE)
Opt("WinWaitDelay", 250) ;---- Or yours other default

The AutoIt window is not a problem when the File open dialogue is opened, it can be even considered a feature since you can click in the task bar to recall the window,

but I think is not a such great idea keep it open after.

Moreover that way the Opt WinWaitDelay is restored after to default as the user may want.

Link to comment
Share on other sites

What the føck was I thinking when I posted this yesterday :

WinMove ("FileOpen Dialog", "", 100, 100)

WinMove ?

WinActivate would be better maybe ? :whistle:

It's a modified code, and I simply just forgot to replace WinMove with WinActivate...

Well well..

EDIT : Bad language sensored.. B)

Edited by Helge
Link to comment
Share on other sites

I don't like the double window, but you can use the always on top to do it cleanly.

As I posted elsewhere, try this:

;Optional
AutoItWinSetTitle("Select the file(s) you want")
;//Optional

Opt("WinWaitDelay", 1)
WinSetOnTop ( AutoItWinGetTitle(), "", 1 )
$Alpha = FileOpenDialog("Select the file(s) you want","c:\","All files (*.*)",5)
WinSetState(AutoItWinGetTitle(), "", @SW_HIDE)
Opt("WinWaitDelay", 250);---- Or yours other default
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

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