public CompiledMacro Compile(Trigger trig)
        {
            //we commented the line below to allow for blank macros now. they will block input and maybe be used to change pages.
            // if (_triggers.Count == 0) throw new Exception("This macro has no triggers.");
            // check if trigger is in triggerset maybe
            InputBuilder magie       = new InputBuilder();
            bool         origKeyDown = trig.triggeredBy == TriggerType.KeyUp;

            foreach (InputEvent evt in _events)
            {
                int vk = evt.vk;
                if (vk == (int)SpecialKey.OriginalKey)
                {
                    //do not attempt to press a mouse key.
                    if (trig.triggeredBy == TriggerType.MouseDown ||
                        trig.triggeredBy == TriggerType.MouseUp)
                    {
                        continue;
                    }

                    vk          = trig.vk;
                    origKeyDown = evt.type == InputEventType.KeyDown;
                }
                switch (evt.type)
                {
                case InputEventType.KeyDown:
                    magie.AddKeyDown((Keys)vk);
                    break;

                case InputEventType.KeyUp:
                    magie.AddKeyUp((Keys)vk);
                    break;

                case InputEventType.KeyPress:
                    magie.AddKeyDown((Keys)vk);
                    magie.AddKeyUp((Keys)vk);
                    break;

                default:
                    throw new Exception("Unsupported input type: " + evt.type.ToString());
                }
            }
            return(new CompiledMacro(magie.ToArray(), origKeyDown, this.HasTableSwitch ? this.TableSwitchName : string.Empty, this.PassOriginalKey));
        }
Esempio n. 2
0
        void DispInfo(Hooker.KeyboardHookStruct arg)
        {
            int vk = arg.VirtualKeyCode;

            label1.Text =
                "Virtual key code: " + vk + " [" + ((Keys)vk).ToString() + "]\r\n" +
                "Scan code: " + arg.ScanCode + " (" + InputBuilder.MapVirtualKey((uint)arg.VirtualKeyCode, InputBuilder.MapVirtualKeyMapTypes.MAPVK_VK_TO_VSC).ToString() + ")\r\n" +
                "Flags: " + Convert.ToString(arg.Flags, 2).PadLeft(8, '0') + "\r\n" +
                "    Extended Key: " + arg.IsExtendedKey.ToString() + "\r\n" +
                "    Lower Injected: " + arg.IsLowerInjected.ToString() + "\r\n" +
                "    Injected: " + arg.IsInjected.ToString() + "\r\n" +
                "    Alt Down: " + arg.IsAltDown.ToString() + "\r\n" +
                "    Key Up: " + arg.IsKeyUp.ToString() + "\r\n" +
                "Extra Info: " + Convert.ToString(arg.ExtraInfo, 2) + "\r\n";
            //int pick = (int)Math.Min(Math.Floor(Math.Abs(GaussRandom(0, 1))), 2);

            //listView1.Items.Add(((Keys)vk).ToString() + " " +( arg.IsKeyUp? "up":"down") + " " +
            //pick + " " + GaussRandom(sleeps[pick][0],sleeps[pick][1])); // DEBUG
        }