Пример #1
0
 private Key VKeyToKey(int vKey)
 {
     return(KeyInterop.KeyFromVirtualKey(vKey));
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nCode"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns></returns>
        protected IntPtr HookProcHandler(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                MessageType     flag    = (MessageType)wParam;
                KBDLLHOOKSTRUCT keyData = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));

                Console.WriteLine("Flag:{0} KeyData:{1}", flag, keyData);


                //按下控制键
                if ((KeyDown != null || KeyPress != null) && (flag == MessageType.WM_KEYDOWN || flag == MessageType.WM_SYSKEYDOWN))
                {
                    if (IsCtrlAltShiftKeys(keyData.vkCode) && KeysList.IndexOf(keyData) == -1)
                    {
                        KeysList.Add(keyData);
                    }
                }
                //松开控制键
                if ((KeyDown != null || KeyPress != null) && (flag == MessageType.WM_KEYUP || flag == MessageType.WM_SYSKEYUP))
                {
                    if (IsCtrlAltShiftKeys(keyData.vkCode))
                    {
                        for (int i = KeysList.Count - 1; i >= 0; i--)
                        {
                            if (KeysList[i].vkCode == keyData.vkCode)
                            {
                                KeysList.RemoveAt(i);
                            }
                        }
                    }
                }

                if (KeyDown != null && (flag == MessageType.WM_KEYDOWN || flag == MessageType.WM_SYSKEYDOWN))
                {
                    KeyEventArgs Args = new KeyEventArgs(null, null, (int)keyData.time, KeyInterop.KeyFromVirtualKey((int)keyData.vkCode));
                    KeyDown(this, Args);
                }

                if (KeyUp != null && (flag == MessageType.WM_KEYUP || flag == MessageType.WM_SYSKEYUP))
                {
                    KeyEventArgs Args = new KeyEventArgs(null, null, (int)keyData.time, KeyInterop.KeyFromVirtualKey((int)keyData.vkCode));
                    KeyUp(this, Args);
                }

                if (KeyPress != null && flag == MessageType.WM_KEYDOWN)
                {
                    byte[] keyState = new byte[256];
                    User32.GetKeyboardState(keyState);
                    byte[] inBuffer = new byte[2];

                    if (User32.ToAscii(keyData.vkCode, (uint)keyData.scanCode, keyState, inBuffer, (uint)keyData.flags) == 1)
                    {
                        Console.WriteLine("KeyChar:{0}", (char)inBuffer[0]);
                        Key k = KeyInterop.KeyFromVirtualKey((int)keyData.vkCode);
                    }
                }
            }

            return(User32.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Пример #3
0
        public Config(VisagePlus visageplus)
        {
            VisagePlus = visageplus;

            Factory = MenuFactory.CreateWithTexture("VisagePlus", "npc_dota_hero_visage");
            Factory.Target.SetFontColor(Color.Aqua);
            var AbilitiesMenu = Factory.Menu("Abilities");

            AbilityToggler = AbilitiesMenu.Item("Use: ", new AbilityToggler(new Dictionary <string, bool>
            {
                { "visage_summon_familiars_stone_form", true },
                { "visage_soul_assumption", true },
                { "visage_grave_chill", true }
            }));

            var ItemsMenu = Factory.Menu("Items");

            ItemsToggler = ItemsMenu.Item("Use: ", new AbilityToggler(new Dictionary <string, bool>
            {
                { "item_armlet", true },
                { "item_necronomicon_3", true },
                { "item_shivas_guard", true },
                { "item_dagon_5", true },
                { "item_veil_of_discord", true },
                { "item_ethereal_blade", true },
                { "item_solar_crest", true },
                { "item_medallion_of_courage", true },
                { "item_rod_of_atos", true },
                { "item_bloodthorn", true },
                { "item_orchid", true },
                { "item_sheepstick", true }
            }));

            var LinkenBreakerMenu = Factory.MenuWithTexture("Linken Breaker", "item_sphere");

            LinkenBreakerToggler = LinkenBreakerMenu.Item("Use: ", new AbilityToggler(new Dictionary <string, bool>
            {
                { "visage_soul_assumption", true },
                { "item_sheepstick", true },
                { "item_rod_of_atos", true },
                { "item_bloodthorn", true },
                { "item_orchid", true },
                { "item_cyclone", true },
                { "item_force_staff", true }
            }));

            LinkenBreakerChanger = LinkenBreakerMenu.Item("Priority: ", new PriorityChanger(new List <string>
            {
                { "visage_soul_assumption" },
                { "item_sheepstick" },
                { "item_rod_of_atos" },
                { "item_bloodthorn" },
                { "item_orchid" },
                { "item_cyclone" },
                { "item_force_staff" }
            }));

            var AntimageBreakerMenu = Factory.MenuWithTexture("Antimage Breaker", "antimage_spell_shield");

            AntimageBreakerToggler = AntimageBreakerMenu.Item("Use: ", new AbilityToggler(new Dictionary <string, bool>
            {
                { "visage_soul_assumption", true },
                { "item_rod_of_atos", true },
                { "item_cyclone", true },
                { "item_force_staff", true }
            }));

            AntimageBreakerChanger = AntimageBreakerMenu.Item("Priority: ", new PriorityChanger(new List <string>
            {
                { "visage_soul_assumption" },
                { "item_rod_of_atos" },
                { "item_cyclone" },
                { "item_force_staff" }
            }));

            var AutoUsageMenu = Factory.Menu("Auto Usage");

            KillStealItem    = AutoUsageMenu.Item("Auto Kill Steal", true);
            KillStealToggler = AutoUsageMenu.Item("Use: ", new AbilityToggler(new Dictionary <string, bool>
            {
                { "item_dagon_5", true },
                { "visage_soul_assumption", true }
            }));

            AutoSoulAssumptionItem = AutoUsageMenu.Item("Auto Soul Assumption", true);

            var FamiliarsLastHitMenu = Factory.Menu("Familiars Last Hit");

            LastHitItem      = FamiliarsLastHitMenu.Item("LastHit Key", new KeyBind('W', KeyBindType.Toggle, false));
            CommonAttackItem = FamiliarsLastHitMenu.Item("Common Attack", true);

            var DrawingMenu = Factory.Menu("Drawing");

            ComboRadiusItem = DrawingMenu.Item("Combo Stable Radius", true);
            ComboRadiusItem.Item.SetTooltip("I suggest making a combo in this radius");

            ComboKeyItem    = Factory.Item("Combo Key", new KeyBind('D'));
            MinDisInOrbwalk = Factory.Item("Min Distance in OrbWalk", new Slider(0, 0, 600));
            FollowKeyItem   = Factory.Item("Follow Key", new KeyBind('E', KeyBindType.Toggle, false));

            FamiliarsLowHPItem = Factory.Item("Familiars Low HP %", new Slider(30, 0, 80));
            BladeMailItem      = Factory.Item("Blade Mail Cancel", false);
            BladeMailItem.Item.SetTooltip("Cancel Combo if there is enemy Blade Mail");
            TargetItem = Factory.Item("Target", new StringList("Lock", "Default"));

            ComboKeyItem.Item.ValueChanged += HotkeyChanged;

            var Key = KeyInterop.KeyFromVirtualKey((int)ComboKeyItem.Value.Key);

            Mode = new Mode(VisagePlus.Context, Key, this);
            VisagePlus.Context.Orbwalker.RegisterMode(Mode);

            LinkenBreaker    = new LinkenBreaker(this);
            FamiliarsCombo   = new FamiliarsCombo(this);
            FamiliarsFollow  = new FamiliarsFollow(this);
            FamiliarsLastHit = new FamiliarsLastHit(this);
            FamiliarsLowHP   = new FamiliarsLowHP(this);
            AutoUsage        = new AutoUsage(this);
            UpdateMode       = new UpdateMode(this);
            Renderer         = new Renderer(this);
        }
Пример #4
0
        IntPtr SourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // Handle WM_GETDLGCODE in order to allow for arrow and tab navigation inside the dialog page.
            // By returning this code, Windows will pass arrow and tab keys to our HWND instead of handling
            // them for its own default tab and directional navigation.
            switch (msg)
            {
            case NativeMethods.WM_GETDLGCODE:
                int dlgCode = NativeMethods.DLGC_WANTARROWS | NativeMethods.DLGC_WANTTAB | NativeMethods.DLGC_WANTCHARS;

                // Ask the currently-focused element if it wants to handle all keys or not.  The DialogKeyPendingEvent
                // is a routed event starting with the focused control.  If any control in the route handles
                // this message, then we'll add DLGC_WANTALLKEYS to request that this pending message
                // be delivered to our content instead of the default dialog procedure.
                IInputElement currentElement = Keyboard.FocusedElement;
                if (currentElement != null)
                {
                    DialogKeyEventArgs args = new DialogKeyEventArgs(DialogKeyPendingEvent, KeyInterop.KeyFromVirtualKey(wParam.ToInt32()));
                    currentElement.RaiseEvent(args);

                    if (args.Handled)
                    {
                        dlgCode |= NativeMethods.DLGC_WANTALLKEYS;
                    }
                }

                handled = true;
                return(new IntPtr(dlgCode));
            }

            return(IntPtr.Zero);
        }
Пример #5
0
        private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            switch (msg)
            {
            case WM_HOTKEY:


                switch (wParam.ToInt32())
                {
                case HOTKEY_ID:
                    int vkey = (((int)lParam >> 16) & 0xFFFF);
                    if (vkey == VK_BINDING)
                    {
                        string pname;
                        int    pid = GetActiveWindowPID(out pname);
                        //Get current audio state to toggle
                        muted = VolumeMixer.GetApplicationMute(pid);

                        if (muted != null)
                        {
                            VolumeMixer.SetApplicationMute(pid, (bool)(muted = !muted));
                            stateBox.Text += "Setting app \'" + pname + "\' to " + muted.ToString() + "\n";
                        }
                        else
                        {
                            stateBox.Text += "App \'" + pname + "\' has no volume settings\n";
                        }
                    }
                    stateBox.Focus();
                    stateBox.CaretIndex = stateBox.Text.Length;
                    stateBox.ScrollToEnd();

                    handled = true;
                    break;
                }
                break;

            case 0x100:     //keypress
                if (isBinding)
                {
                    if ((GetAsyncKeyState(VK_RMENU) & 0x8000) != 0)
                    {
                        bindButton.Content = "LALT + ...";
                        if ((wParam.ToInt32() != VK_CONTROL) &&
                            (wParam.ToInt32() != VK_MENU))
                        {
                            isBinding = false;

                            BindHotkey(KeyInterop.KeyFromVirtualKey(wParam.ToInt32()), ModifierKeys.Control | ModifierKeys.Alt);
                        }
                    }
                    else if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0)
                    {
                        bindButton.Content = "CTRL + ...";
                        if ((wParam.ToInt32() != VK_CONTROL) && //means we also hit our key, which is not a modifier key anymore
                            (wParam.ToInt32() != VK_MENU))      //we should also check if the MENU key (ALT) was pressed, because right ALT is CTRL + ALT
                        {
                            //we want to register a new binding
                            isBinding = false;

                            BindHotkey(KeyInterop.KeyFromVirtualKey(wParam.ToInt32()), ModifierKeys.Control);
                        }
                    }
                }
                break;

            case 0x0104:     //WM_SYSKEYDOWN, needed for ALT aka MENU key (only left one)
                if (isBinding)
                {
                    if ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0)
                    {
                        bindButton.Content = "ALT + ...";
                        if (wParam.ToInt32() != VK_MENU)
                        {
                            isBinding = false;

                            BindHotkey(KeyInterop.KeyFromVirtualKey(wParam.ToInt32()), ModifierKeys.Alt);
                        }
                    }
                }
                break;
            }
            return(IntPtr.Zero);
        }
Пример #6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var action = (IAction)value;

            if (action == null)
            {
                return(null);
            }

            var actionName = string.IsNullOrWhiteSpace(action.Name) ? LocalizationProvider.Instance.GetTextValue("Action.NewAction") : action.Name;

            string triggers = null;

            if (action.ContinuousGesture != null)
            {
                triggers += string.Format(LocalizationProvider.Instance.GetTextValue("Action.Fingers"), action.ContinuousGesture.ContactCount) + " " + LocalizationProvider.Instance.GetTextValue("Action." + action.ContinuousGesture.Gesture) + " / ";
            }
            if (action.Hotkey != null)
            {
                triggers += LocalizationProvider.Instance.GetTextValue("ActionDialog.KeyboardHotKey") + ": " + new HotKey(KeyInterop.KeyFromVirtualKey(action.Hotkey.KeyCode), (ModifierKeys)action.Hotkey.ModifierKeys).ToString() + " / ";
            }
            if (action.MouseHotkey != ManagedWinapi.Hooks.MouseActions.None && AppConfig.DrawingButton != ManagedWinapi.Hooks.MouseActions.None)
            {
                triggers += LocalizationProvider.Instance.GetTextValue("ActionDialog.MouseHotKey") + ": " + ViewModel.MouseActionDescription.DescriptionDict[AppConfig.DrawingButton] + " + " + ViewModel.MouseActionDescription.DescriptionDict[action.MouseHotkey] + " / ";
            }

            return(string.IsNullOrEmpty(triggers) ? actionName : $"{actionName} ({triggers.TrimEnd(' ', '/')})");
        }
Пример #7
0
 public static Key ResolveKey(char charToResolve)
 {
     return(KeyInterop.KeyFromVirtualKey(VkKeyScan(charToResolve)));
 }