Jump to content

Recommended Posts

Here is my scirpt.

; ----------------------------------------------------------------------------

;

; AutoIt Version: 3.1.0

; Author: Calvin <teamgonuts@gmail.com>

;

; Script Function:

; Opens CD Tray

; Closes CD Tray

; ----------------------------------------------------------------------------

; Script Start - Add your code below here

AutoItSetOption( "TrayIconHide" , 1 )

HotKeySet ( "\" , "close" )

Func close ()

Exit

EndFunc

$m = 1

While $m = 1

HotKeySet ( "m" , "opencd" )

WEnd

Func opencd ()

CDTray ( "D:", "open" )

$m = 2

EndFunc

While $m = 2

HotKeySet ( "m" , "closecd")

WEnd

Func closecd ()

CDTray ("D:" , "close" )

$m = 1

EndFunc

While 1=1

Sleep (100)

WEnd

I hit 'm' once, the CD Tray opens.

I hit 'm' again, the CD tray closes.

I hit 'm' a third time, and instead of opening the CD tray again, nothing happens. What am I doing wrong?

Link to post
Share on other sites

Global $CDTray
HotKeySet("{ESC}", "Terminate")
HotKeySet("m", "ShowMessage")  

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    If $CDTray Then CDTray ( "d:", "close" )
    If Not $CDTray Then CDTray ( "d:", "open" )
    $CDTray = NOT $CDTray
EndFunc

Code borrowed and edited. Originally written by Valuater.

Edited by Oxin8
Link to post
Share on other sites

after the second "close" .. $m =1 and goes to the next position

While 1=1

Sleep (100) ; while you are here... nothing happens

WEnd

.............

You should not place any "creates" inside a loop

While $m = 2

HotKeySet ( "m" , "closecd")

WEnd

this sets the hot key over and over and over and....

8)

Edited by Valuater

NEWHeader1.png

Link to post
Share on other sites

after the second "close" .. $m =1 and goes to the next position

While 1=1

Sleep (100) ; while you are here... nothing happens

WEnd

.............

You should not place any "creates" inside a loop

While $m = 2

HotKeySet ( "m" , "closecd")

WEnd

this sets the hot key over and over and over and....

8)

So how can I fix this?

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...