I got one requirement which is when the user copy any text the system should get the copied text from the memory into the program without require the user to paste it in a txtbox or similar control. I searched on the internet but I didn't get any information. can somebody suggest or provide some references so that I can follow...????
any help would be highly appreciated...!!!!
From a web development standpoint, you can not access the clipboard directly. You will have to create either a Flash or Silverlight hook into the clipboard to get the data.
Example
Another Example
For security reasons, you will never be able to do that in Javascript.
As it is already pointed out accessing clipboard is either not possible or restricted for security reasons for all components running on a page in a browser (restricted == is unlikely to be enabled by anyone, especially for such "spy on clipboard" purpose).
For standalone application you can either scan clipboard all the time or use clipboard filters.
Native functions are around SetClipboardViewer and GetClipboardData.
Managed: Clipboard.
Related
I'm building a User Control using C#/Winforms and have struck a bit of an issue with localization.
I have added a number of strings to the resource file "inside" the user control, using the UserControl.resx file created automatically by Visual Studio. For the immediate term, these strings provide the Text values for the various buttons in the user control. I have tested this with location specific suffixes (ie, UserControl.zh-HK.resx), and all appears to work perfectly.
What I have found, though, is that the UserControl.resx file I am using gets wiped out, or cleared, at irregular intervals (I haven't nailed down exactly when it does and does not get cleared).
A big clue is that the IDE throws a message box when I attempt to edit this file. It says, in essence, that my changes may be lost. Experience has taught me that this is certainly the case.
For various reasons, the idea of having the resource file tightly coupled to the user control seems attractive. There are several of us, all developing user controls that are destined for the same product.
Is there any way to stop VS from smashing my string resources? Is there a better way, allowing for the fact that we want a separate set of resource files for each user control?
Thanks.
Long story short, everything I was doing was wrong.
In the end, what I have done is create a Resources folder in my project, with a separate set of resource files for each discrete component (form, user control, etc). Then in each component I retrieve the strings like buttonFoo.Text = Resources.UserControl.buttonFoo_Text.
This method seems to be working well enough for now and provides the separation of resource files that I wanted, while making the integration of the code from multiple sources semi-painless.
I have a C# application that needs to determine where the clipboard is pasting to before it does so in order to disallow the paste to applications that are not allowed/supported. This will be a security application extension that companies will be able to enable when employees are attempting to copy from and paste outside of confidential, internal documents.
Is this possible? I've done a thorough search and looked through the following link, but didn't find anything that would be useful.
https://msdn.microsoft.com/en-us/library/windows/desktop/ff468802(v=vs.85).aspx
edit: I can easily determine if the application being copied from is one of ours, so this will only be enabled in that case. Copy/paste functionality through the rest of the system will work as it always does.
I'm currently working on a project to provide interop between two unrelated pieces of software. I need to pass the data from a textBox/textBoxes, into a textBox of the other said app.
My current idea is to find the handle of the target control, make it active, and enter the data by copying it to the clipboard, and pasting it via:
Clipboard.SetText(textBox1.Text, TextDataFormat.Text);
SendKeys.SendWait("^V");
As textBoxes have no 'caption', handles are dynamically assigned on the process start, and class names are appended with various data regarding the process, is it possible to get a handle for an object within a window via some sort of indexing? I'd be more than willing to find the correct handle by trial and error if need be, as long as it would be consistent for every instance of the application.
Thanks in advance
A.
If you don't have any other choice.. to make this easier, you can use AutoIT.. I had to do something like this a very long time ago. AutoIT. They have a DLL for .net Applications, so you can use their functionality without having to use their scripts. If you do use their scripts.. they also have an option that will turn their script into an executable.
Is there a way to programmatically add text to the clipboard in C# (3.5) or javascript ? Does the client machine type make a difference?
Edit: Sorry, forgot to mention am using asp.net.
You can use Clipboard.SetText(string) and Clipboard.GetText() to interact with the clipboard.
See the MSDN article
As long as the client supports .NET, it shouldn't make a difference.
Oh, for the web...
Then use something like this jQuery plugin:
http://plugins.jquery.com/project/clipboard
It will allow you to copy and paste from the clipboard across browsers.
C#: In System.Windows.Forms you have a Clipboard class and a SetText method which probably is what you're looking for. Example:
Clipboard.SetText("My text");
Edit: Since you're looking for a way to set clipboard text on a client computer, here's an updated answer:
There is no browser agnostic way of setting clipboard text. It's possible in Internet Explorer using the following snippet:
window.clipboardData.setData('Text', 'Your text');
In Firefox and Webkit browsers, for security reasons, you need to go via flash to set clipboard text. Zeroclipboard is a nice library for this.
As far as I'm aware in the web world it would be a security issue to access the clipboard without some sort of client side control, i.e. ActiveX control or Flash. So it would prompt for the user to allow the access. Here is something to get you started.
In WinForms there is a static Clipboard class with a SetText method. So you can use
Clipboard.SetText("whatever");
There are some differences to the default text format based on which operating system you are running on: http://msdn.microsoft.com/en-us/library/ydby206k.aspx
You can use Flash.
I have a asp.net web site. I want to invoke MS word on a Client machine. Is there any easy way to do this with VS2008, C#3.0?
I can do this with Qt and with an ActiveX control but trying to avoid going this way...
would silverlight be a way to go?
You want to execute an application from the browser (without the evil ActiveX things, of course)?! If you could do that, probably you could wipe off the whole disk too.
And no, Silverlight runs in a partially trusted sandbox. It won't run unmanaged executables on the client machine.
If you are just trying to get Word open to view a document, you could just give your user a link to the .doc/.docx file and their browser would take care of opening the file. If you want to interact with Word, you're going to have a hard time doing that from the browser without using ActiveX.
Silverlight has the same locked down sandbox environment that the web browser has, so that won't help you get around this security limitation.
What are you trying to do with Word? Even if you could launch the app, I don't think you could do any kind of COM interaction from within your web page.
An easy way to merely launch Word would be to have the user download a Word file, but I don't think that's what you're asking and they might not open the file -- they could choose to save it instead.