IE window GotFocus / LostFocus events

Add-in Express™ Support Service
That's what is more important than anything else

IE window GotFocus / LostFocus events
Determining if IE is the window that has focus 
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
Hello,

I saw an old post about getting the focus state of IE and that is exactly what i'm looking to do as well.
Previous forum post

Has this been implemented yet?

Details of issue:

I'm looking run some code when the user clicks out of IE to another window and when they come back in to IE.

particularly I need to close any open autocomplete dropdowns (custom controls) because they are set to always on top and remain open when ie loses focus.
Posted 06 Nov, 2015 16:26:38 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Kyle,

Please try to use the OnFrameWindowActivate event of the iemodule.

private void IEModule_OnFrameWindowActivate(object sender, bool active)
{
Debug.WriteLine("OnFrameWindowActivate: " + active.ToString());
}

You need to set the 'HandleDocumentUICommands' property of the iemodule to 'True' in order to enable the event.
Posted 09 Nov, 2015 11:36:53 Top
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
Thank you for the help.

I'm still having problems with it recognizing if the window is active or not.

I went to the visual designer for IEModule and went to the properties and set "HandleDocumentUICommands" to True. Then I added the event handler

Private Sub IEModule_OnFrameWindowActivate(sender As Object, active As Boolean) Handles Me.OnFrameWindowActivate
        Debug.WriteLine("OnFrameWindowActivate: " + active.ToString())
    End Sub


But when I have the toolbar open and click on, for example, a Notepad window on my other screen, the event doesn't get written to debug. same when clicking back into the IE window as well which I assume would make it Active again.
Posted 09 Nov, 2015 16:51:39 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Kyle,

What the tool do you use to see the debug messages? I used DebugView.
Note, you should disable the protected mode in IE so that you can see the debug messages.
Posted 10 Nov, 2015 05:38:47 Top
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
Yes i'm using DebugView and my IE11 is not running in protected mode.
I do get debug messages from minimizing and maximizing IE using the WindowStateChanged event, if that tells you anything.
Posted 10 Nov, 2015 09:45:30 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Kyle,

Do you have 'handleDocumentUICommands' attribute set to 'true' in the adxloader.dll.manifest file of your project?

E.g.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<assemblyIdentity name="MyIEAddon81, PublicKeyToken=853bc2e398bb039c" imageRuntimeVersion="v4.0.30319" />
<loaderSettings generateLogFile="true" shadowCopyEnabled="false" privileges="administrator" configFileName="MyIEAddon81.dll.config" handleDocumentUICommands="true" />
</configuration>
Posted 10 Nov, 2015 11:13:20 Top
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
After going to my project folder I found 5 of these files in various locations within the folder. all of them were read only and all of them were had handleDocumentUICommands="false" or they didn't have it at all.

I reloaded my project in visual studio and found that the property for iemodule was back to false, and when I tried to change it to true in visual studio it would not save the change, it stayed false.

I made sure to unregister the adx project and clean / rebuild all as well.

I manually changed it to true in the manifest files, and it is functioning as expected now, but it is concerning that I was unable to change this in the properties.

*edit*
after removing the read-only on the manifest file (not sure why it was there) i'm able to change this property correctly in visual studio and it remembers it.

Thanks for the help!
Posted 10 Nov, 2015 13:54:44 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hello Kyle,

Kyle Bohannon writes:
after removing the read-only on the manifest file (not sure why it was there)


It might be set by the source code control software product that you use.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Nov, 2015 02:45:01 Top