c# - Intercept MS Windows 'SendTo' menu calls? -


scenario

i manage , organize many files during day, sendto used feature use on windows.

problem

by default, when user clicks item/link of contextmenu send files, o.s not show kind of advise/notifier indicating files copying selected destination.

i consider wrong design issue because big files ok ...a progressbar shown, if files small not show progressbar/visual indicator not possible ensure files copied (without manual effort) because i'm human , click outside sendto contextmenu error.

so, develop personal mini-tool me optimize time showing me notifier window wherever on screen when send/copy files using sendto feature contextmenu, , sendto feature.

question

in simple words, want detect copy/send operation sendto menu ensure click done on menu item (and not outside menu), providing additional basic info such source folder, destination folder, , amount of files or filepaths.

any ideas start developing tool in right direction?.

i grateful code example in c# or else vb.net, preferably last.

approach

since don't know how start doing mean easiest or efficient way intercept sendto calls, firstly thought hook copyfile or copyfileex api functions, not provide information need because function called in kind of copy operation , not when use sendto feature, i'm lost.

i'm not sure if should investigate more internal calls, or maybe investigate more windows contextmenu instead of messing function hooks , ugly things avoid.

my main idea develop hidden winforms (or else windows service) stays in background waiting when use sendto feature (when click on item of sendto menu) , show kind of visual indicator on screen ensure clicked menu-item , maybe inform amount of files i'm moving , i'm moving them.

research

here code example think demostrates how instantiate sendto com object create own?, written in c++ , i'm not sure if example helpful because intention not replace sendto menu i'll keep useful info here it serves else:

how add(enable) standard "send to" context menu option in namespace extension

the knownfolderid constants docs gives useful info sendto folder, again i'm not sure if maybe read/access monitoring approach?, keep info here:

guid: {8983036c-27c0-404b-8f08-102d10dcfd74}

default path: %appdata%\microsoft\windows\sendto

legacy default path: %userprofile%\sendto

in shell extension handlers docs there copy hook handler don't know if has relation sendto's com component , if me in way, same ignorance icontextmenu::invokecommand method reference maybe intercept identify sendto invocation?

by moment feel flying blind.

i found a managed "send to" menu class again example written in c/c++ (i think same source before) don't understand @ , again i'm not sure if me because repeat replacing sendto not have in mind (just because don't know how avoiding possible risks, prefer still let windows logic copy/send files, want detect copy operation retrieve info)

expected results , usage

step 1:

select random file , use sendto menu (in language, spanish, command name 'enviar a')

enter image description here

step 2:

let .net application's logic (working in background) intercept sendto operation retrieve info.

(i need step)

step 3:

display info somewhere on screen ensure sendto operation performed, ensure clicked sendto item (my link).

enter image description here

(that popup simulation, don't know way retrieve info)

it's simple once understand sendto does, , doesn't involves com or shell extensions @ all. basically, send menu populated content of sendto folder of user profile (c:\users\\appdata\roaming\microsoft\windows\sendto default in windows 6.x).

when clicked, if option shortcut folder copy files there, if there shortcut program (or program executable itself) run program, passing paths of selected files command-line arguments.

from there, it's trivial make program takes paths arguments, present kind of notification , copies files or whatever want them.

a quick , dirty example follow (in c#, done else really):

private static void main(string[] args) {     if(messagebox.show("are sure want copy files?", "copy files", messageboxbuttons.yesno) == dialogresult.no) return;      foreach (string file in args)         file.copy(file, path.combine("c:\\temp", path.getfilename(file)); } 

this ask confirmation copying bunch of files. note doesn't "intercepts" send menu, rather handles completely, it's program responsability meaningful action. more serious implementation use the built-in windows copy dialog , display screen progress or else, that's needs.

it take more parameters on command line. when place shortcut in sendto folder, destination add more parameters passed first ones (before file names). example destination of shortcut can read c:\program files\copyfiles.exe c:\temp pass destination folder instead of hardcoding. called program must interpret first parameter destination path , subsequent ones source files.


Popular posts from this blog