private void Window_Loaded(object sender, RoutedEventArgs e) { WinMain winMain = (WinMain)Application.Current.MainWindow; cbLeague.Items.Clear(); if (mLeagues?.Result.Length > 0) { foreach (FilterDict item in mLeagues.Result) { cbLeague.Items.Add(item.Id); } } lbDbVersion.Content = "버전: " + Application.Current.Properties["FileVersion"] + "\n" + winMain.mFilter[0].Upddate; cbLeague.SelectedItem = winMain.mConfig.Options.League ?? ""; if (cbLeague.SelectedIndex == -1) { cbLeague.Items.Add(winMain.mConfig.Options.League ?? ""); cbLeague.SelectedIndex = cbLeague.Items.Count - 1; } cbServerType.SelectedIndex = winMain.mConfig.Options.ServerType; cbSearchAutoDelay.SelectedIndex = Math.Abs(winMain.mConfig.Options.SearchAutoDelay / 30); cbSearchBeforeDay.SelectedIndex = Math.Abs(winMain.mConfig.Options.SearchBeforeDay / 7); cbSearchListCount.SelectedIndex = Math.Abs((winMain.mConfig.Options.SearchListCount / 20) - 1); ckAutoCheckUnique.IsChecked = winMain.mConfig.Options.AutoCheckUnique == true; ckAutoSelectPseudo.IsChecked = winMain.mConfig.Options.AutoSelectPseudo == true; ckAutoCheckTotalres.IsChecked = winMain.mConfig.Options.AutoCheckTotalres == true; ckAutoCheckUpdates.IsChecked = winMain.mConfig.Options.AutoCheckUpdates == true; ckUseCtrlWheel.IsChecked = winMain.mConfig.Options.UseCtrlWheel == true; for (int i = 0; i < winMain.mConfig.Shortcuts.Length; i++) { if (i == 12) { break; } ConfigShortcut shortcut = winMain.mConfig.Shortcuts[i]; HotkeyBox.keyBinding hotkey = new HotkeyBox.keyBinding( KeyInterop.KeyFromVirtualKey(shortcut.Keycode), (ModifierKeys)shortcut.Modifiers ); ((HotkeyBox)FindName("Hotkey" + (i + 1))).Hotkey = hotkey; ((TextBox)FindName("HotkeyValue" + (i + 1))).Text = shortcut.Value; } lbChecked.ItemsSource = winMain.mChecked.Entries; }
private void RemoveRegisterHotKey() { for (int i = 0; i < mConfig.Shortcuts.Length; i++) { ConfigShortcut shortcut = mConfig.Shortcuts[i]; if (shortcut.Keycode > 0 && (shortcut.Value ?? "") != "") { Native.UnregisterHotKey(mMainHwnd, 10001 + i); } } Native.UnregisterHotKey(mMainHwnd, 10000); mInstalledHotKey = false; }
private void InstallRegisterHotKey() { mInstalledHotKey = true; Native.RegisterHotKey(mMainHwnd, 10000, 0, (uint)KeyInterop.VirtualKeyFromKey(Key.Escape)); for (int i = 0; i < mConfig.Shortcuts.Length; i++) { ConfigShortcut shortcut = mConfig.Shortcuts[i]; if (shortcut.Keycode > 0 && (shortcut.Value ?? "") != "") { Native.RegisterHotKey(mMainHwnd, 10001 + i, (uint)shortcut.Modifiers, (uint)shortcut.Keycode); } } }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == Native.WM_DRAWCLIPBOARD) { if (!mPausedHotKey) { #if DEBUG if (true) #else if (Native.GetForegroundWindow().Equals(Native.FindWindow(RS.PoeClass, RS.PoeCaption))) #endif { try { if (Clipboard.ContainsText(TextDataFormat.UnicodeText) || Clipboard.ContainsText(TextDataFormat.Text)) { ItemTextParser(GetClipText(Clipboard.ContainsText(TextDataFormat.UnicodeText)), !mShowWiki); if (mShowWiki) { Button_Click_4(null, new RoutedEventArgs()); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { mShowWiki = false; } } } } else if (msg == (int)0x0112 /*WM_SYSCOMMAND*/ && ((int)wParam & 0xFFF0) == (int)0xf180 /*SC_CONTEXTHELP*/) { WinSetting winSetting = new WinSetting(); winSetting.Show(); handled = true; } else if (!mHotkeyProcBlock && msg == (int)0x312) //WM_HOTKEY { mHotkeyProcBlock = true; IntPtr findHwnd = Native.FindWindow(RS.PoeClass, RS.PoeCaption); if (Native.GetForegroundWindow().Equals(findHwnd)) { int key_idx = wParam.ToInt32() - 10001; const string POPUP_WINDOW_TITLE = "이곳을 잡고 이동, 닫기는 클릭 또는 ESC"; try { if (key_idx == -1) { IntPtr pHwnd = Native.FindWindow(null, POPUP_WINDOW_TITLE); IntPtr pHwnd2 = Native.FindWindow(null, Title + " - " + "{grid:stash}"); if (pHwnd.ToInt32() != 0 || pHwnd2.ToInt32() != 0) { if (pHwnd.ToInt32() != 0) { Native.SendMessage(pHwnd, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } if (pHwnd2.ToInt32() != 0) { Native.SendMessage(pHwnd2, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } } else if (this.Visibility == Visibility.Hidden) { Native.SendMessage(findHwnd, 0x0101, new IntPtr(/* ESC = */ 27), IntPtr.Zero); } else if (this.Visibility == Visibility.Visible) { Close(); } } else { ConfigShortcut shortcut = mConfig.Shortcuts[key_idx]; if (shortcut != null && shortcut.Value != null) { string valueLower = shortcut.Value.ToLower(); if (valueLower.IndexOf("{pause}") == 0) { mPausedHotKey = !mPausedHotKey; if (mPausedHotKey) { if (mConfig.Options.UseCtrlWheel) { MouseHook.Stop(); } MessageBox.Show(Application.Current.MainWindow, "프로그램 동작을 일시 중지합니다." + '\n' + "다시 시작하려면 일시 중지 단축키를 한번더 누르세요.", "POE 거래소 검색"); } else { if (mConfig.Options.UseCtrlWheel) { MouseHook.Start(); } MessageBox.Show(Application.Current.MainWindow, "프로그램 동작을 다시 시작합니다.", "POE 거래소 검색"); } Native.SetForegroundWindow(findHwnd); } else if (valueLower.IndexOf("{restart}") == 0) { Process.Start(new ProcessStartInfo(Assembly.GetExecutingAssembly().Location) { Arguments = "/wait_shutdown" }); Application.Current.Shutdown(); } else if (!mPausedHotKey) { if (valueLower.IndexOf("{run}") == 0 || valueLower.IndexOf("{wiki}") == 0) { mShowWiki = valueLower.IndexOf("{wiki}") == 0; System.Windows.Forms.SendKeys.SendWait("^{c}"); } else if (valueLower.IndexOf("{enter}") == 0) { Regex regex = new Regex(@"{enter}", RegexOptions.IgnoreCase); string tmp = regex.Replace(shortcut.Value, "" + '\n'); string[] strs = tmp.Trim().Split('\n'); for (int i = 0; i < strs.Length; i++) { SetClipText(strs[i], TextDataFormat.UnicodeText); Thread.Sleep(300); System.Windows.Forms.SendKeys.SendWait("{enter}"); System.Windows.Forms.SendKeys.SendWait("^{a}"); System.Windows.Forms.SendKeys.SendWait("^{v}"); System.Windows.Forms.SendKeys.SendWait("{enter}"); } } else if (valueLower.IndexOf("{link}") == 0) { Regex regex = new Regex(@"{link}", RegexOptions.IgnoreCase); string tmp = regex.Replace(shortcut.Value, "" + '\n'); string[] strs = tmp.Trim().Split('\n'); if (strs.Length > 0) { Process.Start(strs[0]); } } else if (valueLower.IndexOf("{grid:stash}") == 0) { IntPtr pHwnd = Native.FindWindow(null, Title + " - " + "{grid:stash}"); if (pHwnd.ToInt32() != 0) { Native.SendMessage(pHwnd, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } else { WinGrid winGrid = new WinGrid(findHwnd); winGrid.Title = Title + " - " + "{grid:stash}"; winGrid.Show(); } } else if (valueLower.IndexOf(".jpg") > 0) { IntPtr pHwnd = Native.FindWindow(null, POPUP_WINDOW_TITLE); if (pHwnd.ToInt32() != 0) { Native.SendMessage(pHwnd, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } WinPopup winPopup = new WinPopup(shortcut.Value); winPopup.WindowStartupLocation = WindowStartupLocation.Manual; winPopup.Title = POPUP_WINDOW_TITLE; winPopup.Left = 10; winPopup.Top = 10; winPopup.Show(); } } } } } catch (Exception) { ForegroundMessage("잘못된 단축키 명령입니다.", "단축키 에러", MessageBoxButton.OK, MessageBoxImage.Error); } handled = true; } mHotkeyProcBlock = false; } return(IntPtr.Zero); }