Sign in to follow this  
Followers 0
slightly_abnormal

Open Close Cd/dvd Tray Toggle

4 posts in this topic

How can I get this to toggle open of CD/dvd tray??

while 1
sleep(1)
wend

Func _cdtraye()
     CDTray ( "e:", "open" )
    sleep(4000)
      CDTray ( "e:", "closed" )
EndFunc

Func _cdtrayd()
     CDTray ( "d:", "open" )
    sleep(4000)
      CDTray ( "d:", "closed" )
EndFunc

#notrayicon
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode",1)
$CDTraye_tray = TrayCreateItem("Open/Close CD Tray")
TrayItemSetOnEvent($Cdtraye_tray,"_CDtraye")
$CDTrayd_tray = TrayCreateItem("Open/Close DVD Tray")
TrayItemSetOnEvent($Cdtrayd_tray,"_CDtrayd")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think that would be:

Global $f="closed"

Func _ToggleCDTray()
While 1
If $f="closed" Then
$open=CDTray ( "e:", "open" )
If $open=1 Then $f="open"
Exitloop
EndIf
If $f="open" Then
$close=CDTray ( "e:", "close" )
If $close=1 Then $f="closed"
Exitloop
EndIf
WEnd
EndFunc

EDIT: Typo

That should work, I hope...

Sparkes.

Edited by Andrew Sparkes

---Sparkes.

Share this post


Link to post
Share on other sites

Thanks!!

Share this post


Link to post
Share on other sites

I think that would be:

Global $f="closed"

Func _ToggleCDTray()
While 1
If $f="closed" Then
$open=CDTray ( "e:", "open" )
If $open=1 Then $f="open"
Exitloop
EndIf
If $f="open" Then
$close=CDTray ( "e:", "close" )
If $close=1 Then $f="closed"
Exitloop
EndIf
WEnd
EndFunc

EDIT: Typo

That should work, I hope...

Sparkes.

@ Sparkes, I just ran across that same issue you just pointed out of having the status predefined then taking action on the CDtray. Nice work! :mellow:

Cheers.. :)

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