OiMunk Posted February 11, 2008 Share Posted February 11, 2008 I'm trying to write a script that will automate WinRAR, but I'd like the Script to launch automatically when I click on a .rar file and then process that file. Ideally, Windows will use MyAU3WinRar.exe as the default for opening .rar file types, but I don't know if this is possible, since MyAU3WinRar.exe isn't actually a decompression program, but will itself launch WinRAR... Is there a way to pass the name of the file opened to my script? Any help starting out is much appreciated, cheers Link to comment Share on other sites More sharing options...
JustinReno Posted February 11, 2008 Share Posted February 11, 2008 This really isn't an AutoIt question but... You could use (Search for this!) the _FileRegister UDF here on the forums to register .rar files to your executable. But its slightly tricky. Or, you could check to see if WinRAR is active using If WinActive, close WinRar, and open your script. Link to comment Share on other sites More sharing options...
Div Posted February 11, 2008 Share Posted February 11, 2008 (edited) I'm trying to write a script that will automate WinRAR, but I'd like the Script to launch automatically when I click on a .rar file and then process that file. Ideally, Windows will use MyAU3WinRar.exe as the default for opening .rar file types, but I don't know if this is possible, since MyAU3WinRar.exe isn't actually a decompression program, but will itself launch WinRAR... Is there a way to pass the name of the file opened to my script?Any help starting out is much appreciated,cheersGo into your control panel and click on Default Programs....change the default opening files type to your AutoIT program. There is a way to pass the file information from your script to WinRar. Goto the online documentation on AutoIT and read the File functions.VR,Div Edited February 11, 2008 by Div Link to comment Share on other sites More sharing options...
BrettF Posted February 11, 2008 Share Posted February 11, 2008 Change the registry entries. Open Regedit, navigate to HKCR\.rar and see what you can see... Probaly would be under run, just change the default path, export them, and your script can do it using the native registry functions. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
OiMunk Posted February 12, 2008 Author Share Posted February 12, 2008 Thanks for the replies, I might be a little over my head with this one. Bert: this is very interesting, though I'm not clear on how to get the file name of the .rar into my script. RegRead() is easy enough to use, but I'm not sure which key to read or use. Here's a few that looked promising, but I probably need to add some flags or something. I'll have to do a lot of research on the registry... HKEY_CLASSES_ROOT\.rar "C:\Program Files\WinRAR\MyAU3WinRar.exe" "%1" HKEY_CLASSES_ROOT\Applications\MyAU3WinRar.exe\shell\open\command "C:\Program Files\WinRAR\MyAU3WinRar.exe" "%1" HKEY_CLASSES_ROOT\Applications\WinRAR.exe HKEY_CLASSES_ROOT\WinRAR\shell\open\command "C:\Program Files\WinRAR\MyAU3WinRar.exe" "%1" Div: the problem is that the script doesn't know which file launched it, I don't need to send data from the script to WinRAR (other than ControlSends, which is easy). Every time I launch the script, it's going to be a different .rar file. Justin: I tried searching for _FileRegister , but it doesn't exist on the forums or on google. WinWaitActive is the easy way, but I need to minimize running processes, so something more elegant is in order. Link to comment Share on other sites More sharing options...
BrettF Posted February 12, 2008 Share Posted February 12, 2008 (edited) I am in the process of creating a File Register/Associate UDF, but it will be months before it sticks it's head out. Way too long till I get it finished. But for now: $key = "HKEY_CLASSES_ROOT\WinRAR" $shelloption = "automate" $shellcommand = '"D:\My Documents\MyProgram.exe "%1' $shellname = "Automate WinRAR" RegWrite ($key & "\Shell\" & $shelloption, "", "REG_SZ", $shellname) RegWrite ($key & "\Shell\" & $shelloption & "\command", "", "REG_SZ", $shellcommand) That will add Automate WinRAR to the context menu of a RAR file, still more to come on .zip and the like... Edit: Here you go! Done! $key = "HKEY_CLASSES_ROOT\WinRAR.ZIP" $shelloption = "automate" $shellcommand = '"D:\My Documents\MyProgram.exe "%1' $shellname = "Automate WinRAR" RegWrite ($key & "\Shell\" & $shelloption, "", "REG_SZ", $shellname) RegWrite ($key & "\Shell\" & $shelloption & "\command", "", "REG_SZ", $shellcommand) $key = "HKEY_CLASSES_ROOT\WinRAR.REV" $shelloption = "automate" $shellcommand = '"D:\My Documents\MyProgram.exe "%1' $shellname = "Automate WinRAR" RegWrite ($key & "\Shell\" & $shelloption, "", "REG_SZ", $shellname) RegWrite ($key & "\Shell\" & $shelloption & "\command", "", "REG_SZ", $shellcommand) Edited February 12, 2008 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
OiMunk Posted February 12, 2008 Author Share Posted February 12, 2008 Those work nicely, I'll definitely use that for some of my apps. I'm still hoping someone knows how to pass the filename of a clicked file to my script. When my script launches WinRAR to decompress, it needs to know what file triggered everything. Maybe because my script launches AFTER the .rar that triggered the script, there's no way to retroactively get this information. I tried accessing HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU but this gets the most recent dialog, not the most recent file. Alas. Link to comment Share on other sites More sharing options...
BrettF Posted February 13, 2008 Share Posted February 13, 2008 Those work nicely, I'll definitely use that for some of my apps.I'm still hoping someone knows how to pass the filename of a clicked file to my script. When my script launches WinRAR to decompress, it needs to know what file triggered everything. Maybe because my script launches AFTER the .rar that triggered the script, there's no way to retroactively get this information.I tried accessing HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU but this gets the most recent dialog, not the most recent file. Alas.As you can see, in the above examples. there is a "%1". That is the file being launched. Now, just use command line params to open your script (Look in the helpfile. ) Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
OiMunk Posted February 14, 2008 Author Share Posted February 14, 2008 (edited) your patience is appreciated that's the detail I was missing, cheers Edited February 14, 2008 by OiMunk Link to comment Share on other sites More sharing options...
TurionAltec Posted February 14, 2008 Share Posted February 14, 2008 Depending on what you're doing with your RAR files (I assume you're going after something fairly simple like just decompressing it into a folder) look at the commandline rar.exe in your WinRAR folder. It might be quicker to pass options directly to it then through the GUI. Link to comment Share on other sites More sharing options...
OiMunk Posted February 16, 2008 Author Share Posted February 16, 2008 Good idea. For the moment, I need the GUI because the script does different things depending on what it 'sees' with PixelGetColor() 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