コード例 #1
0
 private void Window_Closed(object sender, EventArgs e)
 {
     if (mAdministrator && mConfig != null)
     {
         if (mInstalledHotKey)
         {
             RemoveRegisterHotKey();
         }
         if (mConfig.Options.UseCtrlWheel)
         {
             MouseHook.Stop();
         }
     }
 }
コード例 #2
0
        private void Window_Closed(object sender, EventArgs e)
        {
            if (mAdministrator && mConfigData != null)
            {
                if (mIsHotKey)
                {
                    RemoveRegisterHotKey();
                }

                if (mConfigData.Options.CtrlWheel)
                {
                    MouseHook.Stop();
                }
            }

            TrayIcon.Visible = false;
            TrayIcon.Dispose();
        }
コード例 #3
0
        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);
        }