Sign in to follow this  
Followers 0
imani

Need Help with CD Tray App

2 posts in this topic

See the Code and tell me how to get more drives. Because the GUICtrlSetData shows only one drive but I have three.

#include <GuiConstants.au3>
#NoTrayIcon
Opt("GUIOnEventMode", 1)
GuiCreate("CDTray Eject OR Close", 240, 100,-1, -1 )
GUIsetIcon(@SystemDir & "\shell32.dll", 12)
Global $cdd,$i,$a1

$eject = GuiCtrlCreateButton("Eject", 10, 20, 70, 20)
GUICtrlSetOnEvent($eject, "eject")
$close = GuiCtrlCreateButton("Close", 100, 20, 70, 20)
GUICtrlSetOnEvent($close, "close")
$cdd = DriveGetDrive("CDROM")
For $i=1 to $cdd[0]
$default = GUICtrlCreateCombo($cdd[1], 50, 60, 100, 20)
GUICtrlSetData($default,$cdd[$i],$cdd[1]) 
Next

;GUICtrlSetOnEvent($default,"defualt")
GuiSetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
While 1
    $read = GUICtrlRead($default)
    Sleep(10)
Wend
func eject()
;$a1 = String($read)
    CDTray($read,"open")
EndFunc
Func close()
    CDTray($read,"close")
EndFunc
Func defualt()
        EndFunc
Func SpecialEvents()  
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit            
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE          
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE           
    EndSelect   
EndFunc

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>
#NoTrayIcon
Opt("GUIOnEventMode", 1)
GuiCreate("CDTray Eject OR Close", 240, 100,-1, -1 )
GUIsetIcon(@SystemDir & "\shell32.dll", 12)
Global $cdd,$i,$a1

$eject = GuiCtrlCreateButton("Eject", 10, 20, 70, 20)
GUICtrlSetOnEvent($eject, "eject")
$close = GuiCtrlCreateButton("Close", 100, 20, 70, 20)
GUICtrlSetOnEvent($close, "close")
$cdd = DriveGetDrive("CDROM")
$default = GUICtrlCreateCombo($cdd[1], 50, 60, 100, 20)

For $i=1 to $cdd[0]
GUICtrlSetData($default,$cdd[$i],$cdd[1])
Next

;GUICtrlSetOnEvent($default,"defualt")
GuiSetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
While 1
    $read = GUICtrlRead($default)
    Sleep(10)
Wend
func eject()
;$a1 = String($read)
    CDTray($read,"open")
EndFunc
Func close()
    CDTray($read,"close")
EndFunc
Func defualt()
        EndFunc
Func SpecialEvents()  
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit            
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE          
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE           
    EndSelect   
EndFunc
In your for next loop you created as many combo boxes as you had drives, each with only it's own name. I took out the createcombo() and and placed it two lines up. It works now... :)

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

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