Spinning up a CD Cleaner automatically for a set time
Forum rules
We have no special rules for UVK forums. Just try to be polite and clear in your posts.
Please don't post spam in this forum. Spammers will be banned by IP, e-mail and username.
We reserve the right to delete all posts and ban all users we consider not having respected these rules without warning.
We have no special rules for UVK forums. Just try to be polite and clear in your posts.
Please don't post spam in this forum. Spammers will be banned by IP, e-mail and username.
We reserve the right to delete all posts and ban all users we consider not having respected these rules without warning.
Spinning up a CD Cleaner automatically for a set time
As a little "value added" service, I'm incorporating a cleaning of their oft-neglected CD drive as part of my setup and, obviously, I want to automate it. The disc basically just needs to spin for a minute to get the job done. It has audio tracks to walk you through it but, really, it just needs to spin for a bit to work.
I figured I'd use NirCMD to eject the tray to remind me to insert/remove the disc. If
So: Anyone know how to just get the drive to spin for a set period and do nothing else?
(This might be better off in Feature Requests but I can't imagine anyone else wanting this enough to merit adding a <SpinCDDrive> command into UVK.)
I figured I'd use NirCMD to eject the tray to remind me to insert/remove the disc. If
So: Anyone know how to just get the drive to spin for a set period and do nothing else?
(This might be better off in Feature Requests but I can't imagine anyone else wanting this enough to merit adding a <SpinCDDrive> command into UVK.)
-
- Posts: 1529
- Joined: Sun May 25, 2014 7:44 am
- Location: Missouri
Re: Spinning up a CD Cleaner automatically for a set time
Xander,
You might could just eject the drive a couple times by code. Each time you enter a disk it spins for a few seconds to figure out what it is. Cycling the drive tray a couple times might do what you want.
You might could just eject the drive a couple times by code. Each time you enter a disk it spins for a few seconds to figure out what it is. Cycling the drive tray a couple times might do what you want.
Jim
It is not "Can it be done?" but rather, "How can we do it?"
It is not "Can it be done?" but rather, "How can we do it?"
Re: Spinning up a CD Cleaner automatically for a set time
This works for me with an audio CD. I don't have any cleanup disk right now, but if I recall correctly they are audio CDs.
Anyway, I never thought those cleanup disks do their job. I always ended up cleaning up the laser head myself.One thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.
Fred
Fred
Re: Spinning up a CD Cleaner automatically for a set time
Wow. I certainly wasn't expecting a full script written for it. If I'd even suspected this could be done with a script, I'd have looked into it myself. (Now googling mcisendstring commands).
I'm going to see if I can adapt it into a GUI-less version to:
setaudio off (see? already learning), open CD tray, wait till it's closed, play for 30 seconds, eject/wait, setaudio on, exit.
I'm going to see if I can adapt it into a GUI-less version to:
setaudio off (see? already learning), open CD tray, wait till it's closed, play for 30 seconds, eject/wait, setaudio on, exit.
Re: Spinning up a CD Cleaner automatically for a set time
OK. That should be pretty easy. All you need is already in the script.
set cdaudio door open
sleep in chunks until "status cdaudio mode" is not "open"
play cdaudio from 1
sleep 30 secs
stop cdaudio
set cdaudio door open
Let me know if I can help with anything else.
set cdaudio door open
sleep in chunks until "status cdaudio mode" is not "open"
play cdaudio from 1
sleep 30 secs
stop cdaudio
set cdaudio door open
Let me know if I can help with anything else.
One thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.
Fred
Fred
Re: Spinning up a CD Cleaner automatically for a set time
Got it working. About the only thing I'd change would be the MsgBox -- if I'm popping the CD in manually, I'm almost certainly give the tray a bump to close it. Could it auto-detect when the tray has closed?
Code: Select all
<UVKCommandsScript>
<AutoItScript>
Global Const $__HWINMM = DllOpen('Winmm.dll')
_mciSendString('set cdaudio door open')
SoundPlay(@WindowsDir & "\Media\Windows Exclamation.wav",0) ; audio cue
Msgbox("","","Insert Cleaning CD")
If _mciSendString('status cdaudio mode') = 'open' Then _mciSendString('set cdaudio door closed')
_mciSendString('play cdaudio from 9')
Sleep(30000)
_mciSendString('stop cdaudio')
SoundPlay(@WindowsDir & "\Media\Windows Exclamation.wav",0)
_mciSendString('set cdaudio door open') ;go ahead and leave the tray open
Exit
Func _mciSendString($command)
Local $acall = DllCall($__HWINMM, 'DWORD','mciSendStringW', _
'wstr',$command, 'wstr','', 'UINT',65535, 'HANDLE',Null)
If @error Then Return SetError(1, 0, '')
If $acall[0] Then Return SetError($acall[0], 0, '')
Return $acall[2]
EndFunc ;==> _mciSendString
-
- Posts: 1529
- Joined: Sun May 25, 2014 7:44 am
- Location: Missouri
Re: Spinning up a CD Cleaner automatically for a set time
You'd have to use a timer and check for the closed state of the drive. Or, maybe the ready state.
Jim
It is not "Can it be done?" but rather, "How can we do it?"
It is not "Can it be done?" but rather, "How can we do it?"
Re: Spinning up a CD Cleaner automatically for a set time
Now with Wait-For-CD!
Fred, does the mcisendstring support a check for an empty tray? This way, if for some reason I want to skip this step, I could leave the tray empty and "if empty, Exit" ?
Code: Select all
<UVKCommandsScript>
<AutoItScript>
Global Const $__HWINMM = DllOpen('Winmm.dll')
_mciSendString('set cdaudio door open')
SoundPlay(@WindowsDir & "\Media\Windows Exclamation.wav",0) ; audio cue
While _mciSendString('status cdaudio mode') = 'open'
Sleep(2500)
Wend
If _mciSendString('status cdaudio mode') = 'open' Then _mciSendString('set cdaudio door closed')
_mciSendString('play cdaudio from 9')
Sleep(30000)
_mciSendString('stop cdaudio')
SoundPlay(@WindowsDir & "\Media\Windows Exclamation.wav",0)
_mciSendString('set cdaudio door open') ;go ahead and leave the tray open
Exit
Func _mciSendString($command)
Local $acall = DllCall($__HWINMM, 'DWORD','mciSendStringW', _
'wstr',$command, 'wstr','', 'UINT',65535, 'HANDLE',Null)
If @error Then Return SetError(1, 0, '')
If $acall[0] Then Return SetError($acall[0], 0, '')
Return $acall[2]
EndFunc ;==> _mciSendString
-
- Posts: 1529
- Joined: Sun May 25, 2014 7:44 am
- Location: Missouri
Re: Spinning up a CD Cleaner automatically for a set time
Xander I think you can use the disk ready state for that.
Jim
It is not "Can it be done?" but rather, "How can we do it?"
It is not "Can it be done?" but rather, "How can we do it?"
Re: Spinning up a CD Cleaner automatically for a set time
Hitting a dead end. Found "status cd media present" but if I push its contents to a MsgBox or to the clipboard, it comes back empty with or without a CD in the tray.
Maybe an easier option is to have it look for the Escape key while the tray is open with _IsPressed
Maybe an easier option is to have it look for the Escape key while the tray is open with _IsPressed
-
- Posts: 1529
- Joined: Sun May 25, 2014 7:44 am
- Location: Missouri
Re: Spinning up a CD Cleaner automatically for a set time
Xander
See if this is of any use....
http://stackoverflow.com/questions/1142 ... -dvd-drive
This page says status cdaudio mode returns open with the tray open OR no disk in it.
http://www.developerfusion.com/thread/5 ... or-status/
See if this is of any use....
http://stackoverflow.com/questions/1142 ... -dvd-drive
This page says status cdaudio mode returns open with the tray open OR no disk in it.
http://www.developerfusion.com/thread/5 ... or-status/
Jim
It is not "Can it be done?" but rather, "How can we do it?"
It is not "Can it be done?" but rather, "How can we do it?"
Re: Spinning up a CD Cleaner automatically for a set time
Xander, As Jim mentioned, the state returned by _mciSendString('status cdaudio mode') may not be accurate. For instance, if I close the tray without disc, it keeps returning 'open', forever.
To work around this, we can abort the operation if a disc is not inserted and the tray closed in, say, 2 minutes. We also set a timer for the case you remove the disc before the 30 seconds play time ends.
I also placed an error check for the case the disc can not be played from the specified position.
To work around this, we can abort the operation if a disc is not inserted and the tray closed in, say, 2 minutes. We also set a timer for the case you remove the disc before the 30 seconds play time ends.
I also placed an error check for the case the disc can not be played from the specified position.
One thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.
Fred
Fred
Re: Spinning up a CD Cleaner automatically for a set time
Thanks, Fred. That's a valid workaround.