Lemmens Peter Posted December 6, 2005 Share Posted December 6, 2005 Hi everybody, I searched like crazy to find a solution without success I want to use the 'FileOpenDialog' but would like to see the dialogBox (for instance) at the centre of the screen. Now it always appears at the top-left corner of my screen. Does anybody know what to do ? Do you know the answer, please help. Thank you, PeterScript_problem_with_OpenDialogBox.au3 Link to comment Share on other sites More sharing options...
odklizec Posted December 6, 2005 Share Posted December 6, 2005 (edited) Yes, it can be done, but not by using single command Thanks to yesterday's MHz's help, I was able to set the FileOpenDialog on top. And the same trick can be used in your case. Here you can find updated script..Script_problem_with_OpenDialogBox.au3 Edited December 6, 2005 by odklizec Link to comment Share on other sites More sharing options...
Lemmens Peter Posted December 6, 2005 Author Share Posted December 6, 2005 Cool ! Very nice code ! And got a reply in an instand ! Are you a Auto-it pro ? It works very well ! Thanks a lot for your help odklizec ! Peter Link to comment Share on other sites More sharing options...
odklizec Posted December 6, 2005 Share Posted December 6, 2005 No I'm not AutoIt pro user MHz is a pro! I just modified his code to move the FileOpenDialog to center of the screen. Link to comment Share on other sites More sharing options...
MHz Posted December 7, 2005 Share Posted December 7, 2005 (edited) Nice adaption of the code, odklizec. Optional:Just one safeguard I should have added earlier, to prevent the second instance from possibly continuing as a unmanaged process. Just to Return it's PID and ProcessClose it when finished, if it has not already done so.The script could use ProcessClose within OnAutoItExit instead, if either of you want it to run through the duration of the main script.From previous example given:If StringInStr($cmdlineraw, '/WinOnTop') Then MsgBox(4096,"Set win on top","OK") While 1 Select Case WinExists("Browse for Folder") WinSetOnTop("Browse for Folder", "", 1) ExitLoop Case WinExists("Select dll file to test..") WinSetOnTop("Select dll file to test..", "", 1) ExitLoop EndSelect Sleep(50) WEnd Sleep(30000) Exit EndIf ; Main Script Below $pid = _WinOnTop(); <--- PID Returned. FileSelectFolder("Choose a folder with plugins..", "","4","c:\") ProcessClose($pid); <--- PID Closed. Func _WinOnTop() If @Compiled Then Return Run(@ScriptFullPath & ' /WinOnTop'); <--- Return PID Else Return Run(@AutoItExe & ' "' & @ScriptFullPath & '" /WinOnTop'); <--- Return PID EndIf EndFunc4 Lines above using <--- Comment as a pointer show the changes to manage the 2nd process better.Sleep(30000) added just to show a run on effect for testing the ProcessClose Edited December 7, 2005 by MHz Link to comment Share on other sites More sharing options...
Danny35d Posted December 7, 2005 Share Posted December 7, 2005 odklizec nice little trick thanks for share. I modify your script a little bit so now you can pass the window titlle, this way you can used the same function with FileOpenDialog, FileSaveDialog or FileSelectFolder also add MHz safeguard using ProcessClose.expandcollapse popupIf StringInStr($cmdlineraw, '/MoveWin') Then $cmdlineraw = StringSplit(StringMid($cmdlineraw, StringInStr($cmdlineraw, '/MoveWin')), ':') While 1 Select Case WinExists($cmdlineraw[2]) $size=WinGetPos ($cmdlineraw[2]) $PosX=@DesktopWidth/2 - $size[2]/2 $PosY=@DesktopHeight/2 - $size[3]/2 WinMove($cmdlineraw[2], "", $PosX, $PosY) WinActivate($cmdlineraw[2]) ExitLoop EndSelect Sleep(50) WEnd Exit EndIf $Message_1 = "Does anybody know how to make the 'FileOpenDialog'-Box appear in the middle of the screen" & @CRLF & "instead of at the top-left corner of the screen ?" & @CRLF & "If you click 'OK' you'll see what I mean." $Message_2 = "Did you notice ? The 'FileOpenDialog'-Box always appears on the top-left corner of the screen." MsgBox(4096, "Please Help", $Message_1) $PID = _FindBrowseWin('Open file Dialog Box') $Read_File = FileOpenDialog ( "Open file Dialog Box", @ScriptDir & "\", "AutoIt Files (*.au3)",3,@ScriptFullPath) ProcessClose($PID) $PID = _FindBrowseWin('Save file Dialog Box') $Save_File = FileSaveDialog( "Save file Dialog Box", @ScriptDir, "Scripts (*.aut;*.au3)", 3) ProcessClose($PID) $PID = _FindBrowseWin('Browse for Folder') FileSelectFolder("Choose a folder with plugins..", "","4","c:\") ProcessClose($PID) MsgBox(4096, "Please Help", $Message_2) Exit Func _FindBrowseWin($sTitle) If @Compiled Then Return(Run(@ScriptFullPath & ' /MoveWin:' & $sTitle)) Else Return(Run(@AutoItExe & ' "' & @ScriptFullPath & '" /MoveWin:' & $sTitle)) EndIf EndFunc AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
MHz Posted December 7, 2005 Share Posted December 7, 2005 @Danny35d Very nice demonstration with your example. I do find this trick of starting a 2nd instance of the script very useful at regular times to achieve almost impossible goals. It is like asking a friend to help you with a heavy task which you cannot do on your own. Link to comment Share on other sites More sharing options...
cappy2112 Posted January 7, 2006 Share Posted January 7, 2006 Nice adaption of the code, odklizec. I wrote an alternative soltuion to this, before I found these threads. My main app, the one which calls FileOpenDialogue() runs another progrma immediately before calling FileOpenDialogue(), which waits for the window text in FileOpenDIalogue to be active, then centers it, and exits. the main app call looks like this Run("C:\Automation\waitcenter.exe " & $WindowTitle, "", @SW_HIDE) $SelectedPath = FileOpenDialog($WindowTitle, $DefaultDir, $Filter, 8, "PatchBankXXX") The source for WaitCenter is below. I sneed to implement a timeout in this. The strange thing that happens- when I run it the first tome, the FileOpenDIalogue() is centered, when I run the main app subsequently, a runtime error occurrs whic states WaitCenter.exe could not be found. It's not an elegant solution, but it was all I could come up with at 12:30 AM ;############################################################################ Func WaitForWindowandCenter($WindowTitle) While 1 Sleep(20) WindowActiveCenter($WindowTitle) WEnd EndFunc ;==>WaitForWindowandCenter ;############################################################################ Func CenterThisWindow($WindowTitle, $WindowText) Local $Size Local $X = 0 Local $Y = 0 $Size = WinGetClientSize($WindowTitle, "") $Y = (@DesktopHeight / 2) - ($Size[1] / 2) $X = (@DesktopWidth / 2) - ($Size[0] / 2) Return WinMove($WindowTitle, $WindowText, $X, $Y) EndFunc ;==>CenterThisWindow ;############################################################################ Func WindowActiveCenter($WindowTitleText) If WinActive($WindowTitleText, "") Then CenterThisWindow($WindowTitleText, "") Exit EndIf EndFunc ;==>WindowActiveCenter ;############################################################################ Func main() ;WaitForWindowandCenter("SELECT-DESTINATION-DIRECTORY...") WaitForWindowandCenter($CmdLine[1]) EndFunc ;==>main 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