mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-10 20:45:38 +02:00
launch webpage commander notification page from current browser window
This commit is contained in:
parent
0a6c00c3a7
commit
4cece1ab9c
4 changed files with 26 additions and 9 deletions
|
@ -276,7 +276,7 @@ namespace PersistentWindows.Common
|
||||||
StartAliveTimer(1);
|
StartAliveTimer(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsBrowserWindow(IntPtr hwnd)
|
private bool IsBrowserWindow(IntPtr hwnd)
|
||||||
{
|
{
|
||||||
return PersistentWindowProcessor.IsBrowserWindow(hwnd);
|
return PersistentWindowProcessor.IsBrowserWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
@ -1109,7 +1109,7 @@ namespace PersistentWindows.Common
|
||||||
User32.SetForegroundWindow(Handle);
|
User32.SetForegroundWindow(Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetForegroundWindow(bool strict = false)
|
public static IntPtr GetForegroundWindow(bool strict = false)
|
||||||
{
|
{
|
||||||
return PersistentWindowProcessor.GetForegroundWindow(strict);
|
return PersistentWindowProcessor.GetForegroundWindow(strict);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4177,7 +4177,7 @@ namespace PersistentWindows.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string GetProcExePath(uint proc_id)
|
public static string GetProcExePath(uint proc_id)
|
||||||
{
|
{
|
||||||
IntPtr hProcess = Kernel32.OpenProcess(Kernel32.ProcessAccessFlags.QueryInformation, false, proc_id);
|
IntPtr hProcess = Kernel32.OpenProcess(Kernel32.ProcessAccessFlags.QueryInformation, false, proc_id);
|
||||||
string pathToExe = string.Empty;
|
string pathToExe = string.Empty;
|
||||||
|
|
|
@ -63,8 +63,9 @@ namespace PersistentWindows.SystrayShell
|
||||||
User32.KeyModifier modifier = (User32.KeyModifier)((int)m.LParam & 0xFFFF); // The modifier of the hotkey that was pressed.
|
User32.KeyModifier modifier = (User32.KeyModifier)((int)m.LParam & 0xFFFF); // The modifier of the hotkey that was pressed.
|
||||||
int id = m.WParam.ToInt32(); // The id of the hotkey that was pressed.
|
int id = m.WParam.ToInt32(); // The id of the hotkey that was pressed.
|
||||||
|
|
||||||
|
IntPtr fgWnd = PersistentWindowProcessor.GetForegroundWindow(strict : true);
|
||||||
hkwin.HotKeyPressed(from_menu : false);
|
hkwin.HotKeyPressed(from_menu : false);
|
||||||
if (HotKeyWindow.invokedFromBrowser)
|
if (PersistentWindowProcessor.IsBrowserWindow(fgWnd))
|
||||||
{
|
{
|
||||||
Program.HideRestoreTip(false); //hide icon
|
Program.HideRestoreTip(false); //hide icon
|
||||||
Program.HideRestoreTip(); //show icon
|
Program.HideRestoreTip(); //show icon
|
||||||
|
@ -73,12 +74,28 @@ namespace PersistentWindows.SystrayShell
|
||||||
{
|
{
|
||||||
init = false;
|
init = false;
|
||||||
string webpage_commander_notification = Path.Combine(Program.AppdataFolder, "webpage_commander_notification");
|
string webpage_commander_notification = Path.Combine(Program.AppdataFolder, "webpage_commander_notification");
|
||||||
if (!File.Exists(webpage_commander_notification))
|
if (File.Exists(webpage_commander_notification))
|
||||||
{
|
{
|
||||||
File.Create(webpage_commander_notification);
|
Program.systrayForm.notifyIconMain.ShowBalloonTip(8000, "webpage commander is invoked via hotkey", "Press the hotkey (Alt + W) again to revoke", ToolTipIcon.Info);
|
||||||
Process.Start(Program.ProjectUrl + "/blob/master/webpage_commander.md");
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Create(webpage_commander_notification);
|
||||||
|
|
||||||
|
uint processId;
|
||||||
|
User32.GetWindowThreadProcessId(fgWnd, out processId);
|
||||||
|
string procPath = PersistentWindowProcessor.GetProcExePath(processId);
|
||||||
|
Process.Start(procPath, Program.ProjectUrl + "/blob/master/webpage_commander.md");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.ToString());
|
||||||
|
Program.systrayForm.notifyIconMain.ShowBalloonTip(8000, "webpage commander is invoked via hotkey", "Press the hotkey (Alt + W) again to revoke", ToolTipIcon.Info);
|
||||||
|
Process.Start(Program.ProjectUrl + "/blob/master/webpage_commander.md");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Program.systrayForm.notifyIconMain.ShowBalloonTip(8000, "webpage commander is invoked via hotkey", "Press the hotkey (Alt + W) again to revoke", ToolTipIcon.Info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace PersistentWindows.SystrayShell
|
||||||
|
|
||||||
private const int MaxSnapshots = 38; // 0-9, a-z, ` and final one for undo
|
private const int MaxSnapshots = 38; // 0-9, a-z, ` and final one for undo
|
||||||
|
|
||||||
static PersistentWindowProcessor pwp = null;
|
public static PersistentWindowProcessor pwp = null;
|
||||||
public static SystrayForm systrayForm = null;
|
public static SystrayForm systrayForm = null;
|
||||||
static bool silent = false; //suppress all balloon tip & sound prompt
|
static bool silent = false; //suppress all balloon tip & sound prompt
|
||||||
static bool notification = false; //pop balloon when auto restore
|
static bool notification = false; //pop balloon when auto restore
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue