for several days now I am trying to create a program that reads and writes values from/to textboxes in another application. To be more specific: I want to auto-update ticket cathegories in HP Service Manager.
My first attempt was using SendKeys. But I faced the problem that this method seems to be not really reliable as I need to reach text fields far from another and using loops that sended TAB was unreliable [of course I added an Application.DoEvents() and a Thread.Sleep].
After some time of testing I am now unable to control HPSM at all [SendKeys get executed on every program EXCEPT HPSM]. Dunno what is wrong but I read in the internet that there are several problems [only works with Visual Studio running, only while debugging etc.] so I dropped this solution.
I would welcome it if I can access the desired text fields directly. Now, using Spy++ I can select the desired text fields. But unfortunately, there is no fixed value to identify a certain text field: No way to do this programmatically.
The only thing that always seems to stay the same is the structure/hierarchy of the "Windows" provided by HPSM [see attached screenshot].
Now my idea: Is there a way to iterate through those sub-windows and read/modify the "Window Caption" portion of the certain window?
Or is there another, maybe simpler way to get this sucker automated?
Thanks in advance for every help since I slowly drown in desperation :)
HPSM structure:
Related
I'm using a note program,it runs good most of the time,but sometimes it can't display in the Windows Notification bar(I'm not sure if this is the correct name), so i can't click the icon to maximum the program,if I tried to restart the program,it even can't display in the notification bar by ten times attempts.
So I want to write a tiny C# program,Because I found that a lot of grammar is similar to java...(Let's call the program < tinyStarter >) I want it to do one simple job:
using windows command line to call a target program,after a short while(5 seconds maybe),< tinyStarter > will check if the program name list is in the right-down-corner of windows desktop (is it called Notification Bar?),if not,recalling the program until it displays.
I used spy++ to locate the target program's area,then it shows:
Handle:000100DE;
Caption:Notification area for user upgrade
Class:ToolbarWindow32
So the question is ,is there any chance to using C# to get program name list in ToolbarWindow32 ,or at least the count of them?
I actually did some efforts to solve another problem ,
see the thread,
so the question in this thread was not done much searching and trying yet,I ask the question here just because I hope this question can be soveld easily by some experts.When I was doing some efforts on the other problem,the note program can't be opened normally can be very annoyed after all.
Any help will be appreciated.
I've seen it in many code samples, tutorials and other people's code that I've worked with. I've never really understood (or even learned) why people use Console.Write(exception.Message);.
The only reason I can think of is to log the exception for later investigation. So, I thought I'd give it a try, since I have some spare time on my hands, and have tried to find some specific info regarding my questions, but couldn't find it.
If I use Console.Write(exception.Message); in an asp.net webpage, where exactly does this go? Where is the "Console" in a web app/site?
And, how do you "see" what you've previously written to the Console?
In Visual studio, for winforms and WPF application it prints to Output window
For ASP.Net use System.Diagnostics.Debug.WriteLine() to print to output window
To open the Output window, on the View menu, click Output.
You may want to see: Where does Console.WriteLine go in ASP.NET?
i want to write an application, which reads under windows xp the quick launch items in the order like they are located in the taskbar,
and sets hotkeys for each of these item.
windows + 1 should start the first application
windows + 2 the second, etc.
(like in windows 7)
all of these items are found i a folder, but if i read the items of this folder, i dont get the right order of these items.
i found two solutions the get the right order - first:
in the registry an entry is found, where its saved how they are located, but not in plain text. i dont know how to read this, and cant reverse engine it.
the second:
read via winapi the items tooltip from the taskbar, so i can (if there are not items with the same name) search via the name in the quick launch folder.
the quick launch bar is just a listview (syslistview32).
via sendmessage i got it work to count the items, and start one (faking a click on this item), but how the hell can i read the tooltip?
i have googled a lot, tried everything, but i didnt get it run.
i hope you have any snippets for me, to solve this problem.
cheers
Determining the order of the items in the Quick Launch toolbar programmatically is going to be inherently fragile. There's not an API exposed for this, which means that it's subject to change in future versions of Windows, breaking your code that relied on assumptions about undocumented implementation details.
However, this is less of a problem in this specific case than it normally would be, since the Quick Launch toolbar doesn't exist anymore (or, at least, no one uses it anymore). The last version of Windows that used the Quick Launch toolbar was Vista, so if you make sure that your code is compatible with Vista and earlier, you should be fine. It won't work with newer versions anyway.
The positions of items in the Quick Launch toolbar is stored in the Registry in the following key:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Desktop
You can extract the information from there, parse and interpret it, and then use it as you like. As you mention, this information isn't stored in plain text form because that would be very slow for the shell to load and parse itself. Since this is undocumented and not designed to be used by clients, they had no particular benefit in making it user (or developer) friendly. All that matters is what's most efficient for the shell, and storing the binary information from its internal structures is the obvious choice.
You will need to reverse engineer this in order for it to be useful to you. The way I'd go about it is probably by setting up a test environment with a couple of items in the Quick Launch bar in a particular order, exporting the information from the Registry, moving one of the items around, exporting the updated information from the Registry, and comparing the two exported Registry files to see what changed. Rinse and repeat as many times as necessary to deduce the pattern. (Really makes you wonder why so many developers actually do take the time to reverse-engineer undocumented aspects of Windows, doesn't it?)
The other option would be to use Spy++ to investigate the windows that implement the taskbar and its Quick Launch toolbar. I don't have a pre-Windows 7 system around, but it sounds like from the question that you've already done this and determined that the Quick Launch toolbar is implemented using a standard ListView. If you know the name of that window (and the names of its ancestor windows), you can walk through those windows to obtain a handle to the window you're interested in. And then you can determine the order of the items in the window as if it were a standard ListView in your own application.
The documentation for ListView controls is here; that should get you started in the right direction. You can get the text of one of the subitems by sending the LVM_GETITEMTEXT message.
This is probably the easier way of doing it. The same caveats apply--there is nothing keeping future versions of Windows from changing the names of those windows or the way that the taskbar is implemented, but since the only versions of Windows that have a Quick Launch toolbar have already been released (and therefore aren't likely to change), this may not be a big problem.
Then again, with the fact of the Quick Launch toolbar's obsolescence in mind, I struggle to comprehend why this endeavor is even worthy of investing developer time.
Also, even once you get this program all written and installed, consider what happens when the user adds a new item to the Quick Launch toolbar or re-arranges the existing items. How is your utility going to know that and adjust the keyboard shortcuts accordingly? What if an installer adds/removes an item from the Quick Launch toolbar?
Boring background:
I have been working with UltraVNC to control some PC's at work and it does the job great but in order to simplify things I created a program that interfaces with it in C#. Basically I take advantage of the commands the viewer offers to connect, control, watch or transmit to each PC.
Problem is anyone can access the PC's since it has one main account (no domain controller). I need everyone to sign for the PC before they can use it, so to make my job easier I open each PC and block the inputs + blank the screen that way there obligated to sign before use.
Opening each pc and press the block button can be hassle especial when you’re helping someone and a user leaves, others come (btw I work at an electronic library). UltraVNC doesn’t have a command for this; it’s been requested but I don’t think it’s much of a priority for them and the code seems very intimidating for a novice like me so I thought I could try a hack to get what I want.
Problem: I want to “click” a button in a program I use, from an application that I am building in c#. I can currently use the process class to get the handle and identify the specific window I want to use but I have no way to find the button handle which I read is what I need. I found stuff about using findwindow and sendkeys for this but I don’t see how that’ll work unless the button had a keystroke assigned to it which it doesn’t.
So can anyone point me in the right direction?
Why not use something like Eficium Cybercafe SurfShop to achieve what you want? After teh user finished you log the session out, and before someone can log in, they have to sign in.
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.