Skip to content

Commit

Permalink
bugfix for IE. see issue #10
Browse files Browse the repository at this point in the history
  • Loading branch information
zumoshi committed Jul 28, 2016
1 parent b021581 commit 77d9048
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
1 change: 1 addition & 0 deletions BrowserSelect/BrowserSelect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<Compile Include="BrowserUC.Designer.cs">
<DependentUpon>BrowserUC.cs</DependentUpon>
</Compile>
<Compile Include="ForegroundAgent.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
48 changes: 48 additions & 0 deletions BrowserSelect/ForegroundAgent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace BrowserSelect
{
// aquired from:
// http://stackoverflow.com/a/11065126/1461004
// and
// http://stackoverflow.com/q/9099479/1461004
class ForegroundAgent
{
[DllImport("user32.dll")]
private static extern int SetForegroundWindow(IntPtr hWnd);

private const int SW_SHOWNORMAL = 1;
private const int SW_SHOWMAXIMIZED = 3;
private const int SW_RESTORE = 9;

private const int GWL_STYLE = -16;
private const UInt32 WS_MAXIMIZE = 0x1000000;

[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

[DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);


/// <summary>
/// sets window state of given hWnd to Restore if it is not maximized
/// also gives said window focus (setForegroundWindow)
/// </summary>
/// <param name="hwnd">hWnd of window to be restored</param>
public static void RestoreWindow(int hwnd)
{

var hWnd = new IntPtr(hwnd);

int style = GetWindowLong(hWnd, GWL_STYLE);
if ((style & WS_MAXIMIZE) != WS_MAXIMIZE)
ShowWindow(hWnd, SW_RESTORE);
SetForegroundWindow(hWnd);
}
}
}
2 changes: 2 additions & 0 deletions BrowserSelect/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public static void open_url(Browser b)
if (iExplorer.Name.EndsWith("Internet Explorer"))
{
iExplorer.Navigate(Program.url, 0x800);
// for issue #10 (bring IE to focus after opening link)
ForegroundAgent.RestoreWindow(iExplorer.HWND);
found = true;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions BrowserSelect/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ it has been tested on windows 7, windows 8.1 and windows 10. requires **.net fra

# Download

you can download browser select here : [Browser select v1.3.1 (197KB)](https://github.com/zumoshi/BrowserSelect/releases/download/1.3.1/BrowserSelect.exe)
you can download browser select here : [Browser select v1.3.2 (198KB)](https://github.com/zumoshi/BrowserSelect/releases/download/1.3.2/BrowserSelect.exe)



# Changelog

v1.3.2
- bugfix to bring IE to foreground if it is already open

v1.3.1
- bugfix for Auto rule creation of domains with subdomains

Expand Down

0 comments on commit 77d9048

Please sign in to comment.