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.
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 would like a particular type of file (eg. Namefile.ext2) read all the names preceded by a #
Sample contents of the file:
#nameone
#nametwo
#namethree
When I click the right mouse button on the ext2 file extension beyond the standard options (like: open, properties, etc ...) I would like to be:
contents of the file > nameone
nametwo
namethree
Then, select the item (eg. nameone) pass this parameter to my program running in the background / or services
Do you need to modify the registry somehow? I will be grateful for tips on how to achieve the desired effect.
What you are asking about is called 'shell extension'. Basically it requires some knowledge of COM objects programming, but .NET made things a bit easier in that matter.
Shortly: you have to develop a piece of code which will reads the file and generates menu items dynamically (which may be tricky but possible). That code needs to be registered in the system as COM object.
Before it starts working you have to associate file extension with COM object you created.
Perhaps this article can explaint it a bit more:
http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus
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.
I am working on a windows application that will need to be branded. The client will be selling this to other businesses, and needs a customized logo and name for each sale.
The client does not know how to use visual studio!
I think I need to write a packager app to inject custom logo and string resources into the executable. I am planning on using WPF. But since this is a critical requirement, I'd be willing to do it in winforms if that is easier.
What is the best way to do this? Any and all suggestions welcome.
It sounds like what you are after is application skinning. This doesn't mean you have to unpack the exe and inject resources. You just need to consider skinning from the start of the project and build the application to support your skinning requirements.
WPF will make skinning your app much easier. There will be several different ways to accomplish what you want.
Simplest is to leave the logo image loose and reference it with a relative path from the XAML file(s) that need to show this image.
You should look into Resource Dictionaries in WPF and how they help you group resources and support skinning. http://msdn.microsoft.com/en-us/library/ms750613.aspx
The text will be a little different but I am not sure what you need as far as a text goes. Do you mean you need to localize the strings or do you simply need different text (all the same locale) to show for different clients?
One possible solution (perhaps not the simplest one) is to use a parent application which compiles source code for generating child application. You can do it with CSharpCodeProvider and CompilerParameters classes. Add the image as an embedded resource and retrieve it in the child application. A working demo with a source code is available at Slide Show Builder.
My best suggestion for the exact question you asked (although I suspect there is another way by reconsidering the exact requirements) would be to write a utility which uses ildasm to disassemble the assembly, then use ilasm to reassemble it and include your new resource file.
http://msdn.microsoft.com/en-us/library/496e4ekx%28VS.71%29.aspx
The trivial solution is to provide the bitmap along with the EXE as a separate file. Actually replacing an embedded resource in the EXE requires decompiling it with ildasm.exe and putting it back together with ilasm.exe. Ildasm.exe is only available in the Windows SDK, it can be downloaded separately. Error prone and small odds that your customer can get that right, you'll need to provide them with, say, a .bat file that does this.
Of course, whomever is interested in replacing the logo, for whatever reason, would not be slowed down by replacing either the separate image file or using the Ildasm.exe trick. There is therefore very little point in making it any more complicated then it needs to be.
I'm trying to achieve functionality similar to winzip/winrar, etc. I have a Treeview that displays the contents of a package (System.IO.Packaging). I want to be able to drag and drop a file or folder from the TreeView onto an explorer window or the desktop, etc. My problem is that I have to call DoDragDrop before I know if the object was actually even dropped. That means to create the DataObject with the FileDrop type, I must extract those contents of the package out to a temporary area and then provide that path to the DataObject before calling DoDragDrop. If the user doesn't drop on a capable container or cancels the drop, the overhead of extracting those contents is wasted. I've noticed that winzip does not actually create the temporary file until the drop occurs on a valid target. I've checked the DataFormats provided by the WinZip drop and they are normal FileDrop, FileNameW, FileName and Shell IDList Array. The first three simply hold a string to the temporary location that winzip extracted that file to. I'm not sure what the last one does.
Long story short, I want to be able to avoid extracting the contents until I know the drop location was valid. Is there a callback to figure out the drop location? Any suggestions would be extremely helpful.
System.Windows.DragDropEffects de = DragDrop.DoDragDrop(treeview1, dataObj, System.Windows.DragDropEffects.Move);
I've tried this with an application similar to an FTP server - I wanted to start downloading only after the user actually dropped the item. Unfortunately I found no way to do this using managed code only.
The way WinZip probably does it is by receiving COM callbacks (please forgive me if I'm using the wrong words here) and you'd have to create a managed wrapper around the native COM object in order to receive such callbacks yourself.
It's certainly possible, but I gave up and embedded a FolderTreeView thingie in my application to catch the drop events myself :/