C# app that uses Notepad - c#

I want to write an application (C# would be best, other are also welcome) that works in the background in Windows/Linux, but is able to put characters in inputs and textareas of currently active window, in applications like Notepad, Browser URL Address and so on. How is this possible?

Take a look at the SendKeys class. This should handle your situation.
Edit: If you want a Java solution, take a look at the Robot class.

Related

User Click Tracking Library for Desktop App

We are looking into the possibility of allowing users to opt into a program where they report what button clicks etc. they do, and I was wondering if anyone can suggest a good library which already does this. Based on the way the app is implemented, we have access to the base "Button" class and can add code on the click which records the fact that the button was clicked.
What we're looking for is a library which can record all these clicks, store them locally, and then send them to us at some point in the future when the user has internet access.
Does something like this exist in an open or closed form?
Thanks,
Liron
Our app can run code in either c# or javascript, since it runs in Unity3d, but we have other desktop apps which are pure c# and would prefer a library we can run across all our applications.
We ended up going with DeskMetrics, which seemed like a good fit for our needs. We also looked at TrackerBird which has some nice features which weren't necessary for our particular requirement and wasn't working within the limited requirements of Unity3d.

A Simple application that can run in windows task bar

I want to write a very simple application, containing a pop-up menu when user click on it, that will appear in windows task bar, exactly like language bar, this is the only need. it does not concatin any more functionality at the time being.
Does anybody know where to start or do you have any sample code for it. I really do not know where to start since I am a Newbie!
Thanks in advance
Try having a look at the NotifyIcon class.
You are looking for ITrayDeskBand but good luck with getting anything out of the MSDN documentation.
I suggest a web search for ITrayDeskBand and looking at the top hits that aren't on MSDN!
For example, this from the Code Project looks useful. Note that since this is a shell extension, most of the code you find will be native because .NET shell extensions are somewhat frowned upon.
You need to develop a ToolBand for this.
You can either develop one yourself or use a library like EZShellExtensions.

How can you read values from an open application in Windows?

I want to create a program or use a program that will read the memory values out of another application. Does anyone know of an application/library that will do this?
The target app is this. I would like to read the exchange rate values from it.
I'm an experienced c# programmer, but have never worked with the Win32/user32 api which is what I'm assuming I'll have to deal with to pull this off.
Any help that gets me going in the right direction is greatly appreciated.
Update:
I managed to use Spy++ to get the window handle, so I'm sure I can get the values some how.
Have you looked into AutoIT or AutoHotKey?
Both of these open source options have well documented abilities to read text from application windows (and send keystrokes or mouseclicks to them).
AutoIT is very easy to use and well documented.
An example of reading text from a window would be:
$text = WinGetText("title of window", "")
MsgBox(0, "Text read was:", $text)
This can be compiled into an executable.
Typically an application creates controls in a dialog in a consistent manor, same ID, same order etc, so finding a control programatically is fairly simple. Using Spy++ find the control's ID and then you can search the windows created by the application for the desired control. Not being familiar with the app in question I cannot give specifics, but if Spy++ shows the value you desire, it is likely not difficult to obtain the value in your code.
What type of control is the value displayed in? You'll may be able to use GetDlgItemText to obtain the value once you have the parent window handle and control ID? To get the parent window try using EnumWindows.
It might be easier to scrape their data by automating a screenshot and then ocr process. If that's your goal.
Potentially relevant links:
get-a-screenshot-of-a-specific-application
ocr-with-the-tesseract-interface
May be this article helps - http://msdn.microsoft.com/en-us/magazine/cc163617.aspx, but I think it's not universal and for your task is better to get access directly to Forex API/Web-Service or try to catch needed data on network.
It is possible to screen-scrap things created with native windows controls; if that is the case, you should be able to see the controls using Spy++. But some times controls are implemented "by hand", and there is no way to screen-scrap them (e.g. some Java graphic toolkits play directly with the graphics, so everything day do is meaningless from the outside, or even some Office menus are implemented without using the menu control).
The Windows accessibility API is a possible way to screen-scrap the values; check if "Narrator", the screen reader that comes with windows, is able to read aloud your target application.

Entering text into a textbox that doesn't belong to your application (C#/.NET)

So, I was just wondering how I could enter text into a text box on a web page with a windows application.
Almost like a reverse screen scrape.
I know I have read somewhere about being able to do this but, I completely forgot how he did it. I think he may have been using Win32 DLLs which might be a fun endeavor but, getting off-topic now.
So, the question is: How can you inject text into text boxes that don't belong to your application with .NET (C#)
EDIT: Found my answer. See comments below.
Have a look at SendInput Win32 API. You'll need to focus on the correct window first, naturally. Also, it has some security restrictions on Vista and above, so that a low-privilege application cannot manipulate another one with higher privileges.

Send key strokes to another application C#

I need to automate FileMon.exe to startup with filters, save out the log it generates, and then exit.
My solution has been to write an assist application that will do all of this. Which has worked on starting up with specified filters and killing the process, but I still need it to save the log. Do you think it would be silly to send the application keystrokes to save the log? For instance I would send an Alt+F, Alt+S, type filepath, Enter.
How can you send keystrokes like above to another process that is running in C#?
As I know, you have to invoke some of native APIs:
-FindWindow to find parent windows you want to work with
-FindWindowEx to find true windows you'll send message to
-SendMessage to send key strokes to those windows
Details of these APIs, refer at MSDN :)
You can use Windows.Forms.SendKeys to send keystrokes to the active application.
Thanks for all the answers and help guys... I'm actually going to write and invoke a perl script using Win32::GuiTest.
That's probably a deaad end. You should look and see if the application (or one of its dependent DLLs) exposes the proper API calls to do what you are trying to do. If you had to do it by keystrokes, you could look into some kind of macro program like MacorMaker.
You could use powershell and the windows automation cmdlets up on www.codeplex.com/wasp to do this.
-Oisin
Use something like AHK (Auto HotKey) it is a simple language that can be compiled to an EXE and is designed for automating the keyboard and mouse.
Also the IRC Channel and Forums always have people willing to help if need be.

Categories