Jump to content

Fileopendialog()


Rick
 Share

Recommended Posts

i've seen script that moves the FileOpenDialog() but is there a way to stop the flashing?

or better, a way to first centre FileOpenDialog() on screen in the first place??

any help would be appreciated thanks

ps: i bet Larry would know cos he rocks

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

  • Moderators

Yes that was the script i was referring to, its a shame theres an initial flash before moving

Hmm, I have no flash before moving... what are the specs of the computer your using to test?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hmm, I have no flash before moving... what are the specs of the computer your using to test?

when i run that script the dialogue is first placed at 0,0 until its rerun and moves it to centre, ok its not a fast machine but it would be nice if nothing was shown until final position is known and having to restart a long script would delay things further

I did try creating a another script within mine to detect the dialogue window, move it then exit, but that as good as has the same effect

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

  • Moderators

when i run that script the dialogue is first placed at 0,0 until its rerun and moves it to centre, ok its not a fast machine but it would be nice if nothing was shown until final position is known and having to restart a long script would delay things further

I did try creating a another script within mine to detect the dialogue window, move it then exit, but that as good as has the same effect

Well the issue you are going to run into there, is by default it's going to start at 0,0. There aren't any starting coords that you can program into it specifically. So using this method, or even the MsgBox() Move method posted by herewasplato would basically be your only options.

Edit:

Forgot a word!

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

that was my initial question as if filesavedialogue is opened in notepad then it opens within the notepad window not at 0,0

so there must be a way to do it as Windows does it.

Edited by Rick

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

hmm i like that, altho i dont need the read-only box to appear(setting .flags to 4 resolves that),

and want to mutiply select files aswell.

i dont know a lot about objcreate could anyone help?

Edited by Rick

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

;Shift down for multiple files selection :

$Filename = "C:\Default.txt"; Just a default, can be left empty

$OpenDialog = ObjCreate("MSComDlg.CommonDialog")

; For description of the filter format, see:

; http://msdn.microsoft.com/library/en-us/cm...vbproFilter.asp

; This filter collection contains 4 separate filters

$ComplexFilter="Text (*.txt;*.ini)|*.txt;*.ini|Image (*.bmp;*.jpg)|*.bmp;*.jpg|Sound (*.mp3)|*.mp3|ALL (*.*)|*.*"

With $OpenDialog; set the dialog's properties

.DialogTitle = "Choose the file type you want to open..."

.Filter = $ComplexFilter ; Set my filter

.FilterIndex = 2 ; Default position in the above filter

.MaxFileSize = 260

.Flags = 512

.Filename = $Filename

.ShowOpen ; This will display the Open File Dialog

$FileName = .FileName ; Assign the filename selected to a variable.

EndWith

if @error then

msgbox(0,"","An error occured. Error number: " & @error)

else

msgbox(0,"","You have chosen the filename: " & $Filename)

endif

;EDIT :

;from :

http://www.codecomments.com/archive299-2004-3-162174.html

Edited by Lapo
Link to comment
Share on other sites

thanks!

excellent, so 512 enables multi-select, alas changes the style of the box to shortfilenames,

any way to alter this to a normal fileopendialogue box!?

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

;Specifies that the File Name list box allows multiple selections.
;The user can select more than one file at run time by pressing the 
;SHIFT key and using the UP ARROW and DOWN ARROW keys to select the desired files. 
;When this is done, the FileName property returns a string containing the names of 
;all selected files. The names in the string are delimited by spaces.
Global Const $cdlOFNAllowMultiselect = 0x200 
 
;Specifies that the dialog box prompts the user to create a file that 
;doesn't currently exist. This flag automatically sets the cdlOFNPathMustExist 
;and cdlOFNFileMustExist flags. 
Global Const $cdlOFNCreatePrompt = 0x2000 
;Use the Explorer-like Open A File dialog box template. 
;Works with Windows 95, Windows NT 4.0, or later versions. 
Global Const $cdlOFNExplorer = 0x80000 
;Indicates that the extension of the returned filename is different from the 
;extension specified by the DefaultExt property. This flag isn't set if the 
;DefaultExt property is Null, if the extensions match, or if the file has no extension. 
;This flag value can be checked upon closing the dialog box. 
Global Const $CdlOFNExtensionDifferent = 0x400
;Specifies that the user can enter only names of existing files in the File Name text box. 
;If this flag is set and the user enters an invalid filename, a warning is displayed. 
;This flag automatically sets the cdlOFNPathMustExist flag. 
Global Const $cdlOFNFileMustExist = 0x1000
;Causes the dialog box to display the Help button.  
Global Const $cdlOFNHelpButton = 0x10
;Hides the Read Only check box. 
Global Const $cdlOFNHideReadOnly = 0x4
;Use long filenames. 
Global Const $cdlOFNLongNames = 0x200000
;Forces the dialog box to set the current directory to what it was when the dialog box was opened. 
Global Const $cdlOFNNoChangeDir = 0x8
;Do not dereference shell links (also known as shortcuts). By default, choosing a shell link causes
;it to be dereferenced by the shell. 
Global Const $CdlOFNNoDereferenceLinks = 0x100000
;No long file names. 
Global Const $cdlOFNNoLongNames = 0x40000
;Specifies that the returned file won't have the Read Only attribute set and won't be in a write-protected directory. 
Global Const $CdlOFNNoReadOnlyReturn = 0x8000
;Specifies that the common dialog box allows invalid characters in the returned filename. 
Global Const $cdlOFNNoValidate = 0x100
;Causes the Save As dialog box to generate a message box if the selected file already exists.
;The user must confirm whether to overwrite the file. 
Global Const $cdlOFNOverwritePrompt = 0x2
;Specifies that the user can enter only valid paths.
;If this flag is set and the user enters an invalid path, a warning message is displayed. 
Global Const $cdlOFNPathMustExist = 0x800
;Causes the Read Only check box to be initially checked when the dialog box is created.
;This flag also indicates the state of the Read Only check box when the dialog box is closed. 
Global Const $cdlOFNReadOnly = 0x1
;Specifies that sharing violation errors will be ignored 
Global Const $cdlOFNShareAware = 0x4000

;Shift down for multiple files selection :

$Filename = ""; Just a default, can be left empty

$OpenDialog = ObjCreate("MSComDlg.CommonDialog")
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")   ; Initialize a COM error handler


; For description of the filter format, see:
; http://msdn.microsoft.com/library/en-us/cm...vbproFilter.asp

; This filter collection contains 4 separate filters
$ComplexFilter = "Text (*.txt;*.ini)|*.txt;*.ini|Image (*.bmp;*.jpg)|*.bmp;*.jpg|Sound (*.mp3)|*.mp3|ALL (*.*)|*.*"
With $OpenDialog; set the dialog's properties
    
    .DialogTitle = "Choose the file type you want to open..."
    
    .Filter = $ComplexFilter; Set my filter
    .FilterIndex = 2; Default position in the above filter
    .MaxFileSize = 260
    .CancelError = 1
;~  .Flags = 512
    .Flags = BitOR($cdlOFNAllowMultiselect,$cdlOFNFileMustExist,$cdlOFNLongNames,$cdlOFNPathMustExist)
    .Filename = $Filename
    .ShowOpen; This will display the Open File Dialog
    
    $Filename = .FileName; Assign the filename selected to a variable.
    
EndWith


If Not @error Then
    MsgBox(0, "", "You have chosen the filename: " & $Filename)
EndIf

; This is my custom defined error handler
Func MyErrFunc()

  $HexNumber=hex($oMyError.number,8)   ; for displaying purposes
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"     & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.number is: "       & @TAB & $HexNumber              & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF)
  SetError(1) ; to check for after this function returns
Endfunc

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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