Sign in to follow this  
Followers 0
Frozenyam

Register Extension

5 posts in this topic

#1 ·  Posted (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 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."

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 :whistle: I'll pass down the wisdom. :dance:

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 by layer

FootbaG

Share this post


Link to post
Share on other sites

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 :whistle: I'll pass down the wisdom. :dance:

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."

Share this post


Link to post
Share on other sites

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. :whistle:

Share this post


Link to post
Share on other sites

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. :whistle:

<{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."

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0