Jump to content

FileOpenDialog as Child


Sunaj
 Share

Recommended Posts

Hi, I worked on from my last posting and managed to make a MsgBox behave like a 'standard' child to the main script (see example). Now my question goes: is it possible for any of you hardcore AU3 scripters to duplicate this exact behavior in a FileOpenDialog?! If so, please post code that makes 2nd GUI button open a FileOpenDialog that has same behavior as the MsgBox opened by the 1st button. The grand price here is super messageboard fame and my undying gratitude! :whistle:

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

$mainGUI = GUICreate("Example", 400, 500)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$msgbox_button = GUICtrlCreateButton('Open "child-like" MsgBox (working with DllCall)', 70, 50, 243)
GUICtrlSetOnEvent($msgbox_button, "msgbox_button")
$FileOpenDialog_button = GUICtrlCreateButton('Open "child-like" FileOpenDialog (NOT working)', 70, 100, 250)
GUICtrlSetOnEvent($FileOpenDialog_button, "FileOpenDialog_button")
$Exit_button = GUICtrlCreateButton('Exit Example', 70, 150, 250)
GUICtrlSetOnEvent($Exit_button, "CLOSEClicked")
GUISetState(@SW_SHOW)

While 1
  Sleep(500)
WEnd

Func msgbox_button()
  DllCall("user32.dll","int","MessageBox","hwnd",$mainGUI,"str", _
  "1. Notice how this does NOT show up on the taskbar." & @crlf & _ 
  "2. And if you swap between different apps and return to the Example, this is STILL on top" & @crlf & _
  "3. Also, it 'locks' the example untill you click 'ok'","str","Some Title","int",48)
EndFunc

Func FileOpenDialog_button()
  FileOpenDialog("Please select some exe (test)", @ProgramFilesDir,"Executables (*.exe)",1)
EndFunc

Func CLOSEClicked()
  Exit
EndFunc
Edited by Sunaj
Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

when you say, "Act like a standard child window" , could you explain this a little better? Do you mean when the parent window is active, this window will be on top, and when the parent is minimized, it will be also?

Hi vollyman,

Short answer: Please run example and topmost button for a demonstration of the exact behavior I'm talking about.

Long answer: I mean that the dialog should be on top relative to the main script GUI and, while on top, 'lock' the main script GUI so that the user cannot interact with it before the dialog has been dealt with.

Edit: proper addressing of answer

Edited by Sunaj
Link to comment
Share on other sites

ok, just use a WinSetOnTop to do it.

FileOpenDialog ( "title", "init dir", "filter" [, options [, "default name"]] )

while 1

if winactive ("title of your GUI") then

WinSetOnTop ( "title", "text", 1)

sleep(10)

wend

Something like that will do it.

Edited by vollyman
Link to comment
Share on other sites

ok, just use a WinSetOnTop to do it.

FileOpenDialog ( "title", "init dir", "filter" [, options [, "default name"]] )

while 1

if winactive ("title of your GUI") then

WinSetOnTop ( "title", "text", 1)

sleep(10)

wend

Something like that will do it.

Not really, the script (if repaired) will only put the FileOpenDialog on top and not do anything to hide it from taskbar, nor will it tie the FileOpenDialog to the main GUI in the same way the first MsgBox is tied. Maybe a DllCall or a Object (?) is needed to accomplish this..? I scoured through loads of articles on MSDN Windows API Reference site with no luck.. also tried using the ANYGUI ... no luck.

Edit: updated posting with source links

Edited by Sunaj
Link to comment
Share on other sites

The only thing I know about programming is AutoIt. :whistle:

I did a little search and this is what I found, but is above my knowledge.

MSDN

Func FileOpenDialog_button()
    Local $Filter = 'Text (*.txt)' ;Need a NULL-terminated Unicode string
    Local $InitDir = 'C:\'
    Local $FileSelected = ''
  
    DllCall('Shell32.dll', 'none', 'GetFileNameFromBrowse', 'hwnd', $mainGUI, 'wstr', $FileSelected, 'int', 255, _
        'wstr', $InitDir, 'wstr', '', 'wstr', $Filter, 'wstr', 'Some Title')
    ConsoleWrite('File Selected: ' & $FileSelected & @CRLF)
EndFunc

So far the above code is what I try, but the filter section 'Text (*.txt)', 'All files (*.*)' and returning the selected file don't work. May be someone else can take a peek and work from the above code.

Edit: Fix some typo.

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

(accidentally deleted my "thank you very much" posting - I'm still very very happy that Danny35d helped me out on this one!) :whistle:

I'll not have a chance to research further on the GetFileNameFromBrowse shell function tonight - be back on it tomorrow.

Edit: updated due to accidental deleting of former posting

Edited by Sunaj
Link to comment
Share on other sites

:whistle: Ok, so with Danny35d's help I've managed to find a solution that does return a filename from the shell32.dll function GetFileNameFromBrowse (see full incl. code for a ready-to-run example, notice how the dialog does not show up on taskbar and is tied to the main GUI - this is not possible with the built-in FileOpenDialog function*). The only remaining problem is how to make the filter work. Please see this and this (look for lpstrFilter) article for information on how to pass the parameter.. I cannot make it work but I guess it's because of a simply error in my translation of the Microsoft articles to AU3 syntax. I'm sure this obstacle can be overcome.. and followingly it will be possible to add a new fully functional DllCall function to the list of stuff that interacts perfectly with AU3! ;)

*as of yet that is; AutoIT develops quickly due to excellent maintainers/developers (& this very forum!)

Anyhow, the code:

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

$mainGUI = GUICreate("Example", 400, 500)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$msgbox_button = GUICtrlCreateButton('Open "child-like" MsgBox (working DllCall)', 70, 50, 243)
GUICtrlSetOnEvent($msgbox_button, "msgbox_button")
$FileOpenDialog_button = GUICtrlCreateButton('Open "child-like" FileOpenDialog (working DllCall)', 70, 100, 250)
GUICtrlSetOnEvent($FileOpenDialog_button, "FileOpenDialog_button")
$Exit_button = GUICtrlCreateButton('Exit Example', 70, 150, 250)
GUICtrlSetOnEvent($Exit_button, "CLOSEClicked")
GUISetState(@SW_SHOW)

While 1
    Sleep(500)
WEnd

Func msgbox_button()
    Local $MsgBoxText = "1. Notice how this does NOT show up on the taskbar." & @crlf & _
            "2. And if you swap between different apps and return to the Example, this is STILL on top" & @crlf & _
            "3. Also, it 'locks' the example untill you click 'ok'"
    Local $MsgBoxTitle = "Some Title"
    
    DllCall("user32.dll", _ ; dll mother
            "int", "MessageBox", _ ; dll function
            "hwnd", $mainGUI, _ ; maingui to bind msgbox to (if any)
            "str", $MsgBoxText , _ ; msgbox text
            "str",$MsgBoxTitle, _ ; msgbox title
            "int",48) ; msgbox type
EndFunc

Func FileOpenDialog_button()
    Local $Title = "Some Title"
    Local $Filter = 'Executables' & Chr(0) & '.exe' & Chr(0) & Chr(0)
    Local $InitPath = 'C:\'
    Local $InitializeWithFilename = ''
    Local $AutoAppendExtension = ''

    $Result = DllCall("Shell32.dll", _ ; dll mother
            "int", 'GetFileNameFromBrowse', _ ; returns array, [2] contains selected string
            'hwnd', $mainGUI, _ ; maingui to bind msgbox to (if any)
            'wstr', $InitializeWithFilename, _ ; filename to initialize function with (if any)
            'int', 255, _ ; max file string length
            'wstr', $InitPath, _ ; path to initially browse from
            'wstr', $AutoAppendExtension, _ ; makes dialog append a specific extension, no "." needed
            'wstr', $Filter, _ ; shows all (*.*) or specific (*.exe) files
            'wstr', $Title) ; title of dialog box
    
    MsgBox(4096, "returned data from dialog (if any)", $Result[2])
EndFunc

Func CLOSEClicked()
    Exit
EndFunc
Link to comment
Share on other sites

  • 3 weeks later...
[code]Func FileOpenDialog_button()
    Local $Title = "Some Title"
    Local $Filter = 'Executables' & Chr(0) & '.exe' & Chr(0) & Chr(0)
    Local $InitPath = 'C:\'
    Local $InitializeWithFilename = ''
    Local $AutoAppendExtension = ''

    $Result = DllCall("Shell32.dll", _ ; dll mother
            "int", 'GetFileNameFromBrowse', _ ; returns array, [2] contains selected string
            'hwnd', $mainGUI, _ ; maingui to bind msgbox to (if any)
            'wstr', $InitializeWithFilename, _ ; filename to initialize function with (if any)
            'int', 255, _ ; max file string length
            'wstr', $InitPath, _ ; path to initially browse from
            'wstr', $AutoAppendExtension, _ ; makes dialog append a specific extension, no "." needed
            'wstr', $Filter, _ ; shows all (*.*) or specific (*.exe) files
            'wstr', $Title) ; title of dialog box
    
    MsgBox(4096, "returned data from dialog (if any)", $Result[2])
EndFuncoÝ÷ Ûú®¢×Ç©¢ËwÜ­~)mz»(~Øb±û§rبz-Âä#oyø±yÛaÇ«®Ú×±µéÝ~)mz·îËb¢v¥Ü­ ­ ÅW¥ééhû§rب«­¢+ÙÕ¹}¥±=Á¹¥±½ ÀÌØíµ¥¹U$°ÀÌØíÍQ¥Ñ±°ÀÌØíÍ%¹¥Ñ¥È°ÀÌØíÍ¥±ÑÈôÌäí±° ¨¸¨¤Ìäì¤(%1½°ÀÌØí¥±ÑÈôMÑÉ¥¹MÁ±¥Ð ÀÌØíÍ¥±ÑÈ°ÌäíðÌäì¤(%1½°ÀÌØí
MQHlÀÌØí¥±ÑÈlÁt¨È¬Åt(%1½°ÀÌØí¤°ÀÌØí¥MÑÉаÀÌØí¥¥¹°°ÀÌØíÍ
MÑÉÕÐôÌäìÌäì°ÀÌØíÍ]MÑÉÕÐôÌäìÌäì($ÀÌØí
MQHlÁtôÀÌØí¥±ÑÈlÁt¨È(%½ÈÀÌØí¤ôÄQ¼ÀÌØí¥±ÑÈlÁt($$ÀÌØí¥MÑÉÐôMÑÉ¥¹%¹MÑÈ ÀÌØí¥±ÑÈlÀÌØí¥t°Ìäì Ìäì°À°Ä¤($$ÀÌØí¥¥¹°ôMÑÉ¥¹%¹MÑÈ ÀÌØí¥±ÑÈlÀÌØí¥t°Ìäì¤Ìäì°À°´Ä¤($$ÀÌØí
MQHlÀÌØí¤¨È´ÅtôMÑÉ¥¹MÑÉ¥Á]L¡MÑÉ¥¹1Ð ÀÌØí¥±ÑÈlÀÌØí¥t°ÀÌØí¥MÑÉдĤ°Ì¤($$ÀÌØí
MQHlÀÌØí¤¨ÉtôMÑÉ¥¹MÑÉ¥Á]L¡MÑÉ¥¹QÉ¥µI¥¡Ð¡MÑÉ¥¹QÉ¥µ1Ð ÀÌØí¥±ÑÈlÀÌØí¥t°ÀÌØí¥MÑÉФ°MÑÉ¥¹1¸ ÀÌØí¥±ÑÈlÀÌØí¥t¤´ÀÌØí¥¥¹°¬Ä¤°Ì¤($$ÀÌØíÍ
MÑÉÕÐôÀÌØíÍ
MÑÉÕеÀìÌäíåÑlÌäìµÀìMÑÉ¥¹1¸ ÀÌØí
MQHlÀÌØí¤¨È´Åt¤¬ÄµÀìÌäítíåÑlÌäìµÀìMÑÉ¥¹1¸ ÀÌØí
MQHlÀÌØí¤¨Ét¤¬ÄµÀìÌäítìÌäì($$ÀÌØíÍ]MÑÉÕÐôÀÌØíÍ]MÑÉÕеÀìÌäíåÑlÌäìµÀìMÑÉ¥¹1¸ ÀÌØí
MQHlÀÌØí¤¨È´Åt¤¨È¬ÈµÀìÌäítíåÑlÌäìµÀìMÑÉ¥¹1¸ ÀÌØí
MQHlÀÌØí¤¨Ét¤¨È¬ÈµÀìÌäítìÌäì(%9áÐ(%1½°ÀÌØíÕ
MQHô±±MÑÉÕÑ
ÉÑ ÀÌØíÍ
MÑÉÕеÀìÌäíåÑlÅtÌäì¤(%1½°ÀÌØíÕ]MQHô±±MÑÉÕÑ
ÉÑ ÀÌØíÍ]MÑÉÕеÀìÌäíåÑlÉtÌäì¤(%½ÈÀÌØí¤ôÄQ¼ÀÌØí
MQHlÁt($%±±MÑÉÕÑMÑÑ ÀÌØíÕ
MQH°ÀÌØí¤°ÀÌØí
MQHlÀÌØí¥t¤(%9áÐ($ÀÌØíÉÐô±±
±° ÅÕ½Ðí­É¹°Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí5ձѥ    åÑQ½]¥
¡ÈÅÕ½Ðì°|($$ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À°|($$ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À°|($$ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØíÕ
MQH¤°|($$ÅÕ½Ðí¥¹ÐÅÕ½Ðì°±±MÑÉÕÑÑM¥é ÀÌØíÕ
MQH¤°|($$ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØíÕ]MQH¤°|($$ÅÕ½Ðí¥¹ÐÅÕ½Ðì°±±MÑÉÕÑÑM¥é ÀÌØíÕ]MQH¤¤($ÀÌØíÉÐô±±
±° ÅÕ½ÐíM¡±°Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÌäíÑ¥±9µÉ½µ   ɽÝÍÌäì°|($$$Ìäí¡Ý¹Ìäì°ÀÌØíµ¥¹U$°|($$$ÌäíÝÍÑÈÌäì°ÌäìÌäì°|($$$Ìäí¥¹ÐÌäì°ÈÔÔ°|($$$ÌäíÝÍÑÈÌäì°ÀÌØíÍ%¹¥Ñ¥È°|($$$ÌäíÝÍÑÈÌäì°ÌäìÌäì°|($$$ÌäíÁÑÈÌäì°±±MÑÉÕÑÑAÑÈ ÀÌØíÕ]MQH¤°|($$$ÌäíÝÍÑÈÌäì°ÀÌØíÍQ¥Ñ±¤(%IÑÕɸÀÌØíÉÐlÉt)¹Õ¹
Link to comment
Share on other sites

Will we have a similar solution for the FileSaveDialog, too?

Well, I've rewrite this functions headed for full compatible with AutoIT dialogs... And add some new functionality at one:

- New flag: 32 = Hide places bar;

- Optional parameter: Default File Extension (added if user omit file extention);

- Optional parameter: HWND of main GUI Windows.

Func _FileOpenDialog ($sTitle, $sInitDir, $sFilter = 'All (*.*)', $iOpt = 0, $sDefaultFile = "", $sDefaultExt = "", $mainGUI = 0)
    Local $iFileLen = 65536 ; Max chars in returned string
    ; API flags prepare
    Local $iFlag = BitOR ( _
        BitShift (BitAND ($iOpt, 1),-12), BitShift (BitAND ($iOpt, 2),-10), BitShift (BitAND ($iOpt, 4),-7 ), _
        BitShift (BitAND ($iOpt, 8),-10), BitShift (BitAND ($iOpt, 4),-17) )
    ; Filter string to array convertion
    Local $asFLines = StringSplit ( $sFilter, '|'), $asFilter [$asFLines [0] *2+1]
    Local $i, $iStart, $iFinal, $suFilter = ''
    $asFilter [0] = $asFLines [0] *2
    For $i=1 To $asFLines [0]
        $iStart = StringInStr ($asFLines [$i], '(', 0, 1)
        $iFinal = StringInStr ($asFLines [$i], ')', 0,-1)
        $asFilter [$i*2-1] = StringStripWS (StringLeft ($asFLines [$i], $iStart-1), 3)
        $asFilter [$i*2] = StringStripWS (StringTrimRight (StringTrimLeft ($asFLines [$i], $iStart), StringLen ($asFLines [$i]) -$iFinal+1), 3)
        $suFilter = $suFilter & 'byte[' & StringLen ($asFilter [$i*2-1])+1 & '];byte[' & StringLen ($asFilter [$i*2])+1 & '];'
    Next
    ; Create API structures
    Local $uOFN = DllStructCreate ('dword;int;int;ptr;ptr;dword;dword;ptr;dword' & _
        ';ptr;int;ptr;ptr;dword;short;short;ptr;ptr;ptr;ptr;ptr;dword;dword' )
    Local $usTitle  = DllStructCreate ('byte[' & StringLen ($sTitle) +1 & ']')
    Local $usInitDir= DllStructCreate ('byte[' & StringLen ($sInitDir) +1 & ']')
    Local $usFilter = DllStructCreate ($suFilter & 'byte')
    Local $usFile   = DllStructCreate ('byte[' & $iFileLen & ']')
    Local $usExtn   = DllStructCreate ('byte[' & StringLen ($sDefaultExt) +1 & ']')
    For $i=1 To $asFilter [0]
        DllStructSetData ($usFilter, $i, $asFilter [$i])
    Next
    ; Set Data of API structures
    DllStructSetData ($usTitle, 1, $sTitle)
    DllStructSetData ($usInitDir, 1, $sInitDir)
    DllStructSetData ($usFile, 1, $sDefaultFile)
    DllStructSetData ($usExtn, 1, $sDefaultExt)
    DllStructSetData ($uOFN,  1, DllStructGetSize($uOFN))
    DllStructSetData ($uOFN,  2, $mainGUI)
    DllStructSetData ($uOFN,  4, DllStructGetPtr ($usFilter))
    DllStructSetData ($uOFN,  7, 1)
    DllStructSetData ($uOFN,  8, DllStructGetPtr ($usFile))
    DllStructSetData ($uOFN,  9, $iFileLen)
    DllStructSetData ($uOFN, 12, DllStructGetPtr ($usInitDir))
    DllStructSetData ($uOFN, 13, DllStructGetPtr ($usTitle))
    DllStructSetData ($uOFN, 14, $iFlag)
    DllStructSetData ($uOFN, 17, DllStructGetPtr ($usExtn))
    DllStructSetData ($uOFN, 23, BitShift (BitAND ($iOpt, 32), 5))
    ; Call API function
    $ret = DllCall ('comdlg32.dll', 'int', 'GetOpenFileName', _
            'ptr', DllStructGetPtr ($uOFN) )
    If $ret [0] Then
        If BitAND ($iOpt, 4) Then
            $i = 1
            While 1
                If DllStructGetData ($usFile, 1, $i) =0 Then
                    If DllStructGetData ($usFile, 1, $i+1) Then 
                        DllStructSetData ($usFile, 1, 124, $i)
                    Else
                        ExitLoop
                    EndIf
                EndIf
                $i += 1
            Wend
        EndIf
        Return DllStructGetData ($usFile, 1)
    Else
        SetError (1)
        Return ""
    EndIf
EndFunc

Func _FileSaveDialog ($sTitle, $sInitDir, $sFilter = 'All (*.*)', $iOpt = 0, $sDefaultFile = "", $sDefaultExt = "", $mainGUI = 0)
    Local $iFileLen = 65536 ; Max chars in returned string
    ; API flags prepare
    Local $iFlag = BitOR (BitShift (BitAND ($iOpt, 2),-10), BitShift (BitAND ($iOpt,16), 3 ))
    ; Filter string to array convertion
    Local $asFLines = StringSplit ( $sFilter, '|'), $asFilter [$asFLines [0] *2+1]
    Local $i, $iStart, $iFinal, $suFilter = ''
    $asFilter [0] = $asFLines [0] *2
    For $i=1 To $asFLines [0]
        $iStart = StringInStr ($asFLines [$i], '(', 0, 1)
        $iFinal = StringInStr ($asFLines [$i], ')', 0,-1)
        $asFilter [$i*2-1] = StringStripWS (StringLeft ($asFLines [$i], $iStart-1), 3)
        $asFilter [$i*2] = StringStripWS (StringTrimRight (StringTrimLeft ($asFLines [$i], $iStart), StringLen ($asFLines [$i]) -$iFinal+1), 3)
        $suFilter = $suFilter & 'byte[' & StringLen ($asFilter [$i*2-1])+1 & '];byte[' & StringLen ($asFilter [$i*2])+1 & '];'
    Next
    ; Create API structures
    Local $uOFN = DllStructCreate ('dword;int;int;ptr;ptr;dword;dword;ptr;dword' & _
        ';ptr;int;ptr;ptr;dword;short;short;ptr;ptr;ptr;ptr;ptr;dword;dword' )
    Local $usTitle  = DllStructCreate ('byte[' & StringLen ($sTitle) +1 & ']')
    Local $usInitDir= DllStructCreate ('byte[' & StringLen ($sInitDir) +1 & ']')
    Local $usFilter = DllStructCreate ($suFilter & 'byte')
    Local $usFile   = DllStructCreate ('byte[' & $iFileLen & ']')
    Local $usExtn   = DllStructCreate ('byte[' & StringLen ($sDefaultExt) +1 & ']')
    For $i=1 To $asFilter [0]
        DllStructSetData ($usFilter, $i, $asFilter [$i])
    Next
    ; Set Data of API structures
    DllStructSetData ($usTitle, 1, $sTitle)
    DllStructSetData ($usInitDir, 1, $sInitDir)
    DllStructSetData ($usFile, 1, $sDefaultFile)
    DllStructSetData ($usExtn, 1, $sDefaultExt)
    DllStructSetData ($uOFN,  1, DllStructGetSize($uOFN))
    DllStructSetData ($uOFN,  2, $mainGUI)
    DllStructSetData ($uOFN,  4, DllStructGetPtr ($usFilter))
    DllStructSetData ($uOFN,  7, 1)
    DllStructSetData ($uOFN,  8, DllStructGetPtr ($usFile))
    DllStructSetData ($uOFN,  9, $iFileLen)
    DllStructSetData ($uOFN, 12, DllStructGetPtr ($usInitDir))
    DllStructSetData ($uOFN, 13, DllStructGetPtr ($usTitle))
    DllStructSetData ($uOFN, 14, $iFlag)
    DllStructSetData ($uOFN, 17, DllStructGetPtr ($usExtn))
    DllStructSetData ($uOFN, 23, BitShift (BitAND ($iOpt, 32), 5))
    ; Call API function
    $ret = DllCall ('comdlg32.dll', 'int', 'GetSaveFileName', _
            'ptr', DllStructGetPtr ($uOFN) )
    If $ret [0] Then
        Return DllStructGetData ($usFile, 1)
    Else
        SetError (1)
        Return ""
    EndIf
EndFunc
Link to comment
Share on other sites

Hi amel27, just want to add that I'm extremely impressed by the FileSave/Open extensions you have contributed, I'm sure a lot of people will find this really useful.

Sunaj

Well, I've rewrite this functions headed for full compatible with AutoIT dialogs... And add some new functionality at one:

- New flag: 32 = Hide places bar;

- Optional parameter: Default File Extension (added if user omit file extention);

- Optional parameter: HWND of main GUI Windows.

Edited by Sunaj
Link to comment
Share on other sites

The dialog opened by '_FileOpenDialog(...)' shows a Checkbox 'Open write protected' (Schreibgeschützt Öffnen, in German). My question is, does this check reflect in the return array? Does Windows set a 'read only' attribute?

Hmm, I've miss this optional checkbox. :"> The state of this checkbox may be returned when the dialog box is closed, but I don't know where save this info... it may be disable by adding Flag 0x4 to $iFlag flagset:
DllStructSetData ($uOFN, 14, BitOR ($iFlag, 4))
Link to comment
Share on other sites

  • 4 weeks later...

Hi amel27,

I managed to integrate your _Filopen function successfully into my autoit-scripts and they worked fine with WXP. But today I tried them on 2 W2K machines and the $ret, $ret[0] and $ret[1] is always empty. W2K uses an older version of the comdlg32.dll.

So is there a chance to get the filname someway by changing the script?

Michael

Link to comment
Share on other sites

Hi amel27,

I managed to integrate your _Filopen function successfully into my autoit-scripts and they worked fine with WXP. But today I tried them on 2 W2K machines and the $ret, $ret[0] and $ret[1] is always empty. W2K uses an older version of the comdlg32.dll.

So is there a chance to get the filname someway by changing the script?

Michael

I've confused again... :">

Change buffer size for returned string to 32768 bytes:

Local $iFileLen = 32768 ; Max chars in returned string
Link to comment
Share on other sites

  • 2 weeks later...

this may be better for the msgbox_button() function

;MsgBox(flag, "title", "text", [, timeout])
Func _MsgBox($flag=0, $title="", $text="", $parent="")
    DllCall("user32.dll", _        ; dll mother
            "int", "MessageBox", _ ; dll function
            "hwnd", $parent, _     ; maingui to bind msgbox to (if any)
            "str", $text , _       ; msgbox text
            "str", $title, _       ; msgbox title
            "int", $flag)          ; msgbox type
EndFunc
Link to comment
Share on other sites

  • 4 weeks later...

user52

Hi!

It is possible add to this function (for _MsgBox) flag timeout? (like in original function).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Hi all, it's my final stuff for child dialogs. Second parameter ($root) is CSIDL of folder, NOT path!.. And optional Flag 1 has opposite meaning.

Func _FileSelectFolder ($title, $root = 0, $flags = 0, $hwnd = 0)
    Local $ret, $pidl, $res = ''
    ; Creating Structures
    Local $ubi = DllStructCreate ("hwnd;ptr;ptr;ptr;int;ptr;ptr;int") ; structure BROWSEINFO
    Local $utl = DllStructCreate ("char[512]") ; Browse title
    Local $urs = DllStructCreate ("char[260]") ; Buffer for path (MAX_PATH size)
    Local $ulf = BitOR (BitShift(BitAnd ($flags,1),-9), _ ; 1: NOT show Create Folder Button
        BitShift(BitAnd ($flags,2),-5), _ ; 2: Use New Dialog Style
        BitShift(BitAnd ($flags,4),-2)) ; 4: Show Edit Control
    ; Filling structures
    DllStructSetData ($utl, 1, $title)
    DllStructSetData ($ubi, 1, $hwnd)
    DllStructSetData ($ubi, 3, DllStructGetPtr($urs))
    DllStructSetData ($ubi, 4, DllStructGetPtr($utl))
    DllStructSetData ($ubi, 5, $ulf)
    $ret = DllCall ("shell32.dll", "ptr", "SHGetSpecialFolderLocation", _
        "int", 0 , _
        "int", $root , _
        "ptr", DllStructGetPtr($ubi, 2))
    If $ret[0] Then Return $res
    ; Start browse window
    $pidl = DllCall ("shell32.dll", "ptr", "SHBrowseForFolder", "ptr", DllStructGetPtr ($ubi))
    If $pidl[0] Then
        $ret = DllCall ("shell32.dll", "int", "SHGetPathFromIDList", _
            "ptr", $pidl[0], _
            "ptr", DllStructGetPtr ($urs))
        If $ret[0] Then $res = DllStructGetData ($urs, 1)
        DllCall ("ole32.dll", "int", "CoTaskMemFree", "ptr", $pidl[0]) ; clear memory
    EndIf
    DllCall ("ole32.dll", "int", "CoTaskMemFree", "ptr", DllStructGetData ($ubi, 2))
    Return $res
EndFunc
Edited by amel27
Link to comment
Share on other sites

  • 1 month later...

First of all, major props to Amel27! I've been researching this for a few days on MSDN, but couldn't get a working example. This is completely necessary for giving the script control over the dialogs in ways the standard functions currently do not allow for. I could go on about how helpful this is, but I'm sure you (amel27) and others know how much it is.

Amel27, I'd like to work to write this out to the UDF standard with your permission and maybe your help.

A decision is a powerful thing
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...