I'm developing a piece of software to inset some text in a rich edit of another program the code goes like this:
atlfe = FindWindowEx(wtlsplitterwindow, 0, "atl:0087d7a8" , null);
This is only one line: this works fine, problem is with every release of the program number atl:0087d7a8 changes so i have to use spy++ to get the new one and change it in the code.
The question is, is there is any way I can get that number from code?
By the way I'm using C#, VS2010.
I suggest you use UI Automation instead of raw Windows API. You should start with the UI Spy tool to determine the UI hierarchy of your app, it will be more resilient to change.
See some articles on this subject on SO:
Retrieve current URL from C# windows forms application
How to get the word under the cursor in Windows?
Been a while since I messed with some of these windows API's. I think this may be of value though.
http://msdn.microsoft.com/en-us/magazine/cc163617.aspx
If the Title is always the same, use it instead of class name
atlfe = FindWindowEx(wtlsplitterwindow, 0, null, "Title");
More info on MSDN.
Clearly if the sub-window has not title and its classname is different every time you have but one method remaining.
You are first going to have to find the top level window of this app using either EnumWindows or FindWindowEx, the latter if you can identify it by class name and/or window title.
Once you have the top level window you can walk through the children to locate the sub-window that you are looking for. Presumably you already know the relationships between the top level window and the sub-window you are targetting. In any case Spy++ can tell you this.
Related
I am currently using Unity multi display function. When I run my Unity app, it creates two windows in the task bar. One for each display I have.
I am able to - when the program starts - get the active window by using GetActiveWindow(). I have managed to manipulate this a little bit, but the next thing I'm trying to do has me stuck.
I'm trying to cycle through the other unity app windows. The one for the secondary display in this case, and then set it as the active window. Using SetActiveWindow() I would imagine.
However, I'm not too familiar with the convoluted Windows logic. I know I probably need to use FindWindow(), but the actual use of that code has me bewildered.
My question is: How can I reliably find and store every open Unity game/app window that is running?
(Not the editor. Only the Apps launched)
Assuming that each window created by unity will have the same (or similar) class name or window title, you can either use EnumWindows (interop) function to retrieve a list of created windows and then checking each of them for their class name (you'll have to know the class name ahead, do this by using GetClassName (interop) function once and then storing it for later comparison with EnumWindows.
The other possibility would be to listen for the window creation event, therefore getting notified when a new window gets created. Once again, compare the class name or window title with the newly created window to see if it is a window created by unity.
If neither class name nor window title work for comparison (because they might be inconsistent) you can also retrieve the process name (use GetWindowThreadProcessId to retrieve PID) and see whether it matches unity.exe.
I am trying to find a way to start my video conferencing in full screen view, I'm writing a WPF application using Lync SDK.
I've been looking over Lync SDK and practicing the examples on MSDN for a week now, but I did not see a property or a method to set the view to full screen in video call. Intellisense didn't helped me either.
So how can I set the video view in full screen? Also should I do it after I dock it?
Here is the code I use for calling someone;
Dictionary<AutomationModalitySettings, object> _ModalitySettings =
new Dictionary<AutomationModalitySettings, object>();
List<string> inviteeList = new List<string>();
inviteeList.Add("elise#contoso.com");
IAsyncResult Iar = _automation.BeginStartConversation(
AutomationModalities.Video
, inviteeList
, _ModalitySettings
, callbackVideo
, null);
_automation.EndStartConversation(Iar);
And here is the docking method I call from my delegate on new conversation event (Both codes are just slightly edited codes from MSDN);
private void DockTheConversation(string ConversationId)
{
_LyncModel.WindowPanelHandle(ConversationId,
myFormsHost.Child.Handle.ToInt32());
}
I can access the ConversationManager, ConversationWindow, Conversation(the one that is being docked), LyncClient and Automation. But I couldn't found any related methods or properties in any.
ConversationWindow.IsFullScreen property is readonly so that doesn't work either. And I don't know how can I edit;
Microsoft.Lync.Model.Conversation.AudioVideo.VideoWindow.FullScreenMode
Microsoft.Lync.Model.Conversation.AudioVideo.VideoWindow.WindowState
properties, or whether if they would work or not.
I'm already running my WPF application on full screen (WindowState, WindowStyle) but I also want the hosted Lync ConversationWindow to fill the screen, like when you push the button on the top right.
Any help is appreciated! Thanks!
I'm pretty sure you won't be able to do this using the Lync SDK. If you were running your app with Lync in UI suppressed mode, you could get access to the underlying VideoWindow so you would be free to place it anywhere on the screen, but that only works in UI supressed mode.
I'm thinking that it would probably be possible using Win32 calls. You should be able to determine the inividual windows that make up the conversation window, find the Video window and then use SetParent to remove this from the parent conversation window. You could then use e.g the Win32 ShowWindow to maximise the window.
I've not tried this, but i'm fairly sure it would work given the right Win32 calls. If you're not familiar with Win32, then PInvoke.net is a great Win32 reference, and might be a good place to start.
If you want to create full screen, You should write property changed of conversation window as the following code:
InputSimulator.SimulateKeyPress(VirtualKeyCode.F5);
This may be a long short or not even possible but no harm in asking.
What I am trying to do is monitor an application for any new windows it creates in its MDI control. I have implemented hooking in C# and can capture the MDICREATE window message but because I need to get information about the window after is has been created the MDICREATE message isn't much help because at that stage the window hasn't been created in the other application yet.
Without going into to much detail I just need to be able to see when a new window has been created.
Is this possible?
Thanks
I'm not aware of another message that gets the info that you are looking for off hand. But if that message works for you, you could hook that message and then do another scan of the windows to find the one you are missing. You can enumerate the child windows of the parent window. Use Spy++ to see the exact window hierarchy.
If you can watch for a particular function call, I would use some kind of hooking library to grab that (EasyHook comes to mind).
You can hook the MDI create function (assuming there is one), watch for that, then inn your code, call the original and do any lookups using the returned value. You'll have access to the returned value and any parameters, so you should be able to get some info out of those.
Two options off the top of my head.
Hook the WM_MDIACTIVATE event, the first time the window is being activated, use a flag to determine the first time the window is being activated.
If you need to run your code after the WM_MDICREATE or WM_MDIACTIVATE, you can post a new custom message from one of these messages, which is then handled after these messages have completed. You then write your code to handle the custom message.
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.
I wanted to create a program that would allow me to open instances of a already exsiting program (i just have the exe) as windows inside (i belive its called mdi)
Is that something i could do? can anyone point me to an example?
Thanks
Maybe this is the answer you are looking for here. It can be done...look in the sample on that link given.
Hope this helps,
Best regards,
Tom.
When Windows starts a program its parent is the Desktop Window.
If you could somehow manipulate that, it may work.
However, I doubt it is possible, as why would I want to allow you to run my application in your window? Especially MDI? Besides that - running in a child window isn't quite the same as running in the "main" window.
Having said that there is an application out there (can't think of it's name OH) that does place individual applications in tabs. Pretty nifty if you're not on Windows 7. The folks over at the Business of Software forum might be able to help you find it.
Well, after starting the app and storing its PID, you could start monitor the windows that get created, either thru a CBTHook or by just using a timer and the GetWindows to find when a top level window gets created by the PID in question.
Then you can use SetParent to make that window a child to your MDIChild (I doubt you can make it your MDIChild directly).
That should get you going. What you'll run into after that I really don't know. I guess you must correlate any movement of either your app or the external app so that thir windows appears to be stuck together...
Maybo you could strip away the caption from the external app (Get/SetWindowsLong). That could make it look better...