Jump to content
Sign in to follow this  
b1t5tR3@m

Right-Click Context Menu Functionality

Recommended Posts

Has anyone accomplished this, and I mean "this" in the sense of passing a selected / focused file (right-clicked) as a variable to then be manipulated by AutoIt? I spent a great deal of time at MSDN the other day thinking there could be a way through COM or oShell (and there probably is), but got no where. I have also combed the forums for past posts relating to this topic but found nothing helpful.

If you know what I'm talking about and can be of any help, I would sincerely appreciate it.

Share this post


Link to post
Share on other sites

I think that requires some DLL programming. What I've done is placed some compiled scripts in my Send To folder, with these two lines at the top:

#include <Array.au3>
$targetfile = _ArrayToString ( $cmdline, " ", 1)
Hope that's useful.

Edited by lod3n

Share this post


Link to post
Share on other sites

I'm not quite following you on what you want to do. Do you want to have a application you can right click on, and have a menu show up?

Let me further explain what I endeavor to do....

A while back, I came up with a GUI for SolidSnake's UDF's that interacted with the MD5 Deep hash utilities (Here). While I have made quite a few improvements with usage, I thought that it would be 1) prudent to add CRC32 functionality to it (even though it's been basically retired from usage), and 2) modify it slightly to be used as a context menu function. You would, in theory, right-click on a particular file and choose "Hash this file". This would in turn call a modified compiled AutoIt script which would generate the hashes for you.

I hope that explanation gives you a better understanding of what it is I am trying to accomplish.

I've already set up right-click functionality through the registry, I believe at this point I am looking at working with COM or something. I need to pass the "active" file as a variable to AutoIt. Got tired looking through MSDN for one day.

Share this post


Link to post
Share on other sites

I've already set up right-click functionality through the registry, I believe at this point I am looking at working with COM or something. I need to pass the "active" file as a variable to AutoIt. Got tired looking through MSDN for one day.

Just setup a incoming cmdline structure in your script to handle the passed path through the registry should be enough.

This code will register/unregister the entry in registry (via no parameter passed or cmdline). Add entended value so it is not shown by default in contextmenu (press shift to see item).

#region - Includes
#include <Constants.au3>
#endregion

#region - Global Variables
Global Const $REG_KEY = 'HKLM\SOFTWARE\Classes\*\shell\MD5_DeepHash'
#endregion

#region - CmdlineSwitch
If $CMDLINE[0] Then
    For $i = 1 To $CMDLINE[0]
        Switch $CMDLINE[$i]
            Case '/?'
                MsgBox(0x40000, StringTrimRight(@ScriptName, 4) & ' Help', _
                        'Switches are:' & @LF _
                         & @LF & '/extract' _
                         & @LF & @TAB & 'Extract files to current directory' _
                         & @LF & '/register' _
                         & @LF & @TAB & 'Add registration into context menu' _
                         & @LF & '/unregister' _
                         & @LF & @TAB & 'Remove registration from context menu')
                Exit
            Case '/extract'
;~              FileInstall('?', @ScriptDir & '\')
                Exit
            Case '/register'
                RegWrite($REG_KEY, '', 'Reg_sz', 'Hash This File')
                RegWrite($REG_KEY, 'extended', 'Reg_sz', ''); only see item with shift key pressed
                RegWrite($REG_KEY & '\Command', '', 'Reg_sz', '"' & @ScriptFullPath & '" "%1"')
                MsgBox(0x40000, 'MD5', 'Registered')
                Exit
            Case '/unregister'
                RegDelete($REG_KEY)
                MsgBox(0x40000, 'MD5', 'UnRegistered')
                Exit
            Case Else
                Const $FILE_PATH = $CMDLINE[$i]
                If Not FileExists($FILE_PATH) Then
                    MsgBox(0x40030, 'MD5', 'File parameter is invalid')
                    Exit
                EndIf
        EndSwitch
    Next
Else
    If RegRead($REG_KEY, '') Then
        If MsgBox(0x40021, @ScriptName, 'Do you want to remove ' & @ScriptName & ' from the registry?') = $IDOK Then
            RegDelete($REG_KEY)
        EndIf
    Else
        If MsgBox(0x40021, @ScriptName, 'Do you want to add ' & @ScriptName & ' to the registry?') = $IDOK Then
            RegWrite($REG_KEY, '', 'Reg_sz', 'Hash This File')
            RegWrite($REG_KEY, 'extended', 'Reg_sz', ''); only see item with shift key pressed
            RegWrite($REG_KEY & '\Command', '', 'Reg_sz', '"' & @ScriptFullPath & '" "%1"')
        EndIf
    EndIf
    Exit
EndIf
#endregion

; Code below
MsgBox(0, 'File path is', $FILE_PATH)

You will need to compile to have it execute from registry.

:)

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  

×
×
  • Create New...