Sign in to follow this  
Followers 0
bucky002

What's the code to open the cd tray?

33 posts in this topic

#1 ·  Posted (edited)

I Don't know how to work hot keys very well though.

I wanna have it so whenever my sister, brother etc pushes o(open cd tray) or c(close cd tray) that it will do that.

This code might help alittle.

if StringInStr ($con, "pc1") > 0 Then
Select
    Case StringInStr ($con, "opencd") > 0
    CDTray ( "d:", "open" )

        
    Case StringInStr ($con, "closecd") > 0
    CDTray ( "d:", "close" )

Thanks.

Edited by bucky002

Share this post


Link to post
Share on other sites



maybe this could help

Global $Paused, $CDTray
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "ShowMessage")  

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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

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

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Okay, thanks I'll try it later cause I gatta go.

Any more help would be appreciated.

Share this post


Link to post
Share on other sites

what other help do you need?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Can I make a letter instead of f9?

Global $Paused, $CDTray
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "ShowMessage")  

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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

change

HotKeySet("{F9}", "ShowMessage")

to

HotKeySet("a letter goes here", "ShowMessage")

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

Thanks I thought I tried that, but yours worked.

Thanks.

Share this post


Link to post
Share on other sites

How can I make this work on all users? :o

Global $Paused, $CDTray
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("e", "ShowMessage")

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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

it works with ... any user.... using it

you can also compile it into an exe file

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I want it to run on my name so I can switch user then if my sister gets on her name that if will be effective on hers.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

place it in the start-up for all users

@StartupCommonDir

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

So it should look like this?

@StartupCommonDir
Global $Paused, $CDTray
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("e", "ShowMessage")

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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

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

:o

Share this post


Link to post
Share on other sites

no...

just compile it and put a shortcut in that directory

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Replace the first line (@startupcommondir) with this:

FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\" & @ScriptName)

Actually, more specifically so it doesn't try to run the script as an au3 file:

If StringInStr (@ScriptName, ".exe") Then
    FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\" & @ScriptName)
EndIf
Edited by greenmachine

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

So this would work?

If StringInStr (@Script, ".exe") Then
    FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\" & @ScriptName)
EndIf
Global $Paused, $CDTray
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("e", "ShowMessage")

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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

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

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Looks good to me.

Almost.. got the first line a little off again.

If StringInStr (@Script, ".exe") Then
    FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\" & @ScriptName)
EndIf

Should be:

If StringInStr (@ScriptName, ".exe") Then
    FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\" & @ScriptName)
EndIf
Edited by greenmachine

Share this post


Link to post
Share on other sites

Alright, I'll try it.

Thanks. :"> :o

Share this post


Link to post
Share on other sites

Hmm.. :o

It still doesn't seem to work.

It works on mine, but not anyone elses.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Is the location of the script in a place that anyone can access?

Also, I think startup means computer startup. I could be wrong though.

Edited by greenmachine

Share this post


Link to post
Share on other sites

It's on MY Desktop. Should I put it somewhere else?

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