Microsoft Equivalent of WebkitGTK hovering-over-link signal - c++

I need to add ability to catch event each time there is mouse hover event both on Linux and Windows. In Linux I easily connect to hovering-over-link signal. I cannot seem to find Windows equivalent. Searched google, checked the MSDN, I could not find.
Does Such a functionality available in windows? If no is there a way to achieve it?

Can you use the StatusTextChange event? This event is fired when the mouse is hovered over a link, with sText set to the link URL.
It is also fired with additional messages such as when loading a page. In these cases, sText is set to "Connecting to (URL)", "Waiting for (URL)", etc. These messages can be simply ignored by doing a basic URL validation of sText.
A more involved method would be in the DocumentComplete event to search for all anchor elements using getElementsByTagName and attach to the HTMLAnchorEvents onmouseover. This of course wouldn't work for anchor elements dynamically created after page load.

Related

WinAPI navigate back/forward

In any web browser and in the Windows file manager and in many other applications there is support for forward and backward navigation. This always (or at least most of the time) by default works with extra mouse buttons if your mouse has any.
I want to implement this in a C++ application I'm making based on WinAPI. However I wonder how one would do this? Are the mouse buttons captured "manually" in each application that has this forward/backward navigation or is there native support for it somewhere in WinAPI?
Manually capturing the buttons is probably always an option, but if there already is an existing functionality that handles this then it seems like that should be used instead. That's probably more reliable as well.
To sum up: I want my application to correctly handle/receive backward and forward clicks from a mouse that has such buttons.
The WM_APPCOMMAND message offers the APPCOMMAND_BROWSER_FORWARD ("Navigate forward") and APPCOMMAND_BROWSER_BACKWARD ("Navigate backward") navigation commands. You can handle them in your application, even if it's not a browser.
The documentation has information, how and when the WM_APPCOMMAND is generated:
DefWindowProc generates the WM_APPCOMMAND message when it processes the WM_XBUTTONUP or WM_NCXBUTTONUP message, or when the user types an application command key.

NPAPI mac plugin sharing commands with browser

I have a NPAPI plugin running in Safari, Chrome and Firefox. I'm able to handle all key combinations with the event callback, but the problem I'm having is with certain key combinations.
In the plugin, I'm trying to use Command+O to fire the plugin's file open dialog, but the browser is also firing its open file dialog.
Supposedly, returning TRUE for event handling method should report the browser that the plugin handled the event, but I'm having no luck with that.
You neglected to specify which OS you're on; based on the fact that you said "Command+O" instead of "Ctrl-O" I'm assuming you're on Mac. The bad news is that on Mac, all events are passed to the plugin from the browser. If the browser doesn't choose to make it possible to override the handling of an event (and it sounds like this is the case) then there is probably nothing you can do about it, short of possibly using some OS hook to intercept the key event before the browser gets it, which seems risky.
On windows you might have a little more luck, since a windowed plugin should actually get events first before they are passed to the parent window and thus could intercept them. On Mac, though, it's all windowless and you get events when the browser feels like giving them to you.

How to send mouse click event to a game application?

I try to send a mouse click event to a game application. First, i use Spy++ to find what message the application receive. I see something like : WM_MOUSEACTIVATE, WM_WINDOWPOSCHANGING, WM_ACTIVATEAPP, WM_ACTIVATE, WM_SETFOCUS, ...
i try to send the same as i see on Spy++ but it doesn't work. How to send mouse click to a game application without give it focus? . it's run in window mode. Thanks in advance.
You want WM_LMOUSEDOWN. You can always check MSDN for the documentation on which messages mean what.
The best way to automate applications and games is via SendInput. While in theory it should be possible to drive an application via WM_LUBTTONDOWN etc, many applications read the key state directly via lower level APIs (such as GetAsyncKeyState) which don't change their state to reflect the messages processed from the message queue.
Using SendInput requires actually setting the game to the foreground as the input events are synthesized at a low level and are thus delivered to the active/focused window.

Closing a MessageBox automatically

I have a third party encryption library, which may create a MessageBox if key creation fails. The failure can be caused by bad random number generation or other rarities, and in most cases, trying again will result in success. My code will attempt key creation up to three times before deciding it failed.
Now, the issue is that the program may be used with automation. If a MessageBox is created during automation, it will block the process forever, because there's nobody to click the 'OK' button.
Does anyone know of a way to catch when this message box is created and automatically close it?
Anything is fair game, as long as it's not something that will make security suites angry. This means no hooking or code tunneling.
In summary, I need to catch when a MessageBox is created and close it. The MessageBox's creation is outside of my control. Modifying the code at runtime is not acceptable.
Also, I've noticed there are some other similar questions, but they don't have the same requirements.
EDIT: Additional note, I can find the message box via searching through all windows until I find one with a matching title and then send it a WM_CLOSE message, but I don't think this is a great solution. I also have no guarantee that the message box has been/will be displayed, or how long after my call it will be displayed. It could display instantly, it could display 1200 ms later, or it could not display at all.
Just before you begin the encryption process, install a WH_CBT hook, and in its callback watch for an nCode of HCBT_CREATEWND. If you get a matching class name ('#32770 (Dialog)' ?) and a matching title either return a nonzero value from the callback, or if that doesn't work post a WM_CLOSE (or a BM_CLICK to a relevant button if selecting an option is necessary). Uninstall the hook after the process for not messing with every possible dialog your application pops up.
That sounds like bad design on the part of that library. Generally any sort of utility library (like encryption) has no business invoking any kind of GUI (unless you explicitly ask it to).
Is there possibly some configuration or setting in this library that could disable its use of message boxes?
If not, I'd suggest that you might want to investigate using a different library. After all, if the designers of this library have already made this kind of poor design decision once, then there may be other unfortunate surprises lurking in there.
You can hope that it will be found by GetForegroundWindow, but this may catch other applications. The more brute force way is to iterate over all windows with EnumWindows looking for something that has a caption or text equal to this shown by the library.
I have once "remote controlled" an application by sending mouse click events to some controls. I guess you would have to do this in a separate thread that is watching for Events if a window is opened. Pretty ugly but working...
Create a new thread. If your function fails and a Message Box is opened, obtain a handle to the message box by looping through the windows (GetTopWindow, GetNextWindow) and comparing the window's process id to the one returned from GetCurrentProcessId().
Or, you can avoid all the hard work and just hook the MessageBox API with detours. It's not very hard, and if you don't want to pay for detours, you can do it manually.
Call VirtualProtect and set the memory protection at MessageBox at PAGE_EXECUTE_READWRITE
Create a naked function, and use it as a trampoline.
Create a function identical in parameters to MessageBox (this will be your hook)
Create a jump from MessageBox to your hook function.

Display Outlook icon in notification area for messages, not in inbox

I have rules set to move some email messages into different folders. I would like this to still show the envelope in the notification area but there is no option in the rules wizard to do this. It looks like I would either have to have the rule "run a script" or "perform a custom action" allowing either vba or c/c++ respectively.
Anyone else have a better solution?
You can also achieve it not by using a rule, but doing the rule-like action in code. For example:
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim mai As Object
Dim strEntryId
For Each strEntryId In Split(EntryIDCollection, ",")
Set mai = Application.Session.GetItemFromID(strEntryId)
If mai.Parent = "Inbox" Then
If mai.SenderEmailAddress = "the-email-address-the-rule-applies-to" Then
mai.Move Application.GetNamespace("MAPI").GetFolderFromID("the-entry-ID-of-the-folder-you-want-to-move-the-message-to")
End If
End If
Set mai = Nothing
Next
End Sub
How to get the folder ID (i.e., entryID of the folder):
This is just a manual way, you could make a recursive procedure but for simple purposes this is fine. For instance, I had a structure like:
Mailbox - My_Name_Here
Inbox
The Subfolder I'm Looking For
Sent Items
...
So in the Immediate window I typed:
? Application.GetNamespace("MAPI").Folders(1)
and increased the number until I got "Mailbox - My_Name_Here"
then, I typed:
? Application.GetNamespace("MAPI").Folders(the_number_of_my_mailbox).Folders(1)
increasing the number until I got "Inbox".
Then:
? Application.GetNamespace("MAPI").Folders(the_number_of_my_mailbox).Folders(the_number_of_my_Inbox).Folders(1)
increasing the number until I got "The Subfolder I'm Looking For"
Then:
? Application.GetNamespace("MAPI").Folders(the_number_of_my_mailbox).Folders(the_number_of_my_Inbox).Folders(the_number_of_the_subfolder_i_was_looking_for).EntryID
And that was it: the entryID of the folder I wanted to move the message to. You get the point, I'm sure :)
Check out MailAlert, an Outlook plug-in that does exactly that. It still works in Outlook 2007 (although I've had some instabilities since I installed it again recently, which may or may not be related).
The new version of Mail Alert, which was just released, will allow you to control the notification icon as well as the popup alert and sound alerts. Here are some of the new features in 2.0:
Audible alerts - plays a sound for incoming e-mails
Notification area alerts - displays a notification area (system tray) icon
Program alerts - runs a program and can pass information from the incoming e-mail to that program
Mute feature - to quickly suppress all alerts
Microsoft Outlook 2007 support
Multi-monitor support
Unicode Exchange server support
And more desktop alert features:
Aero Glass style alert windows (on Windows Vista)
Ability to easily dismiss the alert window
Ability to quickly open, reply [to all] or forward a message directly from the alert window's buttons
Ability to convert a message into a task, flag a message for follow up or move a message to another folder; all directly from the alert window's context menu
Ability to set the default position of alerts to be where ever you want them
Privacy option to require a click before showing the preview of the message body
there is an option "display a Desktop Alert" on the Step 1 of the Rules Wizard. it does the trick. this wizard can be run when editing the concrete rule.