Jump to content



Photo

FileOpenDialog as Child


  • Please log in to reply
52 replies to this topic

#1 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 185 posts

Posted 09 November 2006 - 10:52 AM

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:

AutoIt         
#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, 09 November 2006 - 10:54 AM.






#2 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,867 posts

Posted 09 November 2006 - 11:08 AM

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?

#3 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 185 posts

Posted 09 November 2006 - 11:13 AM

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, 09 November 2006 - 11:17 AM.


#4 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,867 posts

Posted 09 November 2006 - 11:49 AM

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, 09 November 2006 - 12:03 PM.


#5 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 185 posts

Posted 09 November 2006 - 02:17 PM

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, 09 November 2006 - 03:20 PM.


#6 Danny35d

Danny35d

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 783 posts

Posted 09 November 2006 - 04:16 PM

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, 09 November 2006 - 04:47 PM.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

#7 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 185 posts

Posted 09 November 2006 - 08:48 PM

(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, 09 November 2006 - 08:55 PM.


#8 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 185 posts

Posted 10 November 2006 - 11:46 AM

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

AutoIt         
#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


#9 amel27

amel27

    Seeker

  • Active Members
  • 33 posts

Posted 02 December 2006 - 07:39 AM

[quote name='Sunaj' post='265943' date='Nov 10 2006, 09:46 PM']
AutoIt         
[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]) EndFuncƒo݊÷ Ûú®¢×‰Ç©¢ËwÜ­~)mz»(~Øb±û§rبžz-Šä#oyø±yÛaŠÇ«®ŠÚ×±µéÝ~)mz·îËb¢v¥ŠÜ­ ­ „ÅŠWŽ¥éÉ©hû§rب«­¢+ÙÕ¹Œ}¥±•=Á•¹¥…±½œ€ ˜ŒÀÌØíµ…¥¹U$°€˜ŒÀÌØíÍQ¥Ñ±”°€˜ŒÀÌØíÍ%¹¥Ñ¥È°€˜ŒÀÌØíÍ¥±Ñ•È€ô€˜ŒÌäí±°€ ¨¸¨¤˜ŒÌäì¤(%1½…°€˜ŒÀÌØí…¥±Ñ•È€ôMÑÉ¥¹MÁ±¥Ð€ €˜ŒÀÌØíÍ¥±Ñ•Ȱ€˜ŒÌäíð˜ŒÌäì¤(%1½…°€˜ŒÀÌØí… MQHl˜ŒÀÌØí…¥±Ñ•ȁlÁt€¨È¬Åt(%1½…°€˜ŒÀÌØí¤°€˜ŒÀÌØí¥MхÉа€˜ŒÀÌØí¥¥¹…°°€˜ŒÀÌØíÍ MÑÉՍЀô€˜ŒÌä옌Ìä찀˜ŒÀÌØíÍ]MÑÉՍЀô€˜ŒÌä옌Ìäì($˜ŒÀÌØí… MQHlÁt€ô€˜ŒÀÌØí…¥±Ñ•ȁlÁt€¨È(%½È€˜ŒÀÌØí¤ôāQ¼€˜ŒÀÌØí…¥±Ñ•ȁlÁt($$˜ŒÀÌØí¥MхÉЀôMÑÉ¥¹%¹MÑȀ ˜ŒÀÌØí…¥±Ñ•ȁl˜ŒÀÌØí¥t°€˜ŒÌäì ˜ŒÌä찀À°€Ä¤($$˜ŒÀÌØí¥¥¹…°€ôMÑÉ¥¹%¹MÑȀ ˜ŒÀÌØí…¥±Ñ•ȁl˜ŒÀÌØí¥t°€˜ŒÌä줘ŒÌä찀À°´Ä¤($$˜ŒÀÌØí… MQHl˜ŒÀÌØí¤¨È´Åt€ôMÑÉ¥¹MÑÉ¥Á]L€¡MÑÉ¥¹1•™Ð€ ˜ŒÀÌØí…¥±Ñ•ȁl˜ŒÀÌØí¥t°€˜ŒÀÌØí¥MхÉдĤ°€Ì¤($$˜ŒÀÌØí… MQHl˜ŒÀÌØí¤¨Ét€ôMÑÉ¥¹MÑÉ¥Á]L€¡MÑÉ¥¹QÉ¥µI¥¡Ð€¡MÑÉ¥¹QÉ¥µ1•™Ð€ ˜ŒÀÌØí…¥±Ñ•ȁl˜ŒÀÌØí¥t°€˜ŒÀÌØí¥MхÉФ°MÑÉ¥¹1•¸€ ˜ŒÀÌØí…¥±Ñ•ȁl˜ŒÀÌØí¥t¤€´˜ŒÀÌØí¥¥¹…°¬Ä¤°€Ì¤($$˜ŒÀÌØíÍ MÑÉՍЀô€˜ŒÀÌØíÍ MÑÉՍЀ™…µÀ쀘ŒÌäí‰åѕl˜ŒÌä쀙…µÀìMÑÉ¥¹1•¸€ ˜ŒÀÌØí… MQHl˜ŒÀÌØí¤¨È´Åt¤¬Ä€™…µÀ쀘ŒÌäítí‰åѕl˜ŒÌä쀙…µÀìMÑÉ¥¹1•¸€ ˜ŒÀÌØí… MQHl˜ŒÀÌØí¤¨Ét¤¬Ä€™…µÀ쀘ŒÌäít옌Ìäì($$˜ŒÀÌØíÍ]MÑÉՍЀô€˜ŒÀÌØíÍ]MÑÉՍЀ™…µÀ쀘ŒÌäí‰åѕl˜ŒÌä쀙…µÀìMÑÉ¥¹1•¸€ ˜ŒÀÌØí… MQHl˜ŒÀÌØí¤¨È´Åt¤¨È¬È€™…µÀ쀘ŒÌäítí‰åѕl˜ŒÌä쀙…µÀìMÑÉ¥¹1•¸€ ˜ŒÀÌØí… MQHl˜ŒÀÌØí¤¨Ét¤¨È¬È€™…µÀ쀘ŒÌäít옌Ìäì(%9•áÐ(%1½…°€˜ŒÀÌØíÕ MQH€ô±±MÑÉÕÑ É•…Ñ”€ ˜ŒÀÌØíÍ MÑÉՍЀ™…µÀ쀘ŒÌäí‰åѕlÅt˜ŒÌäì¤(%1½…°€˜ŒÀÌØíÕ]MQH€ô±±MÑÉÕÑ É•…Ñ”€ ˜ŒÀÌØíÍ]MÑÉՍЀ™…µÀ쀘ŒÌäí‰åѕlÉt˜ŒÌäì¤(%½È€˜ŒÀÌØí¤ôāQ¼€˜ŒÀÌØí… MQHlÁt($%±±MÑÉՍÑM•Ñ…Ñ„€ ˜ŒÀÌØíÕ MQH°€˜ŒÀÌØí¤°€˜ŒÀÌØí… MQHl˜ŒÀÌØí¥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)¹‘Õ¹


#10 wolfbartels

wolfbartels

    Seeker

  • Active Members
  • 47 posts

Posted 04 December 2006 - 05:41 PM

Really very useful. It is also a solution for positioning the dialog somewhere else as upper left corner.

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

#11 amel27

amel27

    Seeker

  • Active Members
  • 33 posts

Posted 09 December 2006 - 03:33 AM

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


#12 Sunaj

Sunaj

    Prodigy

  • Active Members
  • PipPipPip
  • 185 posts

Posted 11 December 2006 - 04:23 PM

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, 11 December 2006 - 04:25 PM.


#13 wolfbartels

wolfbartels

    Seeker

  • Active Members
  • 47 posts

Posted 15 December 2006 - 09:27 PM

Thanks for the excellent functions.

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?

#14 amel27

amel27

    Seeker

  • Active Members
  • 33 posts

Posted 16 December 2006 - 09:48 AM

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


#15 MBrand

MBrand

    Seeker

  • Active Members
  • 10 posts

Posted 08 January 2007 - 11:09 AM

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

#16 amel27

amel27

    Seeker

  • Active Members
  • 33 posts

Posted 11 January 2007 - 09:03 AM

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


#17 user52

user52

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 23 January 2007 - 12:57 AM

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


#18 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 17 February 2007 - 04:10 AM

user52
Hi!
It is possible add to this function (for _MsgBox) flag timeout? (like in original function).
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#19 amel27

amel27

    Seeker

  • Active Members
  • 33 posts

Posted 17 February 2007 - 07:45 AM

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.
AutoIt         
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, 23 April 2007 - 11:34 PM.


#20 JohnBailey

JohnBailey

    Scripter

  • Active Members
  • PipPipPipPipPipPip
  • 943 posts

Posted 10 April 2007 - 05:33 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users