diff --git a/BrowserSelect/BrowserSelect.csproj b/BrowserSelect/BrowserSelect.csproj index 237087b..658bd76 100644 --- a/BrowserSelect/BrowserSelect.csproj +++ b/BrowserSelect/BrowserSelect.csproj @@ -54,6 +54,7 @@ BrowserUC.cs + Form diff --git a/BrowserSelect/ForegroundAgent.cs b/BrowserSelect/ForegroundAgent.cs new file mode 100644 index 0000000..90c69d7 --- /dev/null +++ b/BrowserSelect/ForegroundAgent.cs @@ -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); + + + /// + /// sets window state of given hWnd to Restore if it is not maximized + /// also gives said window focus (setForegroundWindow) + /// + /// hWnd of window to be restored + 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); + } + } +} diff --git a/BrowserSelect/Form1.cs b/BrowserSelect/Form1.cs index ce63ab3..4fd5087 100644 --- a/BrowserSelect/Form1.cs +++ b/BrowserSelect/Form1.cs @@ -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; } diff --git a/BrowserSelect/Properties/AssemblyInfo.cs b/BrowserSelect/Properties/AssemblyInfo.cs index d646859..fd506cb 100644 --- a/BrowserSelect/Properties/AssemblyInfo.cs +++ b/BrowserSelect/Properties/AssemblyInfo.cs @@ -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")] diff --git a/README.md b/README.md index 806c60b..1505386 100644 --- a/README.md +++ b/README.md @@ -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