Sign in to follow this  
Followers 0
anhchangtk

Problem FileOpenDiaLog

8 posts in this topic

#1 ·  Posted (edited)

Me had used code FileOpenDiaLog:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 317, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 148, 17)
$browse = GUICtrlCreateButton("Browse", 232, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
Else
    guictrlsetdata($patch,$var)
EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

With with long patch then $patch don't show full patch in 1 line

Now i'm want show Patch C:\MyDocuments and Setting\User\My Documents\exam.jpg then show

C:\MyDocuments an...\exam.jpg

As for file exam.jpg in E:\Pic\Exam\exam.jpg then show full patch is E:\Pic\Exam\exam.jpg

Show patch = width size of $patch :P

Please you help me :unsure:( Because i'm making project then very need :D

Thanks you !!!

Edited by anhchangtk

Share this post


Link to post
Share on other sites



You can use FileGetShortName($var) but I don't think it's a good idea to use a static control. Use GuiCtrlCreateInput with $ES_READONLY (#include <EditConstants.as3>) instead.

Share this post


Link to post
Share on other sites

Thanks You :P

But patch show is:

C:\DOCUME~1\User\MYDOCU~1\ak081012.jpg

Now i'm want patch show is:

C:\DOCUME~1\...\...\ak081012.jpg

Cause the $patch don't show full :unsure:

Share this post


Link to post
Share on other sites

Like this?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 397, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("........................................................", 72, 13, 228, 17)
$browse = GUICtrlCreateButton("Browse", 312, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
    If $browse = $Msg Then
        $message = "Chose a file"

        $var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1)

        If @error Then
            MsgBox(4096, "", "No File(s) chosen")
        Else
            $var = FileGetShortName($var)
            $tmp = StringTrimLeft($var, 3)
            $tmp = StringRegExpReplace($tmp, '(?<=\\).*?(?=\\)', '...')
            $tmp = StringLeft($var, 3) & $tmp
            GUICtrlSetData($patch, $tmp)
        EndIf
    EndIf
    If $Msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Now i'm use script of you

Me edit line $var = FileGetShortName($var) to $var1 = FileGetShortName($var)

And me use code:

$f=GUICtrlRead($var)

$f=FileReadLine($f, 1)

AutoIt don't know :-s it been error :P

Please you help me :unsure:

Edited by anhchangtk

Share this post


Link to post
Share on other sites

Hmm?

$Var is holding a non existing path after all this makeup. Store the file path (if the user chose one) on a global variable.

Also, this is not the way to open a handle to file. Read about FileOpen in the help file.

Share this post


Link to post
Share on other sites

@anhchangtk,

Does this help?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global Const $SS_PATHELLIPSIS = 0x008000
$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 350, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 180, 17, $SS_PATHELLIPSIS)
$browse = GUICtrlCreateButton("Browse", 265, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
Else
    guictrlsetdata($patch,$var)
        guiCtrlSetTip($Patch,$Var)
EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

Credit to Smoke_N and martin:

http://www.autoitscript.com/forum/index.ph...st&p=605551

Share this post


Link to post
Share on other sites

@Authenticity: thanks you :P me had sucess

@ResNullius: ok thanks you :unsure: but over

Set Global $SS_PATHELLIPSIS = 0x008000 and $SS_WORDELLIPSIS = 0x00C000

Can set $SS_PATHELLIPSIS = order ?

Ahh now me use the code

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global Const $SS_PATHELLIPSIS = 0x008000
$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 350, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 180, 17, $SS_PATHELLIPSIS)
$browse = GUICtrlCreateButton("Browse", 265, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileOpenDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 1 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
    Else
        $var = FileGetShortName($var)  [b]; me had add code :) => result very good :)[/b]
    guictrlsetdata($patch,$var)
        guiCtrlSetTip($Patch,$Var)
EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

But me want app to FileSaveDiaLog with script

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global Const $SS_PATHELLIPSIS = 0x008000
$Form1 = GUICreate("Problem Patch with FileOpenDiaLog", 350, 46, 192, 124)
$Label1 = GUICtrlCreateLabel("File name:", 10, 13, 52, 17)
$patch = GUICtrlCreateLabel("................................................", 72, 13, 180, 17, $SS_PATHELLIPSIS)
$browse = GUICtrlCreateButton("Browse", 265, 8, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
if $browse = $msg Then
    $message = "Chose a file"

$var = FileSaveDialog($message, @MyDocumentsDir & "\", "Images (*.jpg;*.bmp)", 1 + 16 )

If @error Then
        MsgBox(4096,"","No File(s) chosen")
    Else
        $var = FileGetShortName($var)
    guictrlsetdata($patch,$var)
        guiCtrlSetTip($Patch,$Var)
        EndIf
endif
if $msg = $GUI_EVENT_CLOSE then exit
WEnd

The script don't show as like :D

It's show is patch is:

C:\Documents and Settings\...\test.jpg

The script FileGetShortName () don't run :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