Jump to content

Recommended Posts

Posted

Hi,

I am wondering if it is possible to change the text displayed on the buttons on the FileOpenDialog window.  Do you guys have any idea ?

Do i need to code a brand new FileOpenDialog function in order to do this ?  Is there some alternative FileOpenDialog solutions ?

Thank you :)

Posted (edited)

I Edit a Guinness code and got this:

#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3>
Global Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ;Must be global to allow compare

HotKeySet("{F8}", "_ShowDialog")

Example()

Func Example()
    Local $hGUI = GUICreate('An(other) example by guinness - 2013', Default, Default) ; Create a GUI.
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') ; Define a window message and assign to the WM_SHELLHOOK function.
    _WinAPI_RegisterShellHookWindow($hGUI) ; Register the shell hook message to our GUI.

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    _WinAPI_DeregisterShellHookWindow($hGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg
    Local $sTitle = ""
    Switch $wParam

        Case $HSHELL_WINDOWCREATED
            $sTitle = WinGetTitle($lParam)
            If WinGetProcess($lParam) = @AutoItPID And $sTitle=$sMessage Then
                ControlSetText($sTitle, "", "Button1", "AutoIt")
                ControlSetText($sTitle, "", "Button2", "Danyfirex")
            EndIf


    EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func _ShowDialog()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the list of selected files.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)
    EndIf

EndFunc   ;==>_Dialog

 

Saludos

Edited by Danyfirex
Update code
  • Moderators
Posted (edited)

OhBobSaget,

Or use my ChooseFileFolder UDF and then you can make your own buttons.

M23

Edit: 24k

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

OhBobSaget,

Or use my ChooseFileFolder UDF and then you can make your own buttons.

M23

Edit: 24k

Thank you for your input :)

I tried ChooseFileFolder and unfortunately this is not exactly what i want.  I want to have a window to select single or multiple files in a folder ( with a root specified in the OpenFileDialog ).  I also need this window to look-alike the windows open file dialog.

 

Posted

You can build your own and make it look however you'd like. FileOpenDialog is a standard Windows GUI, so it won't be very modifiable.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

  • Moderators
Posted

OhBobSaget,

 I want to have a window to select single or multiple files in a folder ( with a root specified in the OpenFileDialog ). 

Which the UDF can do for you very simply - and the user cannot navigate to other folders (unlike the Windows version).

 I also need this window to look-alike the windows open file dialog

Which the UDF cannot, but is the visual appearance really so important? Surely functionality comes first?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

I Edit a Guinness code and got this:

#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3>
Global Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ;Must be global to allow compare

HotKeySet("{F8}", "_ShowDialog")

Example()

Func Example()
    Local $hGUI = GUICreate('An(other) example by guinness - 2013', Default, Default) ; Create a GUI.
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') ; Define a window message and assign to the WM_SHELLHOOK function.
    _WinAPI_RegisterShellHookWindow($hGUI) ; Register the shell hook message to our GUI.

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    _WinAPI_DeregisterShellHookWindow($hGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg
    Local $sTitle = ""
    Switch $wParam

        Case $HSHELL_WINDOWCREATED
            $sTitle = WinGetTitle($lParam)
            If WinGetProcess($lParam) = @AutoItPID And $sTitle=$sMessage Then
                ControlSetText($sTitle, "", "Button1", "AutoIt")
                ControlSetText($sTitle, "", "Button2", "Danyfirex")
            EndIf


    EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func _ShowDialog()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the list of selected files.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)
    EndIf

EndFunc   ;==>_Dialog

 

Saludos

 

Sounds good ! This is was i needed :)

 

Thank you very much!!!

Posted

You're wellcome. Look out with $sMessage. I declared it twice lol. Just keep the global one.

 

Saludos

Posted

Hopefully i will be able to implement parts of your code.  The problem is i don't have a GUI or parent GUI to register.

I have a couple options available in the Tray Menu.  When selecting a specific entry in the Tray menu you launch the following function :

While 1
      Switch TrayGetMsg()
        Case $fileTransfer
            getFileToTransfer()
        EndSwitch
Wend
Func getFileToTransfer()
   $fTDialog = FileOpenDialog( "Please select the files you want to transfer", VerifUSBconnect() , "All Files (*.*)|Word Documents (*.docx)|PDF Documents (*.pdf)", 7 )
   If @error Then
      getFileToTransfer()
   EndIf
   return StringSplit($fTDialog, "|") ;
EndFunc

I think i can't set the button text using this way of doing things right ?

Posted (edited)

of couse yes. just create a dummy gui (hidden)

#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3>
Global Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ;Must be global to allow compare

HotKeySet("{F8}", "_ShowDialog")

Example()

Func Example()
    Local $hGUI = GUICreate('Just a Dummy GUI', Default, Default) ; Create a dummy gui no need to be visible


    GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') ; Define a window message and assign to the WM_SHELLHOOK function.
    _WinAPI_RegisterShellHookWindow($hGUI) ; Register the shell hook message to our GUI.

      _ShowDialog()

    _WinAPI_DeregisterShellHookWindow($hGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg
    Local $sTitle = ""
    Switch $wParam

        Case $HSHELL_WINDOWCREATED
            $sTitle = WinGetTitle($lParam)
            If WinGetProcess($lParam) = @AutoItPID And $sTitle=$sMessage Then
                ControlSetText($sTitle, "", "Button1", "AutoIt")
                ControlSetText($sTitle, "", "Button2", "Danyfirex")
            EndIf


    EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func _ShowDialog()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the list of selected files.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)
    EndIf

EndFunc   ;==>_Dialog

 

 

Saludos

Edited by Danyfirex
edit
Posted

A better example.

 

#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>; Required for the $TRAY_ICONSTATE_SHOW constant.

Global Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ;Must be global to allow compare


Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $hGUI = GUICreate("My Dummy GUI", 0, 0)
    Local $idShowDlg = TrayCreateItem("ShowDialog")
    TrayCreateItem("") ; Create a separator line.
    GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK') ; Define a window message and assign to the WM_SHELLHOOK function.
    _WinAPI_RegisterShellHookWindow($hGUI) ; Register the shell hook message to our GUI.




    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idShowDlg ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                _ShowDialog()
            Case $idExit ; Exit the loop.
                _WinAPI_DeregisterShellHookWindow($hGUI)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example



Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg
    Local $sTitle = ""
    Switch $wParam

        Case $HSHELL_WINDOWCREATED
            $sTitle = WinGetTitle($lParam)
            If WinGetProcess($lParam) = @AutoItPID And $sTitle = $sMessage Then
                ControlSetText($sTitle, "", "Button1", "AutoIt")
                ControlSetText($sTitle, "", "Button2", "Danyfirex")
            EndIf


    EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func _ShowDialog()

    ; Display an open dialog to select a list of file(s).
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the list of selected files.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)
    EndIf

EndFunc   ;==>_ShowDialog

Saludos

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...