Jump to content
Sign in to follow this  
bobheart

combobox

Recommended Posts

bobheart

never mind for now . :ph34r:

Edited by bobheart

Share this post


Link to post
Share on other sites
CyberSlug

Two lines of code would go where you have the MsgBox(4096,"","You chose"

GUISetControlData($combo_1, $var) ;add data to list

GuiWrite($combo_1, 0, $var) ;optional--make new entry appear as selected item in combo


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
bobheart

Like this ?

#cs - ### Generated by AutoBuilder 0.4 -- do not modify ###
440 39
0201000000000000    
combo   $combo_1    Combo 1 10  10  260 20  0   0   
button  $button_1   Button 1    280 10  70  20  0   0   
button  $button_2   Button 2    360 10  60  20  0   0   
#ce - ### End of Dump ###

;Script generated by AutoBuilder 0.4


Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 438,34,(@DesktopWidth-438)/2, (@DesktopHeight-34)/2 , 0x04CF0000)

$combo_1 = GUISetControl("combo", "Combo 1", 10, 10, 260, 20)
$button_1 = GUISetControl("button", "Go", 280, 10, 70, 20)
$button_2 = GUISetControl("button", "Add", 360, 10, 60, 20)

GuiShow()

While 1
    sleep(100)
    $msg = GuiMsg(0)
    Select
    Case $msg = -3
        Exit
    Case $msg = 2
      ;;;
    Case $msg = $combo_1
     IniRead("C:\tray-app.ini", "section2", "key", "NotFound")
GUISetControlData($combo_1, $var);add data to list
GuiWrite($combo_1, 0, $var)
;;
Case $msg = $button_1
        IniWrite("C:\tray-app.ini", "section2", "key", "this is a new value")

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

$var = FileOpenDialog($message, "C:\", "Images (*.exe)", 1 + 4 )

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

Thinking on making a little app that will hold program links and be able to add to the list .

So can click on the name in the combobox then click go to start the app .

Edited by bobheart

Share this post


Link to post
Share on other sites
bobheart

Stiill not reading from file ?

#cs - ### Generated by AutoBuilder 0.4 -- do not modify ###
440 39
0201000000000000    
combo   $combo_1    Combo 1 10  10  260 20  0   0   
button  $button_1   Button 1    280 10  70  20  0   0   
button  $button_2   Button 2    360 10  60  20  0   0   
#ce - ### End of Dump ###

;Script generated by AutoBuilder 0.4


Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 438,34,(@DesktopWidth-438)/2, (@DesktopHeight-34)/2 , 0x04CF0000)

$combo_1 = GUISetControl("combo", "", 10, 10, 260, 20)
$button_1 = GUISetControl("button", "Go", 280, 10, 70, 20)
$button_2 = GUISetControl("button", "Add", 360, 10, 60, 20)

GuiShow()

While 1
    sleep(100)
    $msg = GuiMsg(0)
    Select
    Case $msg = -3
        Exit
    Case $msg = 2
       ;;;
     Case $msg = $combo_1
        $file = FileOpen("marquee.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
   $combo_1(0, "Error", "Unable to open file.")
    Exit
EndIf
     $chars = FileRead($file, 30)
     If @error = -1 Then ExitLoop
MsgBox(0, "Char read:", $chars)
;;
Case $msg = $button_1
      

    Case $msg = $button_2
       $file = "Select a program file."

$var = FileOpenDialog($file, "C:\", "exe (*.exe)", 1 + 4 )

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

Share this post


Link to post
Share on other sites
bobheart

What part of the traybar do you mean?

<{POST_SNAPBACK}>

I just want a simple toolbar that I can load programs to and click on it and have it run .like a drop down combo box . nothing fancy ..

click a button and add a link to the file so it will be listed in the dropdown .

Share this post


Link to post
Share on other sites
bobheart

Ya you can see it in my middle post with code and it didn't work .

#cs - ### Generated by AutoBuilder 0.4 -- do not modify ###
440 39
0201000000000000    
combo   $combo_1    Combo 1 10  10  260 20  0   0   
button  $button_1   Button 1    280 10  70  20  0   0   
button  $button_2   Button 2    360 10  60  20  0   0   
#ce - ### End of Dump ###

;Script generated by AutoBuilder 0.4


Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 438,34,(@DesktopWidth-438)/2, (@DesktopHeight-34)/2 , 0x04CF0000)

$combo_1 = GUISetControl("combo", "Combo 1", 10, 10, 260, 20)
$button_1 = GUISetControl("button", "Go", 280, 10, 70, 20)
$button_2 = GUISetControl("button", "Add", 360, 10, 60, 20)

GuiShow()

While 1
    sleep(100)
    $msg = GuiMsg(0)
    Select
    Case $msg = -3
        Exit
    Case $msg = 2
     ;;;
    Case $msg = $combo_1
     IniRead("C:\tray-app.ini", "section2", "key", "NotFound")
GUISetControlData($combo_1, $var);add data to list
GuiWrite($combo_1, 0, $var)
;;
Case $msg = $button_1
        IniWrite("C:\tray-app.ini", "section2", "key", "this is a new value")

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

$var = FileOpenDialog($message, "C:\", "Images (*.exe)", 1 + 4 )

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

Share this post


Link to post
Share on other sites
Holger

Try this:

Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)
Opt("TrayIconDebug",1)
GuiCreate("MyGUI", 438, 34,(@DesktopWidth-438)/2, (@DesktopHeight-34)/2, 0x04CF0000)

$combo_1 = GUISetControl("combo", "Combo 1", 10, 10, 260, 20)
$button_1 = GUISetControl("button", "Go", 280, 10, 70, 20)
$button_2 = GUISetControl("button", "Add", 360, 10, 60, 20)

$i = 1
$file = ""
$defaultvalue = ""

If FileExists("C:\tray-app.ini") Then
   While 1
      $inivalue = IniRead("C:\tray-app.ini","Application","App" & $i,"")
      If $inivalue = "" Then ExitLoop
      If $i = 1 Then $defaultvalue = $inivalue
      $file = $file & $inivalue & "|"
      $i = $i + 1
   WEnd
   GUISetControlData($combo_1,$file,$defaultvalue)
EndIf
$maxi = $i - 1

GuiShow()

While 1
   $msg = GuiMsg()
   Select
      Case $msg = -3
         Exit

      Case $msg = $combo_1
       ;;;
 
      Case $msg = $button_1
         If GUIRead($combo_1) <> "" Then    
            Run(GUIRead($combo_1))
         EndIf
            
      Case $msg = $button_2
         $message = "Hold down Ctrl or Shift to choose multiple files."
         $file = FileOpenDialog($message, "C:\", "Images (*.exe)", 1 + 4 )
         If @error = 0 Then
            If StringInStr($file,"|") > 0 Then; multiple files selected
            $splitfile = StringSplit($file,"|")
            For $i = 2 To $splitfile[0]; 2 = folder, 3 = file1, 4 = file2 ...
               $file = $splitfile[1] & "\" & $splitfile[$i]
               If FileCheck($file) = 0 Then; check if the entry is already in the list
                  GUISetControlData($combo_1, $file);add data to list
                  GuiWrite($combo_1, 0, $file)
                  $maxi = $maxi + 1
                  IniWrite("C:\tray-app.ini","Application","App" & $maxi,$file)
               EndIf
            Next
         Else
            If FileCheck($file) = 0 Then; check if the entry is already in the list
               GUISetControlData($combo_1, $file);add data to list
               GuiWrite($combo_1, 0, $file)
               $maxi = $maxi + 1
               IniWrite("C:\tray-app.ini","Application","App" & $maxi,$file)
            EndIf
         EndIf
      EndIf
    EndSelect
WEnd

Exit

Func FileCheck($file)
   Local $i, $file
   $i = 1
   $found = 0
   If FileExists("C:\tray-app.ini") Then
      While 1
         $inivalue = IniRead("C:\tray-app.ini","Application","App" & $i,"")
         If $inivalue <> "" Then ExitLoop
         If $inivalue = $file Then
            $found = 1
            ExitLoop
         EndIf
         $i = $i + 1
      WEnd
   EndIf
   Return $found
EndFunc

Regards Holger

Edited by Holger

Share this post


Link to post
Share on other sites
bobheart

No errors but still not reading the ini file . and it is in the c drive .

As you can see nothing in the combo box

Share this post


Link to post
Share on other sites
Holger

Yeahhh, maybe...

1.) I changed it a little bit half an hour ago - please take a look at the trayicon, maybe it hangs/is waiting infinite in a "while-loop"

2.) please rename your old ini-file, cause the new would be like this:

[Application]
App1=C:\WINDOWS\regedit.exe
App2=C:\WINDOWS\NOTEPAD.EXE
App3=C:\WINDOWS\system32\mspaint.exe

3.) what autoit-version do you use?

Edited by Holger

Share this post


Link to post
Share on other sites
bobheart

I use 3, 0, 102, 0 unstable .

I'll check again .

Share this post


Link to post
Share on other sites
bobheart

I renamed it and it works now thank you .,

Share this post


Link to post
Share on other sites
mcfr1es

it would be much easier to just use toolbars in windows xp

just make a folder full of shorcuts to your favourite programs, then right click on your taskbar, choose new toolbar and select your folder with the shortcuts and voila.

u can further organize the folder by adding subfolders..

u might wanna ignore that folder...

btw, all the programs shown on that toolbar were bought with my hard earned money ... stealing is bad, dont download from the internet :ph34r:

Edited by mcfr1es

Roger! You son of a big pile o' Monkey Nuts.

Share this post


Link to post
Share on other sites
bobheart

I know you mean well but you don't know I dont have a windows tool bar .I have no icons on my desktop . I use BlackBox Shell for my windows OS and not explore so I have no tool bar to do what you want me to do .

Share this post


Link to post
Share on other sites
bobheart

Right now it shows all of the line of the exe path and i would just like it to show maybe the app name and the exe .

I have looked at the code for two days now and still not sure how to make it do that . could someone help me with this .

GUICoordMode", 1)
Opt("GUINotifyMode", 1)
Opt("TrayIconDebug",0)
GuiCreate("Run It", 360, 95,(@DesktopWidth-438)/2, (@DesktopHeight-34)/2, 0x04CF0000)
Opt("TrayIconHide", 0) 
$combo_1 = GUISetControl("combo", "Combo 1", 10, 10, 260, 20)
$button_1 = GUISetControl("button", "Go", 280, 10, 70, 20)
$button_2 = GUISetControl("button", "Add", 280, 30, 70, 20)
$button_3 = GUISetControl("button", "Edit", 280, 50, 70, 20)
$pic_1 = GUISetControl("pic", "runit.jpg", 20, 35, 343, 30)
$i = 1
$file = ""
$defaultvalue = ""

If FileExists("C:\tray-app.bak") Then
   While 1
      $inivalue = IniRead("C:\tray-app.bak","Application","App" & $i,"")
      If $inivalue = "" Then ExitLoop
      If $i = 1 Then $defaultvalue = $inivalue
      $file = $file & $inivalue & "|"
      $i = $i + 1
   WEnd
   GUISetControlData($combo_1,$file,$defaultvalue)
EndIf
$maxi = $i - 1

GuiShow()

While 1
   $msg = GuiMsg()
   Select
      Case $msg = -3
         Exit

      Case $msg = $combo_1
     ;;;

      Case $msg = $button_1
         If GUIRead($combo_1) <> "" Then    
            Run(GUIRead($combo_1))
         EndIf
            
      Case $msg = $button_2
         $message = "Hold down Ctrl or Shift to choose multiple files."
         $file = FileOpenDialog($message, "C:\", "files (*.exe;*.bat;*.com;*.*)", 1 + 4 )
         If @error = 0 Then
            If StringInStr($file,"|") > 0 Then; multiple files selected
            $splitfile = StringSplit($file,"|")
            For $i = 2 To $splitfile[0]; 2 = folder, 3 = file1, 4 = file2 ...
               $file = $splitfile[1] & "\" & $splitfile[$i]
               If FileCheck($file) = 0 Then; check if the entry is already in the list
                  GUISetControlData($combo_1, $file);add data to list
                  GuiWrite($combo_1, 0, $file)
                  $maxi = $maxi + 1
                  IniWrite("C:\tray-app.bak","Application","App" & $maxi,$file)
               EndIf
            Next
         Else
            If FileCheck($file) = 0 Then; check if the entry is already in the list
               GUISetControlData($combo_1, $file);add data to list
               GuiWrite($combo_1, 0, $file)
               $maxi = $maxi + 1
               IniWrite("C:\tray-app.bak","Application","App" & $maxi,$file)
            EndIf
         EndIf
      EndIf
   Case $msg = $button_3
      run("MyEdit.exe")
    ;;
       Case $msg = $pic_1
    EndSelect
WEnd

Exit

Func FileCheck($file)
   Local $i, $file
   $i = 1
   $found = 0
   If FileExists("C:\tray-app.bak") Then
      While 1
         $inivalue = IniRead("C:\tray-app.bak","Application","App" & $i,"")
         If $inivalue <> "" Then ExitLoop
         If $inivalue = $file Then
            $found = 1
            ExitLoop
         EndIf
         $i = $i + 1
      WEnd
   EndIf
   Return $found
EndFunc

I changed the ini file to a bak file do to the limit on file size with ini and it still works that way .

But can be changed if need to make it work like I want .

Thank you for any help with this .

Edited by bobheart

Share this post


Link to post
Share on other sites
bobheart

*********bumb**********

Share this post


Link to post
Share on other sites
Holger

@bob: I use an ini like this:

[Application]
Application1=C:\Windows\Notepad.exe
Desc1=Notepad

in my script then I use a function to read the parameters to an array before I fill the combobox with it:

...
Global $apparr[51][2]; -> max. 50 apps
...
IniToArray()
For $idx = 1 To $apparr[0][0]
   If $idx = 1 Then $combodefault = $apparr[$idx][1]
   $combolist = $combolist & $apparr[$idx][1] & "|"
Next
...
; now the combo-creation
$combo = GUISetControl("combo","",15,25,210,20,$CBS_DROPDOWNLIST)
GUISetControlData(-1,$combolist,$combodefault)
...
Exit
...
Func IniToArray()
   Local $idx = 1
   $apparr[0][0] = 0
   While 1
      $app = IniRead($setupini,"Application","Application" & $idx,"")
      $desc = IniRead($setupini,"Application","Desc" & $idx,"")
      If $app = "" Then ExitLoop
      $apparr[0][0] = $idx
      $apparr[0][1] = $idx
      $apparr[$idx][0] = $app
      $apparr[$idx][1] = $desc
      $idx = $idx + 1
   WEnd
EndFunc

Hope that helps you a little bit.

Regards Holger :ph34r:

Edited by Holger

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.