Jump to content

What's the code to open the cd tray?


bucky002
 Share

Recommended Posts

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
Link to comment
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

Link to comment
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
Link to comment
Share on other sites

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!
Link to comment
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
Link to comment
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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...