private void DropToStash() { var cursorPosPreMoving = Mouse.GetCursorPosition(); if (Settings.BlockInput.Value) { WinApi.BlockInput(true); } if (_dropItems.Count > 0) { var sortedByStash = (from itemResult in _dropItems group itemResult by itemResult.StashIndex into groupedDemoClass select groupedDemoClass).ToDictionary(gdc => gdc.Key, gdc => gdc.ToList()); var latency = (int)GameController.Game.IngameState.CurLatency + Settings.ExtraDelay; Keyboard.KeyDown(Keys.LControlKey); Thread.Sleep(INPUT_DELAY); foreach (var stashResults in sortedByStash) { if (!SwitchToTab(stashResults.Key)) { continue; } foreach (var stashResult in stashResults.Value) { Mouse.SetCursorPosAndLeftClick(stashResult.ClickPos + _clickWindowOffset, Settings.ExtraDelay); Thread.Sleep(latency); } } Keyboard.KeyUp(Keys.LControlKey); } ProcessRefills(); Mouse.SetCursorPos(cursorPosPreMoving.X, cursorPosPreMoving.Y); if (Settings.BlockInput.Value) { WinApi.BlockInput(false); Keyboard.KeyUp(Settings.DropHotkey.Value); Thread.Sleep(INPUT_DELAY); } }
private void hook_KeyDown(object sender, KeyEventArgs e) { //判断按下的键(Alt + A)启动鼠标连点器 if (e.KeyValue == (int)Keys.A && (int)System.Windows.Forms.Control.ModifierKeys == (int)Keys.Alt) { WinApi.BlockInput(true); WinApi.mouse_event(WinApi.MOUSEEVENTF_ABSOLUTE | WinApi.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); WinApi.mouse_event(WinApi.MOUSEEVENTF_ABSOLUTE | WinApi.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); WinApi.BlockInput(false); } if (e.KeyValue == (int)Keys.S && (int)System.Windows.Forms.Control.ModifierKeys == (int)Keys.Alt) { WinApi.BlockInput(true); WinApi.mouse_event(WinApi.MOUSEEVENTF_ABSOLUTE | WinApi.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); WinApi.mouse_event(WinApi.MOUSEEVENTF_ABSOLUTE | WinApi.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); WinApi.BlockInput(false); } if (e.KeyValue == (int)Keys.F1 && (int)System.Windows.Forms.Control.ModifierKeys == (int)Keys.Alt) { Save_Mouse_X = System.Windows.Forms.Cursor.Position.X; Save_Mouse_Y = System.Windows.Forms.Cursor.Position.Y; AddInfo("已记录鼠标位置 (" + Save_Mouse_X + "," + Save_Mouse_Y + ")"); } if (e.KeyValue == (int)Keys.F2 && (int)System.Windows.Forms.Control.ModifierKeys == (int)Keys.Alt) { if (Save_Mouse_X == 0 || Save_Mouse_Y == 0) { MessageBox.Show("无可用鼠标位置,按下Alt+F1记录"); return; } Backup_Mouse_X = System.Windows.Forms.Cursor.Position.X; Backup_Mouse_Y = System.Windows.Forms.Cursor.Position.Y; WinApi.BlockInput(true); WinApi.SetCursorPos(Save_Mouse_X, Save_Mouse_Y); WinApi.mouse_event(WinApi.MOUSEEVENTF_ABSOLUTE | WinApi.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); WinApi.mouse_event(WinApi.MOUSEEVENTF_ABSOLUTE | WinApi.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); WinApi.SetCursorPos(Backup_Mouse_X, Backup_Mouse_Y); WinApi.BlockInput(false); } }
private void DropToStash() { var cursorPosPreMoving = Mouse.GetCursorPosition(); if (Settings.BlockInput.Value) { WinApi.BlockInput(true); } if (_dropItems.Count > 0) { // Dictionary where key is the index (stashtab index) and Value is the items to drop. var itemsToDrop = (from dropItem in _dropItems group dropItem by dropItem.StashNode.VisibleIndex into itemsToDropByTab select itemsToDropByTab).ToDictionary(tab => tab.Key, tab => tab.ToList()); var latency = (int)_ingameState.CurLatency; foreach (var stashResults in itemsToDrop) { // If we are more than 2 tabs away from our target, then use dropdown approach if // user has it. if (!Keyboard.IsKeyToggled(Settings.DropHotkey.Value)) { return; } if (!SwitchToTab(stashResults.Value[0].StashNode)) { continue; } try { Keyboard.KeyDown(Keys.LControlKey); Thread.Sleep(INPUT_DELAY); foreach (var stashResult in stashResults.Value) { Mouse.SetCursorPosAndLeftClick(stashResult.ClickPos, Settings.ExtraDelay, _windowOffset); Thread.Sleep(latency + Settings.ExtraDelay.Value); } } catch { Keyboard.KeyUp(Keys.LControlKey); } // QVIN's version of Hud doesn't support Subscription events, so we use reflection. if (_callPluginEventMethod != null) { _callPluginEventMethod.Invoke(API, new object[] { "StashUpdate", new object[0] }); } } Keyboard.KeyUp(Keys.LControlKey); } ProcessRefills(); Mouse.SetCursorPos(cursorPosPreMoving.X, cursorPosPreMoving.Y); // TODO:Go back to a specific tab, if user has that setting enabled. if (Settings.VisitTabWhenDone.Value) { SwitchToTab(Settings.TabToVisitWhenDone); } if (Settings.BlockInput.Value) { WinApi.BlockInput(false); Thread.Sleep(INPUT_DELAY); } }