Frozenyam Posted August 21, 2005 Share Posted August 21, 2005 (edited) A little UDF to register the extension of your choice and set it to open with notepad. If anyone could improve upon this it would be good. I know it's not the best piece of code. #Include-Once Func _RegExt (ByRef $s_FileExt) Local $v_ExtInUse Opt ("WinWaitDelay", 0) Run ("explorer.exe", "", @SW_HIDE) Sleep (500) Send ("!to") WinSetState ("Folder Options", "", @SW_HIDE) Send ("+{TAB}{RIGHT}{RIGHT}") Sleep (1000) Send ("!n") WinSetState ("Create New Extension", "", @SW_HIDE) Send ($s_FileExt) Send ("{ENTER}") $v_ExtInUse = WinExists ("Extension is in use") If $v_ExtInUse = 1 Then Exit(0) EndIf Sleep (1000) Send ("!v") WinSetState ("Edit File Type", "", @SW_HIDE) Send ("!i") WinSetState ("Change Icon", "", @SW_HIDE) Send ("{TAB}{TAB}{DOWN}{DOWN}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{ENTER}!n") WinSetState ("New Action", "", @SW_HIDE) Send ("open{TAB}notepad.exe{ENTER}{ENTER}!{F4}!{F4}") EndFunc Example: #Include <_RegExt.au3> $Var = ".ref" _RegExt ($Var) If you input an extension that already exists it will prompt you asking whether you want to overwrite the extension or cancel. Cancelling will close the script, and overwriting will... well... overwrite the extension._RegExt.au3 Edited August 21, 2005 by Frozenyam "... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster." Link to comment Share on other sites More sharing options...
layer Posted August 21, 2005 Share Posted August 21, 2005 (edited) There is an easier way. RegWrite. I think these are the keys you will need to write to. This code was written by Larry, when he helped me how to register a file extension I'll pass down the wisdom. example... creating a ".qqq" file and assoc with Notepad...RegWrite("HKCR\.qqq","","REG_SZ","qqq") RegWrite ("HKCR\.qqq\ShellNew\") RegWrite('HKCR\qqqfile\Shell\Open\Command','','REG_SZ','"notepad.exe" "%1"') Edited August 21, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
Frozenyam Posted August 21, 2005 Author Share Posted August 21, 2005 There is an easier way. RegWrite. I think these are the keys you will need to write to. This code was written by Larry, when he helped me how to register a file extension I'll pass down the wisdom. RegWrite("HKCR\.qqq","","REG_SZ","qqq") RegWrite ("HKCR\.qqq\ShellNew\") RegWrite('HKCR\qqqfile\Shell\Open\Command','','REG_SZ','"notepad.exe" "%1"')<{POST_SNAPBACK}>That's true that that works as well. But it also seems to create not needed registry keys. "... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster." Link to comment Share on other sites More sharing options...
therks Posted August 21, 2005 Share Posted August 21, 2005 Actually it probably creates just as many (if not less) registry keys than your method does. Your method just takes a potentially hazardous tour through the Explorer GUI, and as such it takes longer. Just give it a try, go through your function, then have a look and see just what registry keys it creates and how long it takes. Then try layer's. I think you'll be surprised. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Frozenyam Posted August 22, 2005 Author Share Posted August 22, 2005 Actually it probably creates just as many (if not less) registry keys than your method does. Your method just takes a potentially hazardous tour through the Explorer GUI, and as such it takes longer.Just give it a try, go through your function, then have a look and see just what registry keys it creates and how long it takes. Then try layer's. I think you'll be surprised. <{POST_SNAPBACK}>Both create the same keys, however, I completely revamped the entire things and it got put as a new topic in the forum. "... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster." 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