Jump to content

[SOLVED] - Add items to Windows context menu for when nothing is selected


Inpho
 Share

Recommended Posts

Updated:

ClipToScript is my attempt at saving some finger effort.

I often copy a bunch of code to the clipboard, right click desktop, click New -> AutoIt v3 Script, Ctrl+A to select template text, then finally paste.

Now, I can right-click anywhere and just select "ClipToScript" and will invoke the script below to present me with a SciTE window with your code pasted in.

 

Old:

Hi All,

Guinness made some fantastic functions which I'm using to modify my Windows context menus. But I've come across an issue which I can't solve myself.

The functions:
_ShellFile
_ShellFolder
_ShellAll

Give the ability to add an item to the right-click menu when selecting a file or folder. What I want is to add options to the context menu displayed when nothing is selected (e.g. you want to make a New Folder in the current directory so you don't select a file or folder - see image below).

This would allow me to have a context menu item called "Clip To Script" which creates a new .au3 file in the current directory, executes (edits) it, then pastes the current contents of the clipboard into SciTE.

Can anyone point me towards some clues on adding items to the Windows context menu when neither a file or folder is selected please?

20200109_103812.thumb.jpg.a7fc1d84dc9aa227e9c5e3ad8c8619de.jpg

Edited by Inpho
Link to comment
Share on other sites

@KaFu Thankyou so much; another few clicks saved.

#include <WinAPIFiles.au3>
#include <WinAPIHObj.au3>

If UBound($CmdLine) < 1 Then
    $sError = ""
    For $i = 1 To UBound($CmdLine) - 1
        If $CmdLine[$i] = "" Then
            $sError &= "NONE" & @CRLF
        Else
            $sError &= $CmdLine[$i] & @CRLF
        EndIf
    Next
    _Error("This script requires a total of 1 parameters; the params you supplied:" & @CRLF & @CRLF & $sError)
EndIf

Func _Error($sMsg)

    ;ConsoleWrite($sMsg & @CRLF)
    MsgBox(0, "", $sMsg)
    Exit 1

EndFunc

$sRandom = String(Random(11111, 99999, 1))
$sFile = "New script_" & $sRandom & ".au3"
$hFile = _WinAPI_CreateFile($sFile, 0, 4, 0)
_WinAPI_CloseHandle($hFile)
FileWrite($sFile, ClipGet())
ShellExecute($sFile)

Will post this "ClipToScript" in my examples/libraries at some point

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...