Sign in to follow this  
Followers 0
Guest rathore

Au3guixp

31 posts in this topic

Please answer these two straight questions:

1. Is it possible to make a 'Browse..' button that when pressed opens a std File Open dialog and the selected file is reflected in the GUI?

2. Is it somehow possible to make the GUI window recognise the path of a file dropped on the window?

Share this post


Link to post
Share on other sites



1. Is it possible to make a 'Browse..' button that when pressed opens a std File Open dialog and the selected file is reflected in the GUI?

See the FileOpenDialog function (and prehaps the FileSelectFolder one too.) As to reflecting it in the GUI, just change a tooltip or label text based on the file.

2. Is it somehow possible to make the GUI window recognise the path of a file dropped on the window?

See the $WS_EX_ACCEPTFILES extended style for creating GUI's and the $GUI_ACCEPTFILES option for use with a control via the ControlSetEx function (you'll also need to read about the functions to understand how to use the paramaters :D .) If you still have problems after reading about those, ask another question and someone will make it clearer.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

i don't think i got the first answer correctly. yes i can use tooltip or even control cmd to reflect the change but how do i make a button open a file open dialog.

(i'm talking here about larry's au3guixp and not au3's inherent gui, of which i'm less acquaint)

Share this post


Link to post
Share on other sites

from the help file :

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","You chose " & $var)
EndIf

you can see the msgbox tells you the name of the file you selected. $var

So you could simply reflect that in the GUI by having it read off the name (" selected file is " & $var ) as an example..

is this what you mean?

Share this post


Link to post
Share on other sites

er, i want to create a 'Browse' button in the gui that'd open a file open window and the file selected will get in a variable that the script can use.

Share this post


Link to post
Share on other sites

forgot to mention that after the file selection, i don't want the gui to close, i want to use the file selected in the same window (maybe this was causing the confusion)

Share this post


Link to post
Share on other sites

er, i want to create a 'Browse' button in the gui that'd open a file open window and the file selected will get in a variable that the script can use.

well this code should open your browsing window. All you need to do is attach it to your button :

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

then from that point on $var would be the value of the file you chose. ie "notepad.exe"

are you just not sure how to add it to the button?

the example code from the GUIwrite command in the help file covers the change of the button name and recording values.

$GUI_FOCUS = 0

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

$ref=GUISetControl("button", "my clicking button", 10,10)
GUISetControlNotify()

GUISetControl("button", "my closing button", -1,50)
GUISetControlEx(-1,$GUI_FOCUS)   ; the focus is on this button and Click will close the GUI
$i=2
    While GUIMsg() > 0      ; will display a dialog box with 2 buttons
    MsgBox(0,"", "the clicking button has been clicked")

    GUIWrite($ref,0,"Click #" & $i)       ; text of the clicking button updated
    $i=$i+1
    Wend

MsgBox(0,"", "the dialog box has bean closed by " & GUIRead())

forgot to mention that after the file selection, i don't want the gui to close, i want to use the file selected in the same window (maybe this was causing the confusion)

if you copy and paste that code you will notice the GUI doesn't close but the information within it updates.

so the code present should give you enough to create a file open box to get your file from and then update the GUI with the new text. I'm sure someone with more experience with the GUI code could whip one up from scratch. If I were to do it.. it's likley you'd get some copy and paste going on :huh2:

now that I think about it.. I'm starting to wonder if you've already made a GUI button that opens this file open box.. but when it does your GUI vanishes? keep in mind that if you store the variable for the file name you can reopen the GUI when the filesearch dialogue is done (within the same script) and the $var should maintain it's information. while technically it's not the *same* gui .. the user won't know the difference.

Sorry if I'm still not getting what you want. I'll leave the rest to someone more experienced if none of this helps you. :D

cheers

Share this post


Link to post
Share on other sites

thanx cowsmanaut and larry,

i'll check it out!

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
  ;// GUICreation
   GuiCreate( "mygui", 400, 300)
   GUICreateEx( -1,)

   GuiShow()
   

$ref=GUISetControl("button", "find file", 10,10)
GUISetControlNotify()

GUISetControl("button", "Cancel", -1,50)
GUISetControlEx(-1, $gui_focus)   ; the focus is on this button and Click will close the GUI

$message = "Hold down Ctrl or Shift to choose multiple files."
$var = "find file"
$file = 0
    While GUIMsg() > 0      ; will display a dialog box with 2 buttons
    $file= FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 )

    If @error Then
     MsgBox(4096,"","No File(s) chosen")
    Else
     $var = Stringright($file, 8)
  msgbox (0, "message", $var)
    EndIf

    GUIWrite($ref,0,$var)       ; text of the clicking button updated

    Wend

There's the copy and paste version with some addition of extra code here and there. Had some errors that had to be patched up.. otherwise it's only about 10% my own code.. the rest is right out of the examples found here and in the help file.

seems to work

moo

Share this post


Link to post
Share on other sites

thanx cowsmanaut for ur help, the only problem is that u're helping me with au3's inherent GUI & not with Au3GUIXP!

Share this post


Link to post
Share on other sites

hmmm yeah that would be a problem wouldn't it :huh2:

Well.. it still works :)

guess I need to actually read about this AU3guiXP

moo :D

Share this post


Link to post
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
Sign in to follow this  
Followers 0