I would like to make some hook in windows programs. For instance, Vodafone application have some MSN like popup that can't be hiddent. So, in that way, I would like to create my option to hide or not this popups. Can anybody tell me some tutorials (basic first) how to do that?
Thanks in advice.
You have to create system wide windows hook with SetWindowsHookEx with first param WH_CBT. You can hook on HCBT_CREATEWND event and return non zero value and window will be destroyed, but first you have to somehow recognize that this is right window, maybe according to window title or something inside that title.
Another thing is that you can't use managed code and C# for system wide hooks, since you have to make unmanaged dll in witch hook will reside. So you have to use C++ or Delphi, and if you are not experienced in win32 programming that would probably be very complicated task.
Related
I want to add custom actions to every window's title bar context menu. The goal is to add an option like in the task view where you can move a window to a different virtual desktop. I was able to do this with hotkeys using GlobalHotKey and WindowsDesktop packages in C#. But I want to do it in the UI as well similar to some Linux desktop environments.
I know you cannot normally do this with the registry like you can with other context menus. When creating your own application I know you can use GetSystemMenu, AppendMenu, etc. and override WndProc to handle it. But this obviously will not work for what I am intending.
The application Moo0 Window Menu Plus achieves the desired effect but I have no idea how they do it.
I have a feeling the solution is probably somewhat hacky but I would still like to know how it could be done. I am open to using any language to achieve this.
You need to inject into the process, that is the only way to add a menu item.
A shell hook will notify you with HSHELL_WINDOWCREATED when a appropriate window has been created. You can then inject into the process (with another hook type or CreateRemoteThread). Once you have your .DLL in the process you can subclass the window and change the system menu.
You need to create both a 32-bit and 64-bit injection .DLL and I would recommend that you write it in native code, not C#.
I have added a .Net windows form inside a saleslogix windows plugin, every thing is working fine but on pressing the "Tab" key inside this control, instead of going on the next textbox the control goes to next plugin.
I have searched it a lot and can not find a work around for this, when I added a browser control in another saleslogix windows plugin, the page inside this textbox has multiple text boxes in it. To my surprise on pressing the tab key it worked perfectly and control goes to the next text box.
Any help is much appreciated.
That's an entirely normal mishap when you use Winforms (and many other UI class libraries) in a host application. Navigation keys, like Tab and the cursor keys as well as shortcut keystroke keys, need to be recognized regardless which control has the focus. One way to do so would be to implement the KeyDown event handler on every single control. That's excessively painful of course.
So it doesn't work that way, the keystroke is recognized when it is received by the message loop, before it is dispatched to the control with the focus. Overriding the ProcessCmdKey() method is the general way to do this. The base method takes care of navigation and recognizing menu and button mnemonics.
Problem is, it isn't the .NET message loop that is receiving and dispatching messages. It is the host application that has the loop. And it doesn't know beans about ProcessCmdKey(). So it doesn't get called and navigation doesn't work.
It tends to work in a WebBrowser because it is an ActiveX control. Which is designed to interact with its host. In particular it negotiates to decide which one gets to process the key. The IOleInPlaceActiveObject::TranslateAccelerator() method does this. Not the kind of plumbing available in .NET and host apps are rarely written to provide an alternative.
You could consider the "excessively painful" solution but pretty unlikely you like the sound of it. There's only one other decent way to fix this, you must call ShowDialog() to display your form. Now it is the .NET loop that dispatches and the Tab and cursor keys work fine. That tends to be unwelcome advice, dialogs can be pretty awkward. If you are lucky and know what you're doing and the host can deal with it (usually not) then using a thread can take the sting out of the modality. Asking the vendor for advice, particularly the threading aspect, would be wise.
I'm doing an automation script for installation wizards using AutoIt. I'm trying to handle window changes in some way.
Can some one explain how these GUI's work?
When I click on the Next button it looks just like the components in the GUI is beeing changed. Is this tha case? Or is a new window created and the old destroyed?
I've noticed that the process ID is the same for all windows.
I'm sure there is some way to know which "state" the GUI is in, or which step?
By the way. All the windows has the same title.
Thanks
/Anders
This will be dependant on the program you are automating.
The easiest approach would be to look at what changes in the GUI between stages, likely candidates are if there is a label that is giving instructions for that step, or a button that has text changing (e.g. if the button says "Finish" then you know your at the end).
Most installer programs have child windows for grouping the controls of each stage. These are typically implemented as dialog resources (as can be seen when using something like reshacker on them). So although the window remains the same, the panels are being created/destroyed as appropriate. This is a very neat method of doing it, for the obvious reason that you don't need to have to code to create/destroy a lot of controls. Resource created dialogs don't have nice class names like windows sometimes do though, so this may not be a reliable way to check the state.
I have an application and would like to know what GUI toolkit was used to implement it. The list of DLLs which it uses at runtime wasn't very enlightening, I didn't recognize anything. Tools like Spy++ or UISpy show that the windows have class names like wcl_manager1 (apparently toplevel windows) or wcl_internal_window_class (for anything else). Most of the controls (line edits, check boxes, buttons) don't even have a native window, i.e. no HWND associated.
Does anybody know what GUI toolkit this might be?
Look up ProcessId property and you'll figure it out.
In my case it was CiscoJabber.exe with "20200" window name.
Is there any method in JScript to get the handle of the main window of a process by providing the process name? The Process.MainWindowHandle property works only in JScript .NET. Is anything similar available in classic JScript?
I am not sure if this works, just try to loop window.parent until its undefined.
something like -
var mainWindow = window;
while( mainWindow.parent ) {
mainWindow = mainWindow.parent;
}
you also have something like window.top which always returns you the topmost window. But not sure if this is supported by all browsers.
JScript and Windows Script Host don't have this functionality, and neither does WMI.
If PowerShell is an option for you, then you can use the Process.MainWindowHandle property you mentioned:
(Get-Process notepad).MainWindowHandle
Otherwise, you'll need to find or write an utility (COM object, command-line tool etc) that would provide this functionality, and call this tool from your script.
Edit: So you need to close the window — that's a UI automation task.
Windows Script Host provides very limited UI automation functionality. If you know the window title, you could try using the AppActivate to and SendKeys methods to activate that window and send the Alt+F4 shortcut to it. You can find an example this answer. (The code is in VBScript, but it should give you the idea.) However, this approach isn't reliable.
If you really really don't want to kill the process, the easiest solution is to use some third-party UI automation tool. For example, you could try the free AutoIt tool — I think it should be able to accomplish what you need.
Edit 2: Have you tried recording the closing of the window? You should get a script like this:
Sys.Process("notepad").Window("Notepad", "Untitled - Notepad").Close();
Isn't this what you need?
For a native win32 application, there is no such thing as a "main window". A process can have no windows at all, or several top level "main" windows.
Well once i had to write a add-in for Outlook. My boss wants a splash-screen to appear when Outlook loads. But Outlook window goes over the splash. After a lot of search i found FindWindow http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28FINDWINDOW%29%3bk%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22%29%3bk%28DevLang-CSHARP%29&rd=true this is help for it . This function finds window based on window caption and window class name. I p-invoked it and used it from C#. If you can use this function through JScript I think it could do the job for you. (I used Spy++ for finding lpClassName parameter)