I have an application that runs elevated (yes, it has to be elevated) but it needs to detect when another application is dragging an object over it. My application doesn't care what the object is, it doesn't want to receive the object, it just needs to know if something is being dragged. In a normal application this isn't an issue, but because my application is elevated it doesn't receive any of the standard drag/drop events from lower privilege applications. Is there a programmatic way to detect whether the cursor is involved in a drag/drop operation?
To do "system wide" drag and drop, I think you have to go the OLE way.
Drag and Drop (OLE)
Also see the "Data Objects and Data Sources (OLE)" link at the bottom of the article.
Related
I have desktop app that is in background. I later want to try this a a service too.
How can I perform mouse click when certain time and date is reached.
I don't want to move user mouse or something. Just send left mouse click from background.
Controling an application via simulated Mouse or Keyboard input goes into the Area of Desktop Automation. There are many existing solutions for it. I advise agaisnt making your own custom hack.
That asumes you do not have control over the target application of course. If that was the case, using a Timer is the obvious way.
As for doing this from a Service: That is nigh impossible. Ever since Windows Vista, Service do not get interactive Sessions by default.This is a rather important part of the UAC security. While getting around it is possible it will propably raise some red flags.
I want to write an application in C# that only opens when the user starts to drag a file in the Windows Explorer. It doesn't matter if the file will be dropped in the app, i only want to know whenever the user drags a file in explorer, and of course, when he releases it again.
I found this article, but I don't really know where to start: Detect drag and drop operations in an external application using .Net
Since I know hardly anything about hooking, I would really appreciate it if someone could give me an example of doing that, or some ideas.
I just implemented drag&drop in my application. It goes two ways:
From my app to Windows Explorer: exports files
From Windows Explorer to my app: imports files
One side effect is that I can also drag files from my application to my application (the same window), which is not intended.
Is there a elegant way to make sure, that a drag&drop operation I started won't be accepted by my application? E.g. check if the source of the drop operation != my application?
You need to register the fact that you initiated a drag from inside your application with some sort of facility or service. If you receive a drop on your application, ask the facility/service if the drag was initiated within your application. If so, discard. Reset the facility/service afterwards (in any case).
I just figured out a way to do this.
Now I set two types of data on my drag&drop data object:
The file names I want to export
A Unicode-Text object containing the name of my application
In my Drop-handler I check if a Unicode-Text object is present and if it contains my application's name. If so, I abort the drop operation.
I have an app with 2 DataGridView's and have implemented Drag/Drop to allow the user to move data between them. Within the context of my application dragging rows between two instances of a form isn't a meaningful action. I'm not sure how to detect it in drag enter so that I can set e.Effect to DragDropEffects.None.
If I don't do so and set it to Copy the DragDrop event fails with a cryptic exception "This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server."
While I can trap this exception to prevent a crash from happening, and abort the actual drop of data in the process it's bad practice to do so, and could be confusing to the user since the drop allowed cursor would be shown but no drop would take place.
Microsoft says that any control can accept data from a drag-and-drop operation in progress, and that you can designate a control as a drop zone by setting the AllowDrop property to true. I would think that, if you set AllowDrop to false on those controls that you do not wish to be a drop zone, you should get the desired behavior.
If you want to detect drag and drop between two instances of your program, you can set an ID in the dragging object (i.e. put a GUID in the tag of the control), and check it during the drag process to see if it matches the GUID of your currently running instance.
http://msdn.microsoft.com/en-us/library/ms973845.aspx
My C# program has a list of files that can be dragged from it and dropped into another program. My requirements are that the file be copied to a different directory first.
So, can I be notified of the drop operation so that I can only copy the file if operation succeeds? I'd rather wait till I know it needs to be copied before actually performing the copy.
Also, is it possible to know what program the drop operation is occurring in? Ideally I'd like to alter the filepath based on who or what its being dropped.
The solution to this can be in any .NET language or C/C++ with COM.
There are a few ambiguities in your question. What operation needs to be successful?
For everything you want to know about drag and drop, browse through these search results (multiple pages worth):
Raymond Chen on drag and drop
So, you intend to modify the data being dropped based on the drop target? I don't think this is possible; after all, you populate the data when the drag is initiated.