Jump to content

Need to make script a DropTarget


Recommended Posts

I have a script that processes all file/folder names from its command line and produces a report.

If I put a link to the compiled script in the"Send To" folder, I can select multiple items, right click and select 'Send To', then my script name. This works OK.

However, because of certain command line argument limitations, I want to put the script name into the top level of the right context menu (the parent of the 'Send Tp' menu).

I got the entry to hook in OK, and I can select any single file, right click on it, select my script name and it creates the report OK.

But, when I select multiple filenames, my script is never called. The command line I put into the registry is this:

"D:\Temp\Rwcheck.exe" "%1"

I believe that this does not work because I need to make my script accept filenames as Drop Targets. (I faked a CLSID entry in the associated HKEY_CLASSES_ROOT\*\shell\Rwcheck\DropTarget key and it called the faked executable.)

I cannot see how this is done in AUTOIT. I see a TreeView DropTarget functionality, but not anything for the main window.

Anyone know how I can do this?

Andy

Link to comment
Share on other sites

I have a script that processes all file/folder names from its command line and produces a report.

If I put a link to the compiled script in the"Send To" folder, I can select multiple items, right click and select 'Send To', then my script name. This works OK.

However, because of certain command line argument limitations, I want to put the script name into the top level of the right context menu (the parent of the 'Send Tp' menu).

I got the entry to hook in OK, and I can select any single file, right click on it, select my script name and it creates the report OK.

But, when I select multiple filenames, my script is never called. The command line I put into the registry is this:

"D:\Temp\Rwcheck.exe" "%1"

I believe that this does not work because I need to make my script accept filenames as Drop Targets. (I faked a CLSID entry in the associated HKEY_CLASSES_ROOT\*\shell\Rwcheck\DropTarget key and it called the faked executable.)

I cannot see how this is done in AUTOIT. I see a TreeView DropTarget functionality, but not anything for the main window.

Anyone know how I can do this?

Andy

If you mean you have added a menu option to explorer's context menu so that you can call your compiled script which is rwcheck.exe then you don't need to sepcified the style $WS_EX_ACCEPTFILES for the gui because being called with parameters is not having files dropped on it.

When you have more than one file in the parameter list then I think that windows will simply call your exe once for every file giving one file as a parameter at a time.

If your script doesn't get called then something else is the problem.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

If you mean you have added a menu option to explorer's context menu so that you can call your compiled script which is rwcheck.exe then you don't need to sepcified the style $WS_EX_ACCEPTFILES for the gui because being called with parameters is not having files dropped on it.

When you have more than one file in the parameter list then I think that windows will simply call your exe once for every file giving one file as a parameter at a time.

If your script doesn't get called then something else is the problem.

I know that the script isn't getting called. It looks like the secret is to put a CLSID in the "DropTarget" registry key.

I recently installed a hex editor that works like I want my script to (relative to context menu handling). I patterned my registry entries after it, replacing the editor's name with my compiled script's name.

When I put a CLSID for the hex editor, and running Explorer, and I right clicked after selecting multiple files, then selected my script name, it ran the hex editor which opened the selected files.

It looks like if I can associate some unique CLSID with my compiled script's executable, I'll be in the right place. I have a CLSID generator, so I have a unique CLSID, but I don't know how to attach it to my COMPILED script. Do you know if I'm on the right track and do you know how to make my compiled script use the new unique CLSID?

Also, in my script, I will probably have to handle WM_DROPFILES events to see the filenames.

Andy

Link to comment
Share on other sites

Try this.

Method 1

#NoTrayIcon

#Include <Messages.au3>

const $RECEIVER_ID_NAME = 'CmdLine'

if _IsReceiver($RECEIVER_ID_NAME) then
    for $i = 1 to $CmdLine[0]
        _MsgSend($RECEIVER_ID_NAME, $CmdLine[$i])
    next
    exit
endif

local $IntFlag = 1, $TimeOut = 200

dim $aParam[$CmdLine[0] + 1] = [$CmdLine[0]]

_MsgTimerInterval(50)
_MsgRegister($RECEIVER_ID_NAME, '_Receiver')

for $i = 1 to $CmdLine[0]
    $aParam[$i] = $CmdLine[$i]
next

$nParam = $aParam[0]

$IntFlag = 0

$Td = TimerInit()

while TimerDiff($Td) < $TimeOut
    if $aParam[0] > $nParam then
        $nParam = $aParam[0]
        $td = TimerInit()
    endif
wend

_ShowParam()

; At this point, the array $aParam contains the entire list of files that were sent through the context menu of Windows ("%1").
; Flag $IntFlag need to set before you change the array $aParam and unset after.
; If parameters will no longer be send, it is possible to release the receiver by _MsgRegister($RECEIVER_ID_NAME, '') or _MsgRelease() function.

;_MsgRegister($RECEIVER_ID_NAME, '')

_ParamRelease()

func _ShowParam()
    
    local $t = ''

    for $i = 1 to $aParam[0]
        $t = $t & $aParam[$i] & @CR
    next
    $t = StringTrimRight($t, 1)
    MsgBox(0, '', $t)
endfunc; _ShowParam

func _ParamRelease()
    
    $IntFlag = 1
    
    redim $aParam[1]
    $aParam[0] = 0
    
    $IntFlag = 0
    
endfunc; _ParamRelease

func _Receiver($sParam)
    
    if $IntFlag = 1 then
        return 1
    endif
    
    $IntFlag = 1
    
    redim $aParam[$aParam[0] + 2]
    $aParam[0] += 1
    $aParam[$aParam[0]] = $sParam
    
    $IntFlag = 0
    
    return 0
endfunc; _Receiver

Param.au3, Messages.au3

Method 2

WM_DDE...

http://msdn.microsoft.com/en-us/library/ms674595(VS.85).aspx

:D

Edited by Yashied
Link to comment
Share on other sites

This has the same problem. If you hook your compiled executable to the first level of the context menu (not in the 'Send To' menu), it works if you select a single file, right click and select 'Param'. But if you select 2 or more files, right click and select 'Param', nothing happens. The executable is not even called.

Here is my .reg file to put in the hooks for your compiled executable:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Param]

[HKEY_CLASSES_ROOT\*\shell\Param\command]

@="\"D:\\AutoIt\\myStuff\\Param.exe\" \"%1\""

[HKEY_CLASSES_ROOT\*\shell\Param\DropTarget]

@="\"D:\\AutoIt\\myStuff\\Param.exe\" \"%1\""

Andy

Link to comment
Share on other sites

This has the same problem. If you hook your compiled executable to the first level of the context menu (not in the 'Send To' menu), it works if you select a single file, right click and select 'Param'. But if you select 2 or more files, right click and select 'Param', nothing happens. The executable is not even called.

Here is my .reg file to put in the hooks for your compiled executable:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Param]

[HKEY_CLASSES_ROOT\*\shell\Param\command]

@="\"D:\\AutoIt\\myStuff\\Param.exe\" \"%1\""

[HKEY_CLASSES_ROOT\*\shell\Param\DropTarget]

@="\"D:\\AutoIt\\myStuff\\Param.exe\" \"%1\""

Andy

Andy, I have everything works fine, but I forgot to tell you that in my script, there is a nuance. It all depends on the speed of your computer. Try to increase the value of the $TimeOut. On my computer, with a delay of 200 milliseconds and it works well with any number of files. Try $TimeOut = 500, should help.

And if the truth, then I think this is not the best example, though quite genuine. The speed of his work is heavily dependent on the number of input files. Try changing it to suit your needs, here is to think about. But if you send files directly to a time when the script is already loaded (not through the command line), it works just fine and without any delay.

Good luck to you.

:D

Link to comment
Share on other sites

  • 1 month later...

I know that the script isn't getting called. It looks like the secret is to put a CLSID in the "DropTarget" registry key.

I recently installed a hex editor that works like I want my script to (relative to context menu handling). I patterned my registry entries after it, replacing the editor's name with my compiled script's name.

When I put a CLSID for the hex editor, and running Explorer, and I right clicked after selecting multiple files, then selected my script name, it ran the hex editor which opened the selected files.

It looks like if I can associate some unique CLSID with my compiled script's executable, I'll be in the right place. I have a CLSID generator, so I have a unique CLSID, but I don't know how to attach it to my COMPILED script. Do you know if I'm on the right track and do you know how to make my compiled script use the new unique CLSID?

Also, in my script, I will probably have to handle WM_DROPFILES events to see the filenames.

Andy

I see that AutoIT has the same problem. If you right click a .au3 file, the context menu has an entry that says "Edit Script".

Click on it and the AUT editor pops up with the file you've chosen.

However, if you select 2 or more .au3 files, then right click and select "Edit Script", absolutely nothing happens!!

The behavior I would expect would be for the editor to open with a tab for each file selected

(BTW Notepad++, based on the SciTE engine, opens all selected files, as I expected it to).

Link to comment
Share on other sites

I see that AutoIT has the same problem. If you right click a .au3 file, the context menu has an entry that says "Edit Script".

Click on it and the AUT editor pops up with the file you've chosen.

However, if you select 2 or more .au3 files, then right click and select "Edit Script", absolutely nothing happens!!

The behavior I would expect would be for the editor to open with a tab for each file selected

(BTW Notepad++, based on the SciTE engine, opens all selected files, as I expected it to).

I use SciTE full version and here it works perfectly, no problems.
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...