jzn2 Posted September 21, 2006 Posted September 21, 2006 (edited) I have been working on a script that would support multiple drive hotkey for open and close functions... However i ran into a problem and dont quite understand the language... Some help would be apreciated.. Here is the code: Optical_Drive_Open_close_hotkeys.au3 ; Place at the top of your script ; Allows only one instance of this script $g_szVersion = "CD Hotkey B1" If WinExists($g_szVersion) Then Exit ; It's already running AutoItWinSetTitle($g_szVersion) ; Rest of your script goes here Select Case HotKeySet("^!1") then ;CTRL+ALT+1 $d = DriveGetDrive("CDROM"); close all optical drives For $x = 1 to $d[0] CDTray($d[$x],"close") EndIf Next Case HotKeySet("^!2") then ;CTRL+ALT+2 $d = DriveGetDrive("CDROM"); Open all Optical Drives For $x = 1 to $d[0] CDTray($d[$x],"open") EndIf Next Case HotKeySet("^!3") then ;CTRL+ALT+3 $d = DriveGetDrive("CDROM") For $x = 1 to $d[0]; Open all Optical Drives if DriveStatus($d[$x]) = "NOTREADY" then $test = CDTray($d[$x],"open") EndIf Next For $x = 1 to $d[0]; close all optical drives if DriveStatus($d[$x]) = "NOTREADY" then $test = CDTray($d[$x],"close") EndIf Next Case HotKeySet("^!4") then ;CTRL+ALT+4 CDTray("F:", "open"); Open the CD tray on drive F: EndIf [edit] this is a non functioning example. Working example below [/edit] Edited April 7, 2008 by jzn2
jvanegmond Posted September 21, 2006 Posted September 21, 2006 (edited) Case HotKeySet("^!1") then ;CTRL+ALT+1That's is the strangest case of HotKeySet I have seen ever!You probably want to take another look at HotKeySet in the helpfile. Edited September 21, 2006 by Manadar github.com/jvanegmond
jzn2 Posted September 22, 2006 Author Posted September 22, 2006 (edited) Your right that helped alot! Thanks! Edited September 22, 2006 by jzn2
jzn2 Posted September 22, 2006 Author Posted September 22, 2006 Here we go This works alot better! maybe i should move this to scripts and scraps section expandcollapse popup; Place at the top of your script ; Allows only one instance of this script $g_szVersion = "CD Hotkey B2" If WinExists($g_szVersion) Then Exit ; It's already running AutoItWinSetTitle($g_szVersion) ; Rest of your script goes here Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("+{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d HotKeySet("^!1", "AllClose") ;CTRL+ALT+1 HotKeySet("^!2", "AllOpen") ;CTRL+ALT+2 HotKeySet("^!3", "AllTest") ;CTRL+ALT+3 HotKeySet("^!4", "FClose") ;CTRL+ALT+4 ;sleep 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() MsgBox(4096,"","This is a message.") EndFunc Func AllClose() $d = DriveGetDrive("CDROM") ; close all optical drives For $x = 1 to $d[0] CDTray($d[$x],"close") Next EndFunc Func AllOpen() $d = DriveGetDrive("CDROM") ; Open all Optical Drives For $x = 1 to $d[0] CDTray($d[$x],"open") Next EndFunc Func AllTest() $d = DriveGetDrive("CDROM") For $x = 1 to $d[0] ; Open all Optical Drives if DriveStatus($d[$x]) = "NOTREADY" then $test = CDTray($d[$x],"open") EndIf Next For $x = 1 to $d[0] ; close all optical drives if DriveStatus($d[$x]) = "NOTREADY" then $test = CDTray($d[$x],"close") EndIf Next EndFunc Func FClose() CDTray("F:", "open") ; Open the CD tray on drive F: EndFunc
jzn2 Posted September 28, 2006 Author Posted September 28, 2006 Is there another way to refer to a specific cd drive without calling the drive letter?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now