Sign in to follow this  
Followers 0
eri

Help with ComboBoxex...

8 posts in this topic

Please Corect My Script..

#include <GUIConstants.au3> 
#include <GuiComboBoxEx.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)
$Debug_CB = False 
Local $hGUI, $Location, $Locate, $delete, $msg, $path,  $open


$hGUI = GUICreate("Test Script AutoIt", 275, 80)
$Location = _GUICtrlComboBoxEx_Create ($hGUI, "", 4, 7, 100, 100)
            _GUICtrlComboBoxEx_AddDir ($Location, "", $DDL_DRIVES, False) 
GUICtrlCreateLabel("<<< Where Is File Location", 120, 5, 268, 20)
GUICtrlSetFont(-1, 10, 800, 4, "Pristina")
GUICtrlSetColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
$open = GUICtrlCreateButton("Open", 10, 40, 75, 25, 0) 
$delete = GUICtrlCreateButton("Delete", 100, 40, 80, 25, 0) 
 
While 1     
    $msg = GUIGetMsg()     
    Switch $msg         
        Case $GUI_EVENT_CLOSE  
        Exit               
    Case $open            
        $path = GUICtrlRead($Location)             
        If $path = '' Then                 
            MsgBox(64, "Warning", "You need to select a drive")             
        ElseIf DirCreate($path) Then   
            ShellExecute ($path &"\test.jpg")
        Else                 
            MsgBox(64, "Warning", "Install failed.") 
        EndIf 
    Case $delete
         FileDelete ($path &"\test.jpg")
    EndSwitch 
WEnd

Although I have select drive in Combolist.. then Click Button Open

Allways get messege MsgBox(64, "Warning", "You need to select a drive")

please correct my script..

Please..

Share this post


Link to post
Share on other sites



might change

ElseIf DirCreate($path) Then

to something like

ElseIf $path<>'' Then

DirCreate($path)

ShellExecute ($path &"\test.jpg")


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

REPLACE THIS:

$path = GUICtrlRead($Location)

WITH THIS:

_GUICtrlComboBoxEx_GetItemText ($Location, 0, $path)

In your script and you should get the results you are looking for.

Share this post


Link to post
Share on other sites

REPLACE THIS:

$path = GUICtrlRead($Location)

WITH THIS:

_GUICtrlComboBoxEx_GetItemText ($Location, 0, $path)

In your script and you should get the results you are looking for.

Hi.. I have change it`s and get message windows cannot find '2\test.jpg' i want open but why get message search file..??

Share this post


Link to post
Share on other sites

it works fine for me, make sure you have a Test.jpg in your c:\ or d:\ or make sure you type the name properly. also make sure your computer has a default program which opens jpgs, mine uses microsoft office picture manager as the default program that displays the image files on my comp.

Share this post


Link to post
Share on other sites

it works fine for me, make sure you have a Test.jpg in your c:\ or d:\ or make sure you type the name properly. also make sure your computer has a default program which opens jpgs, mine uses microsoft office picture manager as the default program that displays the image files on my comp.

Hi.. I have it for All.. But still get error..

Share this post


Link to post
Share on other sites

when I can't figure out why a program isn't working, I add a MsgBox right before a variable to see what the script sees. In your case, before the shellexicute I would add a line:

MsgBox(0,"",$path)

that will show you what is in the variable path and might help you figure out why it isn't working.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

eri,

If you read the Help file for the GuiComboBoxEx UDF, you will see that you need to retrieve the index of the selected item with _GetCurSel before you can use _GetItemText. If you replace the $path = GUICtrlRead($Location) line in you original script with:

_GUICtrlComboBoxEx_GetItemText ($Location, _GUICtrlComboBoxEx_GetCurSel($Location), $path)

you will get the selected drive in your $path variable.

Moral: do not mix the UDF functions with the built-in ones. If you use a UDF to create a control, check if you have to use the other functions within the UDF to work with it. The built-in functions will often only work with controls created by other built-in functions. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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