Jump to content
Sign in to follow this  
bucky002

What's the code to open the cd tray?

Recommended Posts

bucky002

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
Valuater

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
bucky002

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
Valuater

what other help do you need?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
bucky002

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
cdkid

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
bucky002

Thanks I thought I tried that, but yours worked.

Thanks.

Share this post


Link to post
Share on other sites
bucky002

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
Valuater

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
bucky002

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
Valuater

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
bucky002

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
Valuater

no...

just compile it and put a shortcut in that directory

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
greenmachine

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
bucky002

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
greenmachine

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
bucky002

Alright, I'll try it.

Thanks. :"> :o

Share this post


Link to post
Share on other sites
bucky002

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
greenmachine

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
bucky002

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  

×