예제 #1
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            ghk = new GlobalHotkey(Constants.SHIFT, Keys.Escape, this);
            ghk.Register();

            FillProcessCombo();
        }
예제 #2
0
        private void timer_read_Tick(object sender, EventArgs e)
        {
            if (GetActiveWindowTitle() == "Katana ZERO")
            {
                hotkey_restart.Register();
                hotkey_nextRoom.Register();
                hotkey_lastRoom.Register();
                hotkey_setRoom.Register();
            }
            else
            {
                hotkey_restart.Unregister();
                hotkey_nextRoom.Unregister();
                hotkey_lastRoom.Unregister();
                hotkey_setRoom.Unregister();
            }

            if (!game.HasExited)
            {
                var roome = Memory.ReadInt(game, address_room);
                updateCurrentRoom();

                if (roome < 4)
                {
                    setRoom(4);
                }
            }
            else
            {
                label1.Text            = "Katana ZERO is not running";
                groupBox1.Enabled      = false;
                timer_findGame.Enabled = true;
                timer_read.Enabled     = false;
            }
        }
예제 #3
0
        private void RegisterHotKeys()
        {
            m_HotkeyAreaScreenshot          = new GlobalHotkey(Program.globalSetting.AreaHotkey);
            m_HotkeyAreaScreenshot.Pressed += Hk_AreaScreenshot;
            if (!m_HotkeyAreaScreenshot.GetCanRegister(this))
            {
                Console.WriteLine("Already registered");
            }
            else
            {
                m_HotkeyAreaScreenshot.Register(this);
            }


            m_HotkeyClipBoard          = new GlobalHotkey(Program.globalSetting.ClipboardHotkey);
            m_HotkeyClipBoard.Pressed += Hk_ClipBoard;
            if (!m_HotkeyClipBoard.GetCanRegister(this))
            {
                Console.WriteLine("Already registered");
            }
            else
            {
                m_HotkeyClipBoard.Register(this);
            }
        }
예제 #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Interval = 1000 / 60;
            int argb = (int)Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", null);

            SysColor     = Color.FromArgb(255, Color.FromArgb(argb));
            hk_MediaNext = new GlobalHotkey(Constants.NOMOD, Keys.MediaNextTrack, this);
            hk_MediaPrev = new GlobalHotkey(Constants.NOMOD, Keys.MediaPreviousTrack, this);
            hk_MediaPlay = new GlobalHotkey(Constants.NOMOD, Keys.MediaPlayPause, this);
            hk_StandNext = new GlobalHotkey(Constants.CTRL | Constants.SHIFT, Keys.F12, this);
            hk_StandPrev = new GlobalHotkey(Constants.CTRL | Constants.SHIFT, Keys.F11, this);
            hk_StandPlay = new GlobalHotkey(Constants.CTRL | Constants.SHIFT, Keys.F10, this);
            hk_MediaNext.Register();
            hk_MediaPrev.Register();
            hk_MediaPlay.Register();
            hk_StandNext.Register();
            hk_StandPrev.Register();
            hk_StandPlay.Register();
            Enum.TryParse(Properties.MMP.Default.DrawMode, out colorMode);
            menuControl = new MenuController(this);
            songHandler = new SongHandler(this);
            menuControl.Add(new VolumeMenuHandler(songHandler, menuControl));
            menuControl.Add(new NextSongMenuHandler(songHandler, menuControl));
            menuControl.Add(new PositionMenuHandler(songHandler, menuControl));
            menuControl.Add(new TrackMenuHandler(songHandler, menuControl));
            menuControl.Add(new PreviousSongMenuHandler(songHandler, menuControl));
            menuControl.Add(new CloseMenuHandler(songHandler, menuControl));
            menuControl.DoCreate();
            Paused = true;
        }
예제 #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Load Play Area
            top   = Properties.Settings.Default.top;
            bot   = Properties.Settings.Default.bot;
            left  = Properties.Settings.Default.left;
            right = Properties.Settings.Default.right;

            GameEngine.SetPlayableArea(new Rectangle(left, top, right - left, bot - top));

            // By moving here, we do not reload the tasklist every time we stop the program with the GHK
            // Load Tasks
            string ret = PlayerEngine.ParseTasklist(Properties.Settings.Default.taskList);

            if (ret != null)
            {
                MessageBox.Show(string.Format("Error parsing task list: {0}", ret));
                return;
            }

            // Set Discount
            GameEngine.SetHeroDiscount(1.0 - 0.02 * Properties.Settings.Default.dogcog);

            // Set Hotkey
            ghk = new GlobalHotkey(GlobalHotkey.Constants.CTRL + GlobalHotkey.Constants.SHIFT, Keys.D, this);
            if (!ghk.Register())
            {
                throw new Exception("can't register");
            }
        }
예제 #6
0
 private void Form1_Load(object sender, EventArgs e)
 {
     // Set Hotkey
     ghk = new GlobalHotkey(GlobalHotkey.Constants.CTRL + GlobalHotkey.Constants.SHIFT, Keys.D, this);
     if (!ghk.Register())
     {
         throw new Exception("can't register");
     }
 }
예제 #7
0
        public Form1()
        {
            InitializeComponent();

            ghk = new GlobalHotkey(Modifiers.NoMod, Keys.Escape, this);
            ghk.Register();
            Native.SetMonitorEnable(this.Handle, false);
            this.Shown += (o, e) => this.Hide();
        }
예제 #8
0
        private void RegisterHotkeys()
        {
            ScanScreenshotHotkey            = new GlobalHotkey(HotkeyConstants.NOMOD, Settings.Settings.ScanHotkey, this);
            ScanScreenshotHotkey.Triggered += ScanScreenshotHotkeyTriggered;
            ScanScreenshotHotkey.Register();

            ScanTextboxHotkey            = new GlobalHotkey(HotkeyConstants.NOMOD, Settings.Settings.RescanHotkey, this);
            ScanTextboxHotkey.Triggered += ScanTextBoxHotkeyTriggered;
            ScanTextboxHotkey.Register();
        }
 private void RegisterTriggerKey(Keys key, int mod = Constants.NOMOD)
 {
     try
     {
         mainTrigger = new GlobalHotkey(mod, key, this);
         mainTrigger.Register();
     }
     catch (GlobalHotkeyException e)
     {
         MessageBox.Show(e.Message, "Registration Error");
         this.BeginInvoke(new MethodInvoker(Close));
     }
 }
예제 #10
0
        private void BtnFindControl_MouseUp(object sender, MouseEventArgs e)
        {
            var point = ClickOnPointTool.GetCursorPosition();

            var hwnd = ClickOnPointTool.WindowFromPoint(new POINT {
                X = point.X, Y = point.Y
            });

            if (hwnd.ToInt64() > 0)
            {
                StringBuilder className = new StringBuilder(256);
                var           nRet      = ClickOnPointTool.GetClassName(hwnd, className, className.Capacity);

                //For Parent
                IntPtr hWndParent = ClickOnPointTool.GetParent(hwnd);
                if (hWndParent.ToInt64() > 0)
                {
                    txtClass.Text = ClickOnPointTool.GetClassNameOfWindow(hWndParent);
                    txtName.Text  = ClickOnPointTool.GetCaptionOfWindow(hWndParent);

                    ghk     = new GlobalHotkey(GlobalHotkey.ALT, Keys.S, hwnd);
                    ghkMain = new GlobalHotkey(GlobalHotkey.ALT, Keys.S, this.Handle);
                    var isSuccess     = ghk.Register();
                    var isSuccessMain = ghkMain.Register();
                    //if (isSuccess || isSuccessMain)
                    //MessageBox.Show("Hotkey registered.");

                    if (Configs.Count > 0)
                    {
                        foreach (var config in Configs)
                        {
                            config.WindowClass  = txtClass.Text;
                            config.WindowName   = txtName.Text;
                            config.WindowHandle = hWndParent;
                        }
                    }
                    //        LoadingConfigs = new List<Configuration.Config>()
                    //{
                    //    new Configuration.Config
                    //    {
                    //        No = 1, Delay = 500, XPos = 439, YPos = 387, ColorName = "ff222222",
                    //        WindowClass = txtClass.Text, WindowName =txtName.Text, WindowHandle = hWndParent
                    //    }
                    //};
                }
            }

            Cursor.Current = Cursors.Default;
        }
예제 #11
0
        private void InitializeKeys()
        {
            //? See if you actually need this, makes it to where key presses are detected across all forms, does this include while the app is closed too?
            //? If the above is true then this will need to have a setting in the options panel
            this.KeyPreview = true;

            // GlobalHotkey
            ghShiftAlt = new GlobalHotkey(VirtualKey.SHIFT + VirtualKey.ALT, Keys.None, this);
            //ghDivide = new GlobalHotkey(VirtualKey.NOMOD, Keys.Divide, this);
            //ghMultiply = new GlobalHotkey(VirtualKey.NOMOD, Keys.Multiply, this);
            //ghNumPad5 = new GlobalHotkey(VirtualKey.NOMOD, Keys.NumPad5, this);

            if (!ghShiftAlt.Register())
            {
                MessageBox.Show("Hotkey failed to register!");
            }
        }
예제 #12
0
        private void RegisterGlobalKeys()
        {
            foreach (KeyCombination keyCombination in mainModel.GlobalKeys.Keys)
            {
                //Convert from managed to native enum
                var modifiers = (MOD)(int)keyCombination.Modifiers;

                var ghk = new GlobalHotkey(modifiers, keyCombination.Key, this);
                if (ghk.Register())
                {
                    globalHotKeyRegistered.Add(ghk);
                    LogManager.Logger(GetType()).InfoFormat("Hotkey '{0}' registered", keyCombination);
                }
                else
                {
                    LogManager.Logger(GetType()).ErrorFormat("Hotkey '{0}' failed to register", keyCombination);
                }
            }
        }
예제 #13
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Unregister Hotkeys
            m_HotkeyAreaScreenshot.Unregister();
            m_HotkeyClipBoard.Unregister();

            //Show settings form
            new Settings().ShowDialog();

            //Update current hotkeys
            m_HotkeyAreaScreenshot.UpdateHotkey(Program.globalSetting.AreaHotkey);
            m_HotkeyClipBoard.UpdateHotkey(Program.globalSetting.ClipboardHotkey);

            //Reenable hotkeys
            m_HotkeyAreaScreenshot.Register(this);
            m_HotkeyClipBoard.Register(this);

            //Save
            Program.globalSetting.SaveSettings();
        }
예제 #14
0
 private void ApplyToggleListening()
 {
     if (_currentOptions.ToggleListening)
     {
         try {
             _ghk.Register();
         }
         catch {
             Console.WriteLine("Couldn't register key properly");
         }
     }
     else
     {
         try {
             _ghk.Unregister();
         }
         catch {
             Console.WriteLine("Couldn't unregister key properly");
         }
     }
 }
예제 #15
0
 private void HotkeyActivated_CheckedChanged(object sender, EventArgs e)
 {
     if (HotkeyActivated.Checked)
     {
         if (hotkeymessage == false)
         {
             MessageBox.Show(@"The Global Hotkey for this application is 'ESC'. It will stop the recording of keyboard and mouse movements if activated. If you are playing the movements pressing it will stop the playback process. Using this you have the ability to forever loop the movements and drive your friend crazy! Have fun :)");
             hotkeymessage = true;
         }
         ForeverLoop.Visible = true;
         ghk.Register();
     }
     else
     {
         if (ForeverLoop.Checked)
         {
             ForeverLoop.Checked = false;
             MessageBox.Show(@"Forever Loop was on. Deactivated it.", @"Deactivated Forever Loop", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         ForeverLoop.Visible = false;
         ghk.Unregiser();
     }
 }
예제 #16
0
        private void PreviewImage_Load(object sender, EventArgs e)
        {
            ColorValueIsHex = Properties.Settings.Default.ColorHTML;
            hotkey          = new GlobalHotkey(Constants.NOMOD, Keys.Escape, this);

            if (hotkey.Register())
            {
                Console.WriteLine("Hotkey registered.");
            }

            foreach (Screen screen in Screen.AllScreens)
            {
                screens++;
            }

            this.Size     = new Size(screenWidth, screenHeight);
            this.Location = new Point(screenLeft, screenTop);

            Screen screenCurrent = Screen.FromPoint(Cursor.Position);

            if (screens > 1)
            {
                width = screenCurrent.Bounds.Width;
            }
            else
            {
                width = 0;
            }

            panel1.Location = new Point((Cursor.Position.X + 30) + screenWidth / screens, ((Cursor.Position.Y - Height) / 2) + screenHeight);

            thread = new Thread(SetColorLoop)
            {
                IsBackground = true
            };
            thread.Start();
        }
예제 #17
0
 private void InitializeHotkeys()
 {
     StartStopHotkey = new GlobalHotkey(HotkeyConstants.NOMOD, ApplicationConfiguration.StartStopHotKey, this, StartStopHotkeyPressed);
     StartStopHotkey.Register();
 }
예제 #18
0
        protected override void OnInitialized(EventArgs eventArgs)
        {
            base.OnInitialized(eventArgs);

            try
            {
                instance = this;
                // Update the position and size of the window.
                UpdatePosition();
                // Set the window as NO_ACTIVATE, TOOLWINDOW and TOPMOST,
                WindowStyles.SetExtended(this, WindowStyles.GetExtended(this)
                                         | ExtendedWindowStyle.WS_EX_NOACTIVATE
                                         | ExtendedWindowStyle.WS_EX_TOOLWINDOW
                                         | ExtendedWindowStyle.WS_EX_TOPMOST);

                // Apply the user-selected locale.
                IntlManager.Apply(new CultureInfo(AppState.Current.UserSettings.Locale));
                // Apply the user-selected theme.
                ThemeManager.Apply(AppState.Current.UserSettings.Theme);

                // Initialize the drop shadow.
                _dropShadow = new WindowDropShadow(this)
                {
                    Radius   = 15.0,
                    Strength = 2.0,
                    Opacity  = 0.0,
                };

                // Set the window's view-model.
                _viewModel = new OverviewViewModel();

                InitializeQuickInfoWindow();

                // Request the needed window permissions. (>= Windows 8)
                _clipboardPermission = new UIPermission(PermissionState.Unrestricted)
                {
                    Clipboard = UIPermissionClipboard.AllClipboard
                };

                // Setup the clipboard manager and the according event listeners.
                _clipboardManager = new ClipboardManager(this);
                _clipboardManager.StateChanged += OnClipboardStateChanged;

                // Initially hidden.
                _isVisible   = false;
                _transitions = new TaskChain();

                // Initialize the window message receiver with a name.
                _wmr = new WindowMessageReceiver("MULTICLIP_IPC", null);
                // Setup the IPC handler.
                _wmr.MessageReceived += OnMessageReceived;

                // Initialize and set the low-level mouse hook.
                _mouseHook              = new LowLevelMouseHook();
                _mouseHook.LButtonDown += OnMouseHookButtonDown;
                _mouseHook.RButtonDown += OnMouseHookButtonDown;
                _mouseHook.XButtonDown += OnMouseHookButtonDown;
                _mouseHook.SetHook();

                // Initialize and register the overview hotkey.
                _overviewHotkey          = new GlobalHotkey(HotkeyModfier.Ctrl, Keys.Space);
                _overviewHotkey.Pressed += OnOverviewHotkeyPressed;
                _overviewHotkey.Register();

                // Initialize and register the secure-copy hotkey.
                _secureCopyHotkey          = new GlobalHotkey(HotkeyModfier.Ctrl | HotkeyModfier.Alt, Keys.C);
                _secureCopyHotkey.Pressed += OnSecureCopyHotkeyPressed;
                _secureCopyHotkey.Register();

                // Show the help window on the first run of the app.
                if ((bool)Properties.Settings.Default["IsFirstRun"] == true)
                {
                    Properties.Settings.Default["IsFirstRun"] = false;
                    Properties.Settings.Default.Save();
                    HelpWindow helpWindow = new HelpWindow();
                    helpWindow.Show();
                }

                ClipboardList.ItemsSource = _viewModel.ClipboardItems;

                // When a file-drop item is about to open a subwindow,
                // hide the main window.
                FileDropItem.PreviewShellExecute += delegate
                {
                    if (_isVisible)
                    {
                        HideAsync().GetAwaiter();
                    }
                };
            }
            catch (Exception e)
            {
                _logger.LogCritical(LogEvents.FatalErr, "Failed to initialize the main window!", e);
                Exceptions.NotifyCritical(e);
            }
        }
예제 #19
0
        private void UIForm2_Load(object sender, EventArgs e)
        {
            ghk.Register();
            Utils.Log("** Global hotkey for LazyRaider registered: Ctrl + Alt + Shift + Z", Utils.Colour("Red"));

            string environment = Utils.IsBattleground ? "PVP" : "PVE";

            environment = ObjectManager.Me.IsInInstance ? "Instance" : environment;
            ConfigSettings.CurrentEnvironment = environment;
            environmentSettings.SelectedItem  = environment;
            ConfigSettings.UIActive           = true;

            _path = Settings.ConfigFolder + FileName;



            #region Dynamically populate UI form with controls

            #region Add Value Templates

            foreach (XElement ele in XDocument.Load(_path).Root.Elements("ValueTemplates").Elements("Template"))
            {
                string label = ele.Element("Label").Value;
                string value = ele.Element("Value").Value;

                _valueTemplates.Add(label.ToUpper(), value);
            }
            #endregion

            #region Add Tab Pages
            foreach (XElement ele in XDocument.Load(_path).Root.Elements("TabPages").Elements("Tab"))
            {
                string label = ele.Element("Label").Value;

                TabPage tp = new TabPage {
                    Text = label, BackColor = Color.White
                };
                tabControl1.TabPages.Add(tp);
            }
            #endregion

            #region Add Groupboxes to all tabs
            foreach (XElement ele in XDocument.Load(_path).Root.Elements("Groupboxes").Elements("Group"))
            {
                string label   = ele.Element("Label").Value;
                string name    = ele.Element("Name").Value;
                string column  = ele.Element("Column").Value;
                string tabpage = ele.Element("Tab").Value;

                int      leftPosition = (column == "Right" ? 318 : 8);
                GroupBox gb           = new GroupBox {
                    Left = leftPosition, Top = 220, Height = 224, Width = 302, Text = label, Name = name
                };
                foreach (TabPage tab in tabControl1.TabPages)
                {
                    if (tab.Text == tabpage)
                    {
                        tab.Controls.Add(gb); break;
                    }
                }
            }

            #endregion

            #region Add Items to each group

            foreach (XElement ele in XDocument.Load(_path).Root.Elements("Items").Elements("Item"))
            {
                string label     = ele.Element("Label").Value;
                string name      = ele.Element("Name").Value;
                string groupName = ele.Element("GroupName").Value;
                string type      = ele.Element("Type").Value;
                string value     = ele.Element("Value").Value;
                string tooltip   = ele.Element("Tooltip").Value;
                string tag       = ele.Element("Tag").Value;

                // If no 'type' is passed assume it is a combo box. I use this more than the bars so its a safe assumption
                if (type.ToUpper() == "COMBO" || string.IsNullOrEmpty(type))
                {
                    if (!string.IsNullOrEmpty(groupName))
                    {
                        // Find the groupbox name and pass it along with the other data
                        foreach (GroupBox gb in from TabPage tab in tabControl1.Controls from gb in tab.Controls.Cast <GroupBox>().Where(gb => gb.Name == groupName) select gb)
                        {
                            NewCombo(gb, label, name, value, tooltip, tag);
                            break;
                        }
                    }
                    else
                    {
                        // No Groupbox name was read so use the last Groupbox
                        NewCombo(null, label, name, value, tooltip, tag);
                    }
                }
                else if (type.ToUpper() == "BAR")
                {
                    if (!string.IsNullOrEmpty(groupName))
                    {
                        // Find the groupbox name and pass it along with the other data
                        foreach (GroupBox gb in from TabPage tab in tabControl1.Controls from gb in tab.Controls.Cast <GroupBox>().Where(gb => gb.Name == groupName) select gb)
                        {
                            NewBar(gb, label, name, tooltip, tag);
                            break;
                        }
                    }
                    else
                    {
                        // No Groupbox name was read so use the last Groupbox
                        NewBar(null, label, name, tooltip, tag);
                    }
                }
            }



            #endregion

            #region Resize and reposition the groupboxes
            foreach (TabPage tab in tabControl1.Controls)
            {
                GroupBox leftGb = null, rightGb = null;
                foreach (GroupBox gb in tab.Controls)
                {
                    // Resize each Groupbox appropriately for the number of controls it has
                    gb.Height = ((28 * gb.Controls.Count / 2) + 28);

                    if (gb.Left == 8)
                    {
                        if (leftGb != null)
                        {
                            gb.Top = leftGb.Top + leftGb.Height + 4; leftGb = gb;
                        }
                        else
                        {
                            leftGb = gb; gb.Top = 8;
                        }
                    }
                    else if (gb.Left == 318)
                    {
                        if (rightGb != null)
                        {
                            gb.Top = rightGb.Top + rightGb.Height + 4; rightGb = gb;
                        }
                        else
                        {
                            rightGb = gb; gb.Top = 8;
                        }
                    }
                }

                // The last (left) Groupbox will be resized to full the column it is in.
                if (leftGb != null)
                {
                    int filloutHeight = leftGb.Height + (tab.Height - (leftGb.Top + leftGb.Height + 8));
                    leftGb.Height = filloutHeight;
                }

                // The last (right) Groupbox will be resized to full the column it is in.
                if (rightGb != null)
                {
                    int filloutHeight = rightGb.Height + (tab.Height - (rightGb.Top + rightGb.Height + 8));
                    rightGb.Height = filloutHeight;
                }
            }
            #endregion

            #endregion


            LoadSettings();


            _isLoading = false;

            if (Settings.MultipleEnvironment.Contains("never"))
            {
                environmentSettings.SelectedItem = "PVE";
                environmentSettings.Visible      = false;
            }
        }
예제 #20
0
 private void Form1_Load(object sender, EventArgs e)
 {
     // Set Hotkey
     ghk = new GlobalHotkey(GlobalHotkey.Constants.CTRL + GlobalHotkey.Constants.SHIFT, Keys.D, this);
     if (!ghk.Register())
     {
         throw new Exception("can't register");
     }
 }
예제 #21
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Load Play Area
            top = Properties.Settings.Default.top;
            bot = Properties.Settings.Default.bot;
            left = Properties.Settings.Default.left;
            right = Properties.Settings.Default.right;

            GameEngine.SetPlayableArea(new Rectangle(left, top, right - left, bot - top));

            // By moving here, we do not reload the tasklist every time we stop the program with the GHK
            // Load Tasks
            string ret = PlayerEngine.ParseTasklist(Properties.Settings.Default.taskList);
            if (ret != null)
            {
                MessageBox.Show(string.Format("Error parsing task list: {0}", ret));
                return;
            }

            // Set Discount
            GameEngine.SetHeroDiscount(1.0 - 0.02 * Properties.Settings.Default.dogcog);

            // Set Hotkey
            ghk = new GlobalHotkey(GlobalHotkey.Constants.CTRL + GlobalHotkey.Constants.SHIFT, Keys.D, this);
            if (!ghk.Register())
            {
                throw new Exception("can't register");
            }
        }