crazyfool Posted June 16, 2010 Share Posted June 16, 2010 (edited) hey guys, I have been using autoit for a long time to automate a number of tasks for my htpc. However the problem I'm having now is probably a very simple one for you guys but obviously not for me. I am basically trying to emulate the same action that occurs when I go to my computer and double click a disc drive with a dvd or cd in it (the cd plays in windows media player etc...) However I don't really want to have to write code to open explorer, select the disc, press enter, close explorer etc... There must be some way to do this. I have tried using the run command and pointing it to the disc drive but that didn't work. I have searched through the forums but I can't seem to find an answer. I'm hoping someone will be able to help. Thanks. Edited June 16, 2010 by crazyfool Link to comment Share on other sites More sharing options...
enaiman Posted June 16, 2010 Share Posted June 16, 2010 Run("explorer.exe c:\") SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
crazyfool Posted June 17, 2010 Author Share Posted June 17, 2010 Thanks for the reply. Unfortunately that doesn't run the disc in the same way. Instead it open explorer so you can see the disc contents(folders etc...) Any other ideas? Link to comment Share on other sites More sharing options...
GEOSoft Posted June 17, 2010 Share Posted June 17, 2010 This will do it for Audio Cds. To do the same for other formats you will have to check the registry for the strings. The RegExpressions should be the same. By the way, this only works for the first loaded drive.Opt("ExpandEnvStrings", 1) $sReg = RegRead("HKCR\AudioCD\shell\play\command", "") $sApp = StringRegExpReplace($sReg, "(?m:^|\n)\x22(.+?)\x22.+", "$1") $sParam = StringRegExpReplace($sReg, "(?m:^|\n).+?(/.+)\x22.+", "$1") $aDrives = DriveGetDrive("CDROM") For $i = 1 To Ubound($aDrives) -1 If DriveGetSerial($aDrives[$i]) Then ShellExecute($sApp, $sParam & $aDrives[$i]) Exitloop EndIf Next George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
crazyfool Posted June 17, 2010 Author Share Posted June 17, 2010 Awesome that works for a music cd. However I'm going to be using it to load blu rays for my htpc. How do I find the strings in the registry? Link to comment Share on other sites More sharing options...
GEOSoft Posted June 17, 2010 Share Posted June 17, 2010 (edited) To do it for disks that have an AutoRun.inf file (Software disks mainly) you should be able to use this. $aDrives = DriveGetDrive("CDROM") For $i = 1 To Ubound($aDrives) -1 If DriveGetSerial($aDrives[$i]) Then $sCmd = IniRead($aDrive[$i] & "\Autorun.inf", "Autorun", "Open", "") If $sCmd Then If StringLeft($sCmd, 1 = "\" Then $sCmd = StringTrimLeft($sCmd, 1) ShellExecute($aDrives[$i] & $sCmd) Exitloop EndIf EndIf Next EDIT: M23 take note, no SRE's required. Edited June 17, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted June 17, 2010 Share Posted June 17, 2010 Awesome that works for a music cd. However I'm going to be using it to load blu rays for my htpc. How do I find the strings in the registry?I have no idea. It should be available someplace. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
crazyfool Posted June 17, 2010 Author Share Posted June 17, 2010 ok I found it in the registry, I'll have a play around with it later to see if I can get it to work I got a couple of questions though: What value does drivegetdrive get? (drive letter???) Is it possible for me to specify drive? (again using drive letter???) Thanks Link to comment Share on other sites More sharing options...
GEOSoft Posted June 17, 2010 Share Posted June 17, 2010 Update. Found one more. For DVDs it's the same as for audio cds with one change Change $sReg = RegRead("HKCR\AudioCD\shell\play\command", "") To $sReg = RegRead("HKCR\dvd\shell\play\command", "") The StringRegExpReplace()calls remain the same. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted June 17, 2010 Share Posted June 17, 2010 (edited) ok I found it in the registry, I'll have a play around with it later to see if I can get it to work I got a couple of questions though: What value does drivegetdrive get? (drive letter???) Is it possible for me to specify drive? (again using drive letter???) Thanks Drive get drive returns the lower case drive letter followed by a colon( : ) You can use the actual drive letter with no problem but you won't need the loop. Opt("ExpandEnvStrings", 1) $sReg = RegRead("HKCR\AudioCD\shell\play\command", "") $sApp = StringRegExpReplace($sReg, "(?m:^|\n)\x22(.+?)\x22.+", "$1") $sParam = StringRegExpReplace($sReg, "(?m:^|\n).+?(/.+)\x22.+", "$1") $sDrive = "g:' If DriveGetSerial($sDrive) Then ShellExecute($sApp, $sParam & $sDrive) Edited June 17, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
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