Copy Extra's: For Win Explorer Context Menu

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
megnatar
Posts: 92
Joined: 27 Oct 2014, 20:49
Location: The Netherlands
Contact:

Copy Extra's: For Win Explorer Context Menu

15 Feb 2019, 14:26

If often find myself in need to copying some file or folder name/location.
Unfortunate windows offers no functionality from the shell for copying names and locations.
Actually the way you need to do that is rather clumsy.

So here is a simple script I wrote that will add a cascading menu option "Copy Extra's" to Windows explorer context menu.

For all type of files:
  • Copy File Name and Path
  • Copy File Name and Path Quoted
  • Copy Path To File
  • Copy File Name
  • Copy File Name and Extension

For all files registered as type Text, Document, RegFiles and AutoHotkeyScript:
  • Copy File Name and Path
  • Copy File Name and Path Quoted
  • Copy Path To File
  • Copy File Name
  • Copy File Name and Extension
  • Copy File Content

For Directory's:
  • Copy Folder Path
  • Copy Folder Path Quoted
  • Copy Folder Name
Install script:
Use below script to add the "Copy Extra's" option to Windows Explorer context menu.
Run the script to add the feature to Windows.
To remove the feature, run the script again!
Confirmation is required for both add and remove.

Code: Select all

#NoEnv
#NoTrayIcon
SetBatchLines -1

if (!A_IsAdmin)
    RunAsAdmin()

if (!FileExist(A_WinDir "\CopyExtra's.exe"))
{
    MsgBox, 0x21, Add: Copy Extra's, Add "Copy Extra's" to Windows context menu?
    IfMsgBox Cancel
        ExitApp
    MsgBox,,Copy Extra's, % AddScript()
} else {
    MsgBox, 0x21, Remove: Copy Extra's, Remove "Copy Extra's" from Windows context menu?
    IfMsgBox Cancel
        ExitApp
    MsgBox,,Copy Extra's, % AddScript(1)
}
exitapp

RunAsAdmin() {
    if (!A_IsCompiled) {
        Run, *RunAs "%A_AhkPath%" /ErrorStdOut "%A_ScriptFullPath%"
    } else {
        Run, *RunAs "%A_ScriptFullPath%"
    }
    ExitApp
}

AddScript(rm=0) {
    Static Script, RegKeys
    Script =
    (
    #NoEnv`n#NoTrayIcon`nSetBatchLines -1`nLoop `% A_Args.Length() {`nIf (A_index = A_Args.Length()){`nIf (A_Args[A_Index] = "/cp1")`nClipboard = `%F`%`nelse If (A_Args[A_Index] = "/cp2")`nClipboard = "`%F`%"`nelse If (A_Args[A_Index] = "/cp3")`nClipboard := SubStr(F,1,InStr(F,"\",,0,1))`nelse If (A_Args[A_Index] = "/cp4")`nClipboard := SubStr(SubStr(F, InStr(F,"\",,0,1)+1),1,InStr(SubStr(F, InStr(F,"\",,0,1)+1),".",,0,1)-1)`nelse If (A_Args[A_Index] = "/cp5")`nClipboard := SubStr(F,InStr(F,"\",,0,1)+1)`nelse If (A_Args[A_Index] = "/cp6")`nClipboard := FileOpen(F,0).read()`nelse If (A_Args[A_Index] = "/cp7")`nClipboard := RTrim(F)`nelse If (A_Args[A_Index] = "/cp8")`nClipboard := """" RTrim(F) """"`nelse If (A_Args[A_Index] = "/cp9")`nClipboard := RTrim(SubStr(F,InStr(F,"\",,0,1)+1))`n}`nF .= A_Args[A_Index] " "`n}`nExitApp
    )
    RegKeys =
    (
    REG_SZ|HKCR\*\shell\CopyExtra's|MUIVerb|Copy Extra's`nREG_SZ|HKCR\*\shell\CopyExtra's|Position|bottom`nREG_SZ|HKCR\*\shell\CopyExtra's|SubCommands`nREG_SZ|HKCR\*\shell\CopyExtra's|NoWorkingDirectory`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\1: Copy File Name and Path||Copy File Name and Path`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\1: Copy File Name and Path|icon|Shell32.dll,-16763`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\1: Copy File Name and Path\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp1"`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted||Copy File Name and Path Quoted`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted|icon|Shell32.dll,-16763`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp2"`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\3: Copy Path To File||Copy Path To File`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\3: Copy Path To File|icon|Shell32.dll,-16763`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\3: Copy Path To File\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp3"`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\4: Copy File Name Only||Copy File Name Only`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\4: Copy File Name Only|icon|Shell32.dll,-16763`nREG_DWORD|HKCR\*\shell\CopyExtra's\shell\4: Copy File Name Only|CommandFlags|0x00000020`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\4: Copy File Name Only\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp4"`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\5: Copy File Name and Extension||Copy File Name and Extension`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\5: Copy File Name and Extension|icon|Shell32.dll,-16763`nREG_SZ|HKCR\*\shell\CopyExtra's\shell\5: Copy File Name and Extension\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp5"`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's|MUIVerb|Copy Extra's`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's|Position|bottom`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's|SubCommands`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's|NoWorkingDirectory`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\1: Copy File Name and Path||Copy File Name and Path`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\1: Copy File Name and Path|icon|Shell32.dll,-16763`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\1: Copy File Name and Path\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp1"`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\2: Copy File Name and Path Quoted||Copy File Name and Path Quoted`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\2: Copy File Name and Path Quoted|icon|Shell32.dll,-16763`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\2: Copy File Name and Path Quoted\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp2"`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\3: Copy Path To File||Copy Path To File`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\3: Copy Path To File|icon|Shell32.dll,-16763`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\3: Copy Path To File\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp3"`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\4: Copy File Name Only||Copy File Name Only`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\4: Copy File Name Only|icon|Shell32.dll,-16763`nREG_DWORD|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\4: Copy File Name Only|CommandFlags|0x00000020`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\4: Copy File Name Only\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp4"`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\5: Copy File Name and Extension||Copy File Name and Extension`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\5: Copy File Name and Extension|icon|Shell32.dll,-16763`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\5: Copy File Name and Extension\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp5"`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\6: Copy File Content||Copy File Content`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\6: Copy File Content|icon|Shell32.dll,-16763`nREG_DWORD|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\6: Copy File Content|CommandFlags|0x00000020`nREG_SZ|HKCR\AutoHotkeyScript\Shell\CopyExtra's\shell\6: Copy File Content\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp6"`nREG_SZ|HKCR\Directory\shell\CopyExtra's|MUIVerb|Copy Extra's`nREG_SZ|HKCR\Directory\shell\CopyExtra's|Position|bottom`nREG_SZ|HKCR\Directory\shell\CopyExtra's|SubCommands`nREG_SZ|HKCR\Directory\shell\CopyExtra's|NoWorkingDirectory`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\1: Copy Folder Path||Copy Folder Path`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\1: Copy Folder Path|icon|Shell32.dll,-16763`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\1: Copy Folder Path\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp7"`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\2: Copy Folder Path Quoted||Copy Folder Path Quoted`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\2: Copy Folder Path Quoted|icon|Shell32.dll,-16763`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\2: Copy Folder Path Quoted\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp8"`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\3: Copy Folder Name||Copy Folder Name`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\3: Copy Folder Name|icon|Shell32.dll,-16763`nREG_SZ|HKCR\Directory\shell\CopyExtra's\shell\3: Copy Folder Name\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp9"`nREG_SZ|HKCR\regfile\shell\CopyExtra's|MUIVerb|Copy Extra's`nREG_SZ|HKCR\regfile\shell\CopyExtra's|Position|bottom`nREG_SZ|HKCR\regfile\shell\CopyExtra's|SubCommands`nREG_SZ|HKCR\regfile\shell\CopyExtra's|NoWorkingDirectory`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\1: Copy File Name and Path||Copy File Name and Path`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\1: Copy File Name and Path|icon|Shell32.dll,-16763`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\1: Copy File Name and Path\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp1"`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted||Copy File Name and Path Quoted`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted|icon|Shell32.dll,-16763`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp2"`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\3: Copy Path To File||Copy Path To File`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\3: Copy Path To File|icon|Shell32.dll,-16763`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\3: Copy Path To File\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp3"`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\4: Copy File Name Only||Copy File Name Only`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\4: Copy File Name Only|icon|Shell32.dll,-16763`nREG_DWORD|HKCR\regfile\shell\CopyExtra's\shell\4: Copy File Name Only|CommandFlags|0x00000020`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\4: Copy File Name Only\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp4"`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\5: Copy File Name and Extension||Copy File Name and Extension`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\5: Copy File Name and Extension|icon|Shell32.dll,-16763`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\5: Copy File Name and Extension\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp5"`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\6: Copy File Content||Copy File Content`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\6: Copy File Content|icon|Shell32.dll,-16763`nREG_DWORD|HKCR\regfile\shell\CopyExtra's\shell\6: Copy File Content|CommandFlags|0x00000020`nREG_SZ|HKCR\regfile\shell\CopyExtra's\shell\6: Copy File Content\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp6"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's|MUIVerb|Copy Extra's`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's|Position|bottom`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's|SubCommands`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's|NoWorkingDirectory`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\1: Copy File Name and Path||Copy File Name and Path`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\1: Copy File Name and Path|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\1: Copy File Name and Path\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp1" `nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted||Copy File Name and Path Quoted`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp2"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\3: Copy Path To File||Copy Path To File`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\3: Copy Path To File|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\3: Copy Path To File\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp3"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\4: Copy File Name Only||Copy File Name Only`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\4: Copy File Name Only|icon|Shell32.dll,-16763`nREG_DWORD|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\4: Copy File Name Only|CommandFlags|0x00000020`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\4: Copy File Name Only\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp4"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\5: Copy File Name and Extension||Copy File Name and Extension`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\5: Copy File Name and Extension|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\5: Copy File Name and Extension\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp5"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\6: Copy File Content||Copy Content`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\6: Copy File Content|icon|Shell32.dll,-16763`nREG_DWORD|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\6: Copy File Content|CommandFlags|0x00000020`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's\shell\6: Copy File Content\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp6"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's|MUIVerb|Copy Extra's`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's|Position|bottom`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's|SubCommands`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's|NoWorkingDirectory`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\1: Copy File Name and Path||Copy File Name and Path`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\1: Copy File Name and Path|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\1: Copy File Name and Path\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp1"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted||Copy File Name and Path Quoted`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\2: Copy File Name and Path Quoted\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp2"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\3: Copy Path To File||Copy Path To File`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\3: Copy Path To File|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\3: Copy Path To File\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp3"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\4: Copy File Name Only||Copy File Name Only`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\4: Copy File Name Only|icon|Shell32.dll,-16763`nREG_DWORD|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\4: Copy File Name Only|CommandFlags|0x00000020`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\4: Copy File Name Only\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp4"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\5: Copy File Name and Extension||Copy File Name and Extension`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\5: Copy File Name and Extension|icon|Shell32.dll,-16763`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\5: Copy File Name and Extension\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp5"`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\6: Copy File Content||Copy Content`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\6: Copy File Content|icon|Shell32.dll,-16763`nREG_DWORD|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\6: Copy File Content|CommandFlags|0x00000020`nREG_SZ|HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's\shell\6: Copy File Content\Command||"C:\Windows\CopyExtra's.exe" `%1 "/cp6"
    )

    If (!rm) {
        FileAppend, %Script%, %A_Temp%\CopyExtra's.ahk
        RegRead, ExecCmplr, HKCR\AutoHotkeyScript\Shell\Compile\Command
        RunWait % """" (SubStr(ExecCmplr, 2, InStr(ExecCmplr, """",, 0, 3)-2)) """" " /in " """" A_Temp "\CopyExtra's.ahk""" " /out " """" A_WinDir "\CopyExtra's.exe"""
        FileDelete %A_Temp%\CopyExtra's.ahk
        
        Loop, parse, RegKeys, `n
        {
            Type := Key := Name := Value := ""
            loop, parse, A_LoopField, |
            {
                if (A_Index = 1)
                    Type := LTrim(A_Loopfield)
                else if (A_Index = 2)
                    Key := LTrim(A_Loopfield)
                else if (A_Index = 3)
                    Name := LTrim(A_Loopfield)
                else if (A_Index = 4)
                    Value := LTrim(A_Loopfield)
            }
            RegWrite, %Type%, %Key%, %Name%, %Value%
        }
        str := "Feature is successfully installed!"
    } else {
        FileDelete, %A_WinDir%\CopyExtra's.exe
        
        For i, path in ["HKCR\*\shell\CopyExtra's", "HKCR\AutoHotkeyScript\shell\CopyExtra's", "HKCR\Directory\shell\CopyExtra's", "HKCR\regfile\shell\CopyExtra's", "HKLM\SOFTWARE\Classes\SystemFileAssociations\document\shell\CopyExtra's", "HKLM\SOFTWARE\Classes\SystemFileAssociations\text\shell\CopyExtra's"]
            RegDelete, % path 
        str := "Feature is successfully removed!"
    }
    return str 
}

Copy Handler:
This is the script that handles all copy to clipboard actions. Above script will create, then compile this script.
The executable will be written to the windows folder. You don't need this! It's sitting here for curious people.

Code: Select all

#NoEnv
#NoTrayIcon
SetBatchLines -1
Loop % A_Args.Length() 
{
    If (A_index = A_Args.Length())
    {
        If (A_Args[A_Index] = "/cp1")
            Clipboard = %F%
        else If (A_Args[A_Index] = "/cp2")
            Clipboard := """" RTrim(F) """"
        else If (A_Args[A_Index] = "/cp3")
            Clipboard := SubStr(F,1,InStr(F,"\",,0,1))
        else If (A_Args[A_Index] = "/cp4")
            Clipboard := SubStr(SubStr(F, InStr(F,"\",,0,1)+1),1,InStr(SubStr(F, InStr(F,"\",,0,1)+1),".",,0,1)-1)
        else If (A_Args[A_Index] = "/cp5")
            Clipboard := SubStr(F,InStr(F,"\",,0,1)+1)
        else If (A_Args[A_Index] = "/cp6")
            Clipboard := FileOpen(F,0).read()
        else If (A_Args[A_Index] = "/cp7")
            Clipboard := RTrim(F)
        else If (A_Args[A_Index] = "/cp8")
            Clipboard := """" RTrim(F) """"
        else If (A_Args[A_Index] = "/cp9")
            Clipboard := RTrim(SubStr(F,InStr(F,"\",,0,1)+1))
    }
    F .= A_Args[A_Index] " "
}
ExitApp
Last edited by megnatar on 07 Mar 2019, 09:52, edited 13 times in total.
godofOOF
Posts: 27
Joined: 22 Dec 2018, 06:03

Re: Copy Extra's Context Menu

16 Feb 2019, 00:56

This is actually pretty cool thanks! do i have to rerun this if i restart my pc?
User avatar
megnatar
Posts: 92
Joined: 27 Oct 2014, 20:49
Location: The Netherlands
Contact:

Re: Copy Extra's Context Menu

16 Feb 2019, 03:51

godofOOF wrote:
16 Feb 2019, 00:56
This is actually pretty cool thanks! do i have to rerun this if i restart my pc?
Nope, it writes the settings to the windows configuration DB a.k.a. the registry.
Like I said, run the script to add the settings and run it again to remove them.

Have fun!
User avatar
megnatar
Posts: 92
Joined: 27 Oct 2014, 20:49
Location: The Netherlands
Contact:

Re: Copy Extra's Context Menu

17 Feb 2019, 11:27

There was a little mistake in the script that handles the copy actions.
It's fixed now.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Chunjee, Xtra and 83 guests