ezzetabi Posted March 30, 2004 Share Posted March 30, 2004 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 More sharing options...
Helge Posted March 30, 2004 Share Posted March 30, 2004 (edited) 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.. Edited March 30, 2004 by Helge Link to comment Share on other sites More sharing options...
Valik Posted March 30, 2004 Share Posted March 30, 2004 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 More sharing options...
CyberSlug Posted March 30, 2004 Share Posted March 30, 2004 (edited) 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 activeMsgBox(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 March 30, 2004 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 More sharing options...
Administrators Jon Posted March 30, 2004 Administrators Share Posted March 30, 2004 I can't remember if the file dialog uses g_hWnd as a parent or if it uses NULL. One or the other may work better. (Bit busy with work atm to play much) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Valik Posted March 30, 2004 Share Posted March 30, 2004 It uses g_hWnd and changing to NULL seemed to have helped (With FileOpenDialog at least). Link to comment Share on other sites More sharing options...
ezzetabi Posted March 31, 2004 Author Share Posted March 31, 2004 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 More sharing options...
Helge Posted March 31, 2004 Share Posted March 31, 2004 (edited) What the føck was I thinking when I posted this yesterday :WinMove ("FileOpen Dialog", "", 100, 100)WinMove ?WinActivate would be better maybe ? It's a modified code, and I simply just forgot to replace WinMove with WinActivate...Well well..EDIT : Bad language sensored.. Edited March 31, 2004 by Helge Link to comment Share on other sites More sharing options...
scriptkitty Posted March 31, 2004 Share Posted March 31, 2004 (edited) 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 March 31, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now