diff --git a/WinAlfred/Helper/GlobalKeyboardHook.cs b/WinAlfred/Helper/GlobalKeyboardHook.cs
new file mode 100644
index 0000000000..f3c71e59e7
--- /dev/null
+++ b/WinAlfred/Helper/GlobalKeyboardHook.cs
@@ -0,0 +1,343 @@
+/// KEYBOARD.CS
+/// (c) 2006 by Emma Burrows
+/// This file contains the following items:
+/// - KeyboardHook: class to enable low-level keyboard hook using
+/// the Windows API.
+/// - KeyboardHookEventHandler: delegate to handle the KeyIntercepted
+/// event raised by the KeyboardHook class.
+/// - KeyboardHookEventArgs: EventArgs class to contain the information
+/// returned by the KeyIntercepted event.
+
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+
+namespace WinAlfred.Helper
+{
+ ///
+ /// Low-level keyboard intercept class to trap and suppress system keys.
+ ///
+ public class GlobalKeyboardHook : IDisposable
+ {
+ ///
+ /// Parameters accepted by the KeyboardHook constructor.
+ ///
+ public enum Parameters
+ {
+ None,
+ AllowAltTab,
+ AllowWindowsKey,
+ AllowAltTabAndWindows,
+ PassAllKeysToNextApp
+ }
+
+ //Internal parameters
+ private bool PassAllKeysToNextApp = false;
+ private bool AllowAltTab = false;
+ private bool AllowWindowsKey = false;
+
+ //Keyboard API constants
+ private const int WH_KEYBOARD_LL = 13;
+ private const int WM_KEYUP = 0x0101;
+ private const int WM_SYSKEYUP = 0x0105;
+
+ //Modifier key constants
+ private const int VK_SHIFT = 0x10;
+ private const int VK_CONTROL = 0x11;
+ private const int VK_MENU = 0x12;
+ private const int VK_CAPITAL = 0x14;
+
+ //Variables used in the call to SetWindowsHookEx
+ private HookHandlerDelegate proc;
+ private IntPtr hookID = IntPtr.Zero;
+ internal delegate IntPtr HookHandlerDelegate(
+ int nCode, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam);
+
+ ///
+ /// Event triggered when a keystroke is intercepted by the
+ /// low-level hook.
+ ///
+ public event KeyboardHookEventHandler KeyIntercepted;
+
+ // Structure returned by the hook whenever a key is pressed
+ internal struct KBDLLHOOKSTRUCT
+ {
+ public int vkCode;
+ int scanCode;
+ public int flags;
+ int time;
+ int dwExtraInfo;
+ }
+
+ #region Constructors
+ ///
+ /// Sets up a keyboard hook to trap all keystrokes without
+ /// passing any to other applications.
+ ///
+ public GlobalKeyboardHook()
+ {
+ proc = new HookHandlerDelegate(HookCallback);
+ using (Process curProcess = Process.GetCurrentProcess())
+ using (ProcessModule curModule = curProcess.MainModule)
+ {
+ hookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, proc,
+ NativeMethods.GetModuleHandle(curModule.ModuleName), 0);
+ }
+ }
+
+ ///
+ /// Sets up a keyboard hook with custom parameters.
+ ///
+ /// A valid name from the Parameter enum; otherwise, the
+ /// default parameter Parameter.None will be used.
+ public GlobalKeyboardHook(string param)
+ : this()
+ {
+ if (!String.IsNullOrEmpty(param) && Enum.IsDefined(typeof(Parameters), param))
+ {
+ SetParameters((Parameters)Enum.Parse(typeof(Parameters), param));
+ }
+ }
+
+ ///
+ /// Sets up a keyboard hook with custom parameters.
+ ///
+ /// A value from the Parameters enum.
+ public GlobalKeyboardHook(Parameters param)
+ : this()
+ {
+ SetParameters(param);
+ }
+
+ private void SetParameters(Parameters param)
+ {
+ switch (param)
+ {
+ case Parameters.None:
+ break;
+ case Parameters.AllowAltTab:
+ AllowAltTab = true;
+ break;
+ case Parameters.AllowWindowsKey:
+ AllowWindowsKey = true;
+ break;
+ case Parameters.AllowAltTabAndWindows:
+ AllowAltTab = true;
+ AllowWindowsKey = true;
+ break;
+ case Parameters.PassAllKeysToNextApp:
+ PassAllKeysToNextApp = true;
+ break;
+ }
+ }
+ #endregion
+
+ #region Check Modifier keys
+ ///
+ /// Checks whether Alt, Shift, Control or CapsLock
+ /// is enabled at the same time as another key.
+ /// Modify the relevant sections and return type
+ /// depending on what you want to do with modifier keys.
+ ///
+ private void CheckModifiers()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if ((NativeMethods.GetKeyState(VK_CAPITAL) & 0x0001) != 0)
+ {
+ //CAPSLOCK is ON
+ sb.AppendLine("Capslock is enabled.");
+ }
+
+ if ((NativeMethods.GetKeyState(VK_SHIFT) & 0x8000) != 0)
+ {
+ //SHIFT is pressed
+ sb.AppendLine("Shift is pressed.");
+ }
+ if ((NativeMethods.GetKeyState(VK_CONTROL) & 0x8000) != 0)
+ {
+ //CONTROL is pressed
+ sb.AppendLine("Control is pressed.");
+ }
+ if ((NativeMethods.GetKeyState(VK_MENU) & 0x8000) != 0)
+ {
+ //ALT is pressed
+ sb.AppendLine("Alt is pressed.");
+ }
+ Console.WriteLine(sb.ToString());
+ }
+ #endregion Check Modifier keys
+
+ #region Hook Callback Method
+ ///
+ /// Processes the key event captured by the hook.
+ ///
+ private IntPtr HookCallback(
+ int nCode, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam)
+ {
+ bool AllowKey = PassAllKeysToNextApp;
+
+ //Filter wParam for KeyUp events only
+ if (nCode >= 0)
+ {
+ if (wParam == (IntPtr)WM_KEYUP || wParam == (IntPtr)WM_SYSKEYUP)
+ {
+
+ // Check for modifier keys, but only if the key being
+ // currently processed isn't a modifier key (in other
+ // words, CheckModifiers will only run if Ctrl, Shift,
+ // CapsLock or Alt are active at the same time as
+ // another key)
+ if (!(lParam.vkCode >= 160 && lParam.vkCode <= 164))
+ {
+ CheckModifiers();
+ }
+
+ // Check for key combinations that are allowed to
+ // get through to Windows
+ //
+ // Ctrl+Esc or Windows key
+ if (AllowWindowsKey)
+ {
+ switch (lParam.flags)
+ {
+ //Ctrl+Esc
+ case 0:
+ if (lParam.vkCode == 27)
+ AllowKey = true;
+ break;
+
+ //Windows keys
+ case 1:
+ if ((lParam.vkCode == 91) || (lParam.vkCode == 92))
+ AllowKey = true;
+ break;
+ }
+ }
+ // Alt+Tab
+ if (AllowAltTab)
+ {
+ if ((lParam.flags == 32) && (lParam.vkCode == 9))
+ AllowKey = true;
+ }
+
+ OnKeyIntercepted(new KeyboardHookEventArgs(lParam.vkCode, AllowKey));
+ }
+
+ //If this key is being suppressed, return a dummy value
+ if (AllowKey == false)
+ return (System.IntPtr)1;
+ }
+ //Pass key to next application
+ return NativeMethods.CallNextHookEx(hookID, nCode, wParam, ref lParam);
+
+ }
+ #endregion
+
+ #region Event Handling
+ ///
+ /// Raises the KeyIntercepted event.
+ ///
+ /// An instance of KeyboardHookEventArgs
+ public void OnKeyIntercepted(KeyboardHookEventArgs e)
+ {
+ if (KeyIntercepted != null)
+ KeyIntercepted(e);
+ }
+
+ ///
+ /// Delegate for KeyboardHook event handling.
+ ///
+ /// An instance of InterceptKeysEventArgs.
+ public delegate void KeyboardHookEventHandler(KeyboardHookEventArgs e);
+
+ ///
+ /// Event arguments for the KeyboardHook class's KeyIntercepted event.
+ ///
+ public class KeyboardHookEventArgs : System.EventArgs
+ {
+
+ private string keyName;
+ private int keyCode;
+ private bool passThrough;
+
+ ///
+ /// The name of the key that was pressed.
+ ///
+ public string KeyName
+ {
+ get { return keyName; }
+ }
+
+ ///
+ /// The virtual key code of the key that was pressed.
+ ///
+ public int KeyCode
+ {
+ get { return keyCode; }
+ }
+
+ ///
+ /// True if this key combination was passed to other applications,
+ /// false if it was trapped.
+ ///
+ public bool PassThrough
+ {
+ get { return passThrough; }
+ }
+
+ public KeyboardHookEventArgs(int evtKeyCode, bool evtPassThrough)
+ {
+ keyName = ((Keys)evtKeyCode).ToString();
+ keyCode = evtKeyCode;
+ passThrough = evtPassThrough;
+ }
+
+ }
+
+ #endregion
+
+ #region IDisposable Members
+ ///
+ /// Releases the keyboard hook.
+ ///
+ public void Dispose()
+ {
+ NativeMethods.UnhookWindowsHookEx(hookID);
+ }
+ #endregion
+
+ #region Native methods
+
+ [ComVisible(false),
+ System.Security.SuppressUnmanagedCodeSecurity()]
+ internal class NativeMethods
+ {
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr GetModuleHandle(string lpModuleName);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr SetWindowsHookEx(int idHook,
+ HookHandlerDelegate lpfn, IntPtr hMod, uint dwThreadId);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool UnhookWindowsHookEx(IntPtr hhk);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
+ IntPtr wParam, ref KBDLLHOOKSTRUCT lParam);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
+ public static extern short GetKeyState(int keyCode);
+
+ }
+
+
+ #endregion
+ }
+}
+
+
diff --git a/WinAlfred/Helper/Settings.cs b/WinAlfred/Helper/Settings.cs
index 3d58177b32..40beac986f 100644
--- a/WinAlfred/Helper/Settings.cs
+++ b/WinAlfred/Helper/Settings.cs
@@ -13,6 +13,7 @@ namespace WinAlfred.Helper
IniParser parser = new IniParser("config.ini");
public string Theme { get; set; }
+ public bool ReplaceWinR { get; set; }
private Settings()
{
@@ -23,11 +24,19 @@ namespace WinAlfred.Helper
{
if (!File.Exists(configPath)) File.Create(configPath);
Theme = parser.GetSetting("ui", "theme");
+
+ string replaceWinRStr = parser.GetSetting("hotkey", "replaceWinR");
+ bool replace = true;
+ if (bool.TryParse(replaceWinRStr, out replace))
+ {
+ ReplaceWinR = replace;
+ }
}
public void SaveSettings()
{
parser.AddSetting("ui", "theme", Theme);
+ parser.AddSetting("hotkey", "replaceWinR", ReplaceWinR.ToString());
parser.SaveSettings();
}
diff --git a/WinAlfred/KeyboardListener.cs b/WinAlfred/KeyboardListener.cs
new file mode 100644
index 0000000000..36cc545526
--- /dev/null
+++ b/WinAlfred/KeyboardListener.cs
@@ -0,0 +1,245 @@
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows.Input;
+using System.Windows.Threading;
+
+namespace WinAlfred
+{
+ public enum KeyEvent : int
+ {
+ ///
+ /// Key down
+ ///
+ WM_KEYDOWN = 256,
+
+ ///
+ /// Key up
+ ///
+ WM_KEYUP = 257,
+
+ ///
+ /// System key up
+ ///
+ WM_SYSKEYUP = 261,
+
+ ///
+ /// System key down
+ ///
+ WM_SYSKEYDOWN = 260
+ }
+
+ public class SpecialKeyState
+ {
+ public bool CtrlPressed { get; set; }
+ public bool ShiftPressed { get; set; }
+ public bool AltPressed { get; set; }
+ public bool WinPressed { get; set; }
+ }
+
+ ///
+ /// Listens keyboard globally.
+ ///
+ /// Uses WH_KEYBOARD_LL.
+ ///
+ public class KeyboardListener : IDisposable
+ {
+ private InterceptKeys.LowLevelKeyboardProc hookedLowLevelKeyboardProc;
+ private IntPtr hookId = IntPtr.Zero;
+ public delegate bool KeyboardCallback(KeyEvent keyEvent, int vkCode, SpecialKeyState state);
+ public event KeyboardCallback hookedKeyboardCallback;
+
+ //Modifier key constants
+ private const int VK_SHIFT = 0x10;
+ private const int VK_CONTROL = 0x11;
+ private const int VK_ALT = 0x12;
+ private const int VK_WIN = 91;
+
+ public KeyboardListener()
+ {
+ // We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
+ hookedLowLevelKeyboardProc = LowLevelKeyboardProc;
+ // Set the hook
+ hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);
+ }
+
+ private SpecialKeyState CheckModifiers()
+ {
+ SpecialKeyState state = new SpecialKeyState();
+ if ((InterceptKeys.GetKeyState(VK_SHIFT) & 0x8000) != 0)
+ {
+ //SHIFT is pressed
+ state.ShiftPressed = true;
+ }
+ if ((InterceptKeys.GetKeyState(VK_CONTROL) & 0x8000) != 0)
+ {
+ //CONTROL is pressed
+ state.CtrlPressed = true;
+ }
+ if ((InterceptKeys.GetKeyState(VK_ALT) & 0x8000) != 0)
+ {
+ //ALT is pressed
+ state.AltPressed = true;
+ }
+ if ((InterceptKeys.GetKeyState(VK_WIN) & 0x8000) != 0)
+ {
+ //ALT is pressed
+ state.WinPressed = true;
+ }
+
+ return state;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam)
+ {
+ bool continues = true;
+
+ if (nCode >= 0)
+ {
+ if (wParam.ToUInt32() == (int)KeyEvent.WM_KEYDOWN ||
+ wParam.ToUInt32() == (int)KeyEvent.WM_KEYUP ||
+ wParam.ToUInt32() == (int)KeyEvent.WM_SYSKEYDOWN ||
+ wParam.ToUInt32() == (int)KeyEvent.WM_SYSKEYUP)
+ {
+ continues = hookedKeyboardCallback((KeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), CheckModifiers());
+ }
+ }
+
+ if (continues)
+ {
+ return InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam);
+ }
+ return (IntPtr)1;
+ }
+
+ ~KeyboardListener()
+ {
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ InterceptKeys.UnhookWindowsHookEx(hookId);
+ }
+ }
+
+ public static class InterceptKeys
+ {
+ public delegate IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam);
+
+ private static int WH_KEYBOARD_LL = 13;
+
+ public static IntPtr SetHook(LowLevelKeyboardProc proc)
+ {
+ using (Process curProcess = Process.GetCurrentProcess())
+ using (ProcessModule curModule = curProcess.MainModule)
+ {
+ return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
+ }
+ }
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool UnhookWindowsHookEx(IntPtr hhk);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, UIntPtr wParam, IntPtr lParam);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr GetModuleHandle(string lpModuleName);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
+ public static extern short GetKeyState(int keyCode);
+
+ [DllImport("user32.dll")]
+ internal static extern uint SendInput(uint nInputs, [MarshalAs(UnmanagedType.LPArray), In] INPUT[] pInputs, int cbSize);
+
+
+ public static void SendKeyStroke(int funckey, int key)
+ {
+ INPUT[] input = new INPUT[4];
+ input[0].type = input[1].type = input[2].type = input[3].type = (int)InputType.INPUT_KEYBOARD;
+ input[0].ki.wVk = input[2].ki.wVk = (short) funckey;
+ input[1].ki.wVk = input[3].ki.wVk = (short) key;
+
+ input[2].ki.dwFlags = input[3].ki.dwFlags =(int) KEYEVENTF.KEYUP;
+
+ SendInput((uint)input.Length, input, Marshal.SizeOf(input[0]));
+ }
+ }
+
+ public enum InputType
+ {
+ INPUT_MOUSE = 0,
+ INPUT_KEYBOARD = 1,
+ INPUT_HARDWARE = 2,
+ }
+ [Flags()]
+ public enum MOUSEEVENTF
+ {
+ MOVE = 0x0001, //mouse move
+ LEFTDOWN = 0x0002, //left button down
+ LEFTUP = 0x0004, //left button up
+ RIGHTDOWN = 0x0008, //right button down
+ RIGHTUP = 0x0010, //right button up
+ MIDDLEDOWN = 0x0020, //middle button down
+ MIDDLEUP = 0x0040, //middle button up
+ XDOWN = 0x0080, //x button down
+ XUP = 0x0100, //x button down
+ WHEEL = 0x0800, //wheel button rolled
+ VIRTUALDESK = 0x4000, //map to entire virtual desktop
+ ABSOLUTE = 0x8000, //absolute move
+ }
+
+ [Flags()]
+ public enum KEYEVENTF
+ {
+ EXTENDEDKEY = 0x0001,
+ KEYUP = 0x0002,
+ UNICODE = 0x0004,
+ SCANCODE = 0x0008,
+ }
+ [StructLayout(LayoutKind.Explicit)]
+ public struct INPUT
+ {
+ [FieldOffset(0)]
+ public Int32 type;//0-MOUSEINPUT;1-KEYBDINPUT;2-HARDWAREINPUT
+ [FieldOffset(4)]
+ public KEYBDINPUT ki;
+ [FieldOffset(4)]
+ public MOUSEINPUT mi;
+ [FieldOffset(4)]
+ public HARDWAREINPUT hi;
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public struct MOUSEINPUT
+ {
+ public Int32 dx;
+ public Int32 dy;
+ public Int32 mouseData;
+ public Int32 dwFlags;
+ public Int32 time;
+ public IntPtr dwExtraInfo;
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public struct KEYBDINPUT
+ {
+ public Int16 wVk;
+ public Int16 wScan;
+ public Int32 dwFlags;
+ public Int32 time;
+ public IntPtr dwExtraInfo;
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HARDWAREINPUT
+ {
+ public Int32 uMsg;
+ public Int16 wParamL;
+ public Int16 wParamH;
+ }
+}
\ No newline at end of file
diff --git a/WinAlfred/MainWindow.xaml b/WinAlfred/MainWindow.xaml
index 5d9ee64dd3..4c8f39538a 100644
--- a/WinAlfred/MainWindow.xaml
+++ b/WinAlfred/MainWindow.xaml
@@ -7,12 +7,12 @@
SizeToContent="Height"
ResizeMode="NoResize"
WindowStyle="None"
- WindowStartupLocation="CenterScreen"
+ WindowStartupLocation="Manual"
ShowInTaskbar="False"
Style="{DynamicResource WindowStyle}"
Icon="Images\app.png"
>
-
+
diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs
index a75a10912d..50ced85aaf 100644
--- a/WinAlfred/MainWindow.xaml.cs
+++ b/WinAlfred/MainWindow.xaml.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
@@ -26,6 +28,9 @@ namespace WinAlfred
private bool queryHasReturn = false;
SelectedRecords selectedRecords = new SelectedRecords();
+ private KeyboardListener keyboardListener = new KeyboardListener();
+ private bool WinRStroked = false;
+
public MainWindow()
{
InitializeComponent();
@@ -36,7 +41,9 @@ namespace WinAlfred
ThreadPool.SetMaxThreads(30, 10);
InitProgressbarAnimation();
+
ChangeStyles(Settings.Instance.Theme);
+
}
private void WakeupApp()
@@ -45,7 +52,7 @@ namespace WinAlfred
//This is caused by the Virtual Mermory Page Mechanisam. So, our solution is execute some codes in every min
//which may prevent sysetem uninstall memory from RAM to disk.
- System.Timers.Timer t = new System.Timers.Timer(1000 * 60 * 3) { AutoReset = true, Enabled = true };
+ System.Timers.Timer t = new System.Timers.Timer(1000 * 60 * 5) { AutoReset = true, Enabled = true };
t.Elapsed += (o, e) => Dispatcher.Invoke(new Action(() =>
{
if (Visibility != Visibility.Visible)
@@ -87,8 +94,7 @@ namespace WinAlfred
private void resultCtrl_resultItemChangedEvent()
{
- //Height = resultCtrl.pnlContainer.ActualHeight + tbQuery.Height + tbQuery.Margin.Top + tbQuery.Margin.Bottom;
- resultCtrl.Margin = resultCtrl.GetCurrentResultCount() > 0 ? new Thickness { Top = 10 } : new Thickness { Top = 0 };
+ resultCtrl.Margin = resultCtrl.GetCurrentResultCount() > 0 ? new Thickness { Top = grid.Margin.Top } : new Thickness { Top = 0 };
}
private void OnHotKey(object sender, KeyPressedEventArgs e)
@@ -153,8 +159,9 @@ namespace WinAlfred
{
Show();
Activate();
- tbQuery.Focus();
tbQuery.SelectAll();
+ Focus();
+ tbQuery.Focus();
}
public void ParseArgs(string[] args)
@@ -200,6 +207,9 @@ namespace WinAlfred
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
+ Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
+ Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
+
Plugins.Init(this);
cmdDispatcher = new Command(this);
InitialTray();
@@ -208,6 +218,32 @@ namespace WinAlfred
WakeupApp();
//var engine = new Jurassic.ScriptEngine();
//MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString());
+ keyboardListener.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
+ }
+
+ private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
+ {
+ if (Settings.Instance.ReplaceWinR)
+ {
+ if (keyevent == KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
+ {
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ resultCtrl.Clear();
+ ShowWinAlfred();
+ ChangeQuery(">");
+ WinRStroked = true;
+ }));
+ return false;
+ }
+ if (keyevent == KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin)
+ {
+ WinRStroked = false;
+ WindowsInput.InputSimulator.SimulateModifiedKeyStroke(WindowsInput.VirtualKeyCode.LWIN, WindowsInput.VirtualKeyCode.CONTROL);
+ return false;
+ }
+ }
+ return true;
}
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
@@ -250,7 +286,7 @@ namespace WinAlfred
progressBar.Dispatcher.Invoke(new Action(StopProgress));
if (list.Count > 0)
{
- //todo:this used be opened to users, it's they choise use it or not in thier workflows
+ //todo:this should be opened to users, it's their choise to use it or not in thier workflows
list.ForEach(o =>
{
if (o.AutoAjustScore) o.Score += selectedRecords.GetSelectedCount(o);
@@ -314,6 +350,5 @@ namespace WinAlfred
#endregion
-
}
}
\ No newline at end of file
diff --git a/WinAlfred/SettingWindow.xaml b/WinAlfred/SettingWindow.xaml
index dab9c17916..96d2551f5c 100644
--- a/WinAlfred/SettingWindow.xaml
+++ b/WinAlfred/SettingWindow.xaml
@@ -6,8 +6,15 @@
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Height="407.447" Width="843.989">
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WinAlfred/SettingWindow.xaml.cs b/WinAlfred/SettingWindow.xaml.cs
index ec62008bec..b3fe0a9308 100644
--- a/WinAlfred/SettingWindow.xaml.cs
+++ b/WinAlfred/SettingWindow.xaml.cs
@@ -16,6 +16,16 @@ namespace WinAlfred
this.mainWindow = mainWindow;
InitializeComponent();
Loaded += Setting_Loaded;
+ cbReplaceWinR.Checked += (o, e) =>
+ {
+ Settings.Instance.ReplaceWinR = true;
+ Settings.Instance.SaveSettings();
+ };
+ cbReplaceWinR.Unchecked += (o, e) =>
+ {
+ Settings.Instance.ReplaceWinR = false;
+ Settings.Instance.SaveSettings();
+ };
}
private void Setting_Loaded(object sender, RoutedEventArgs e)
@@ -27,6 +37,7 @@ namespace WinAlfred
}
themeComboBox.SelectedItem = Settings.Instance.Theme;
+ cbReplaceWinR.IsChecked = Settings.Instance.ReplaceWinR;
}
private List LoadAvailableThemes()
diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj
index 79fdf839e1..9fe39639d2 100644
--- a/WinAlfred/WinAlfred.csproj
+++ b/WinAlfred/WinAlfred.csproj
@@ -41,6 +41,7 @@
DEBUG;TRACE
prompt
4
+ false
AnyCPU
@@ -77,6 +78,9 @@
+
+ C:\Users\Scott\Desktop\InputSimulator.dll
+
..\packages\log4net.2.0.3\lib\net35-full\log4net.dll
@@ -114,10 +118,12 @@
+
+
Msg.xaml