Beispiel #1
0
        public static void AddHotkey(TreeNode parent, string name, HotKeyCallback callback)
        {
            KeyData key = HotKey.Add(HKCategory.None, HKSubCat.None, name, callback);

            key.Remove();
            key.m_Node = HotKey.MakeNode(parent, key.StrName, key);
        }
        /// <summary>
        /// Register a new global hot key. This will throw an exception if the hot
        /// key is already registered.
        /// </summary>
        /// <param name="modifiedKey">The modified key.</param>
        /// <param name="HotKeyCallback">A callback that will be invoked when the HotKey is pressed.</param>
        public void Register(ModifiedKey modifiedKey, HotKeyCallback hotKeyCallback)
        {
            modifiedKey.ThrowIfNull("modifiedKey");

            hotKeyCallback.ThrowIfNull("hotKeyCallback");
            Register(modifiedKey.Modifiers, modifiedKey.Key, hotKeyCallback);
        }
Beispiel #3
0
        public static KeyData Add(HKCategory cat, HKSubCat sub, string name, HotKeyCallback callback)
        {
            KeyData kd = new KeyData(name, cat, sub, callback);

            m_List.Add(kd);
            return(kd);
        }
Beispiel #4
0
        public SPApiWrapper()
        {
            hNVSPapi = LoadLibrary(@"C:/Program Files (x86)/NVIDIA Corporation/ShadowPlay/nvspapi.dll");

            IntPtr hCreateShadowPlayApiInterface = GetProcAddress(hNVSPapi, "CreateShadowPlayApiInterface");
            CreateShadowPlayApiInterface createShadowPlayApiInterface
                = (CreateShadowPlayApiInterface)Marshal.GetDelegateForFunctionPointer(hCreateShadowPlayApiInterface, typeof(CreateShadowPlayApiInterface));

            CShadowPlayApiProxyInterface ppvInterface = new CShadowPlayApiProxyInterface
            {
                api = Marshal.AllocHGlobal(4)
            };

            CreateShadowPlayApiParams createShadowPlayApiParams = new CreateShadowPlayApiParams
            {
                api_version   = 0x10010,
                interface_ver = 0x10004,
                client        = 0,
                ppvInterface  = ppvInterface
            };

            int result = createShadowPlayApiInterface(ref createShadowPlayApiParams);

            hProxyInterface = Marshal.ReadIntPtr(ppvInterface.api);
            api             = Marshal.PtrToStructure <CShadowPlayApi>(Marshal.ReadIntPtr(hProxyInterface));

            hotkeyCB += (IntPtr unk01, IntPtr unk02) =>
            {
                if ((bool)Application.Current.Properties["IsHotkeysEnabled"])
                {
                    byte hotkeyId = Marshal.ReadByte(unk02 + 20);
                    byte state    = Marshal.ReadByte(unk02 + 21);
                    switch (hotkeyId)
                    {
                    case (byte)HotKeys.SAVE_IR: ExecuteCaptureCommand(IRAction.SaveInstantReplay); break;

                    case (byte)HotKeys.TOGGLE_RECORD: this.ToggleManualRecord(); break;
                    }
                }


                return(0);
            };
            notificationCB += (IntPtr unk01) =>
            {
                IntPtr obj   = Marshal.ReadIntPtr(unk01 + 28);
                int    msgId = Marshal.ReadInt32(obj);
                if (msgId == 0x00010218)
                {
                    if (OnFileSaved != null)
                    {
                        string filename = Marshal.PtrToStringAuto(obj + 16);
                        Application.Current.Dispatcher.Invoke(() => { OnFileSaved(this, filename); });
                    }
                }
                return(0);
            };
            RegisterCallback(1, hotkeyCB);
            RegisterCallback(2, notificationCB);
        }
Beispiel #5
0
 public KeyData(string name, HKCategory cat, HKSubCat sub, HotKeyCallback call)
 {
     m_Name          = 0;
     m_SName         = name;
     m_Callback      = call;
     m_CallbackState = null;
     m_Node          = HotKey.MakeNode(HotKey.FindParent(cat, sub), ToString(), this);
 }
Beispiel #6
0
 public KeyData(int name, HKCategory cat, HKSubCat sub, HotKeyCallbackState call, object state)
 {
     m_Name          = name;
     m_SName         = null;
     m_Callback      = null;
     m_CallbackState = call;
     m_State         = state;
     m_Node          = HotKey.MakeNode(HotKey.FindParent(cat, sub), ToString(), this);
 }
Beispiel #7
0
        /// <summary>
        /// Creates a GlobalHotKey object.
        /// </summary>
        /// <param name="modifier">HotKey modifier keys</param>
        /// <param name="key">HotKey</param>
        /// <param name="window">The Window that the HotKey should be registered to</param>
        /// <param name="callback">The delegate to call when the HotKey is pressed.</param>
        /// <param name="registerImmediately"> </param>
        public GlobalHotKey(Modifiers modifier, Keys key, IWin32Window window, HotKeyCallback callback, bool registerImmediately = false)
        {
            window.ThrowIfNull("window", "You must provide a form or window to register the HotKey against.");
            callback.ThrowIfNull("callback", "You must specify a callback in order to do some useful work when your HotKey is pressed.");

            Modifier = modifier;
            Key      = (int)key;
            hWnd     = window.Handle;
            Id       = GetHashCode();
            Callback = callback;

            if (registerImmediately)
            {
                Register();
            }
        }
        /// <summary>
        /// Register a new global hot key. This will throw an exception if the hot
        /// key is already registered.
        /// </summary>
        /// <param name="modifiers">Key modifiers (Shift, Alt etc.) that you want applied.</param>
        /// <param name="key">The key.</param>
        /// <param name="HotKeyCallback">A callback that will be invoked when the HotKey is pressed.</param>
        public void Register(Modifiers modifiers, Keys key, HotKeyCallback hotKeyCallback)
        {
            modifiers.ThrowIfNull("modifiers");
            key.ThrowIfNull("key");
            hotKeyCallback.ThrowIfNull("hotKeyCallback");

            string keystr = ModifiedKey.ToString(modifiers, key);

            log.Debug("RegisterGlobalHotKey, Hot key = " + keystr);

            // For multi-threaded apps, we need to be careful to use the form's handle
            // on the same thread as it was initially created.
            if (MessageLoopForm.InvokeRequired)
            {
                MessageLoopForm.Invoke(new MethodInvoker(delegate { InternalRegister(modifiers, key, hotKeyCallback); }));
            }
            else
            {
                InternalRegister(modifiers, key, hotKeyCallback);
            }

            log.Debug(keystr + " successfully registered");
        }
Beispiel #9
0
 static unsafe CallbackHolder()
 {
     HotKeyCallback = OnHotKey;
 }
Beispiel #10
0
 public KeyData( string name, HKCategory cat, HKSubCat sub, HotKeyCallbackState call, object state )
 {
     m_Name = 0;
     m_SName = name;
     m_Callback = null;
     m_CallbackState = call;
     m_State = state;
     m_Node = HotKey.MakeNode( HotKey.FindParent( cat, sub ), ToString(), this );
 }
Beispiel #11
0
 //public HotKeyCallback Callback{ get{ return m_Callback; } }
 public KeyData( int name, HKCategory cat, HKSubCat sub, HotKeyCallback call )
 {
     m_Name = name;
     m_SName = null;
     m_Callback = call;
     m_CallbackState = null;
     m_Node = HotKey.MakeNode( HotKey.FindParent( cat, sub ), ToString(), this );
 }
Beispiel #12
0
 public static KeyData Add( HKCategory cat, HKSubCat sub, string name, HotKeyCallback callback )
 {
     KeyData kd = new KeyData( name, cat, sub, callback );
     m_List.Add( kd );
     return kd;
 }
Beispiel #13
0
 public static void AddHotkey(string name, HotKeyCallback callback)
 {
     AddHotkey(node.Value, name, callback);
 }
Beispiel #14
0
 public static void AddHotkey(TreeNode parent, string name, HotKeyCallback callback)
 {
     KeyData key = HotKey.Add(HKCategory.None, HKSubCat.None, name, callback);
     key.Remove();
     key.m_Node = HotKey.MakeNode(parent, key.StrName, key);
 }
Beispiel #15
0
 public static KeyData Add(HKCategory cat, int name, HotKeyCallback callback)
 {
     return(Add(cat, HKSubCat.None, name, callback));
 }
        void InternalRegister(Modifiers modifiers, Keys key, HotKeyCallback HotKeyCallback)
        {
            var hk = new GlobalHotKey(modifiers, key, MessageLoopForm, HotKeyCallback, true);

            HotKeys.Add(hk);
        }
Beispiel #17
0
 public static void AddHotkey(string name, HotKeyCallback callback)
 {
     AddHotkey(node.Value, name, callback);
 }
Beispiel #18
0
 public static extern void SetHotKeyCallback(HotKeyCallback callback);
Beispiel #19
0
 public static KeyData Add(HKCategory cat, LocString name, HotKeyCallback callback)
 {
     return(Add(cat, HKSubCat.None, (int)name, callback));
 }
Beispiel #20
0
 public static KeyData Add( HKCategory cat, int name, HotKeyCallback callback )
 {
     return Add( cat, HKSubCat.None, name, callback );
 }
Beispiel #21
0
 public static KeyData Add( HKCategory cat, LocString name, HotKeyCallback callback )
 {
     return Add( cat, HKSubCat.None, (int)name, callback );
 }
Beispiel #22
0
 public static extern void SetHotKeyCallback(HotKeyCallback callback);