zoukankan      html  css  js  c++  java
  • WPF 中使用Hook

    public DocumentWindow()
          {
              InitializeComponent();
      this.SourceInitialized += new EventHandler(OnSourceInitialized);
          }
          void OnSourceInitialized(object sender, EventArgs e)
          {
              HwndSource source = (HwndSource)PresentationSource.FromVisual(this);
              source.AddHook(new HwndSourceHook(HandleMessages));
          }
          private IntPtr HandleMessages(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
          {
              //KeyboardHook  一个钩子类
              KeyboardHook hk = new KeyboardHook();
              hk.KeyDown += new System.Windows.Forms.KeyEventHandler(kh_KeyDown);
              return System.IntPtr.Zero;
          }
     
     
          void kh_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
          {
              if (e.KeyCode == Keys.F5)
              {
                  System.Windows.Forms.MessageBox.Show("f5");
                  e.Handled = true;
                  Microsoft.Office.Interop.PowerPoint._Presentation myPres =
                    (Microsoft.Office.Interop.PowerPoint.Presentation)framer.ActiveDocument;
                  myPres.SlideShowSettings.RangeType = PpSlideShowRangeType.ppShowSlideRange;
                  var mm = myPres.SlideShowSettings;
                  var app = myPres.Application;
                  mm.Run();
              }
              else if (e.KeyCode == Keys.Escape)
              {
                  //System.Windows.Forms.MessageBox.Show("退?出?");
                  e.Handled = true;
                  this.Close();
              }
              if (e.KeyCode == Keys.Right)
              {
                 // e.Handled = true;
                 // Microsoft.Office.Interop.PowerPoint._Presentation myPres =
                 //  (Microsoft.Office.Interop.PowerPoint.Presentation)framer.ActiveDocument;
                 // myPres.SlideShowSettings.RangeType = PpSlideShowRangeType.ppShowSlideRange;
                 // var mm = myPres.SlideShowSettings;
                 // mm.LoopUntilStopped=Microsoft.Office.Core.MsoTriState.msoTrue;
                 ////myPres.SlideShowWindow.View.LastSlideViewed
                 //// var app = myPres.Application;
                 // mm.Run();
              }
              //if (e.KeyCode == Keys.F1 && !fInCall)
              //{
              //    e.Handled = true;
              //    fInCall = true;
              //    tmrDelayedCall = new Timer();
              //    tmrDelayedCall.Interval = 1;
              //    tmrDelayedCall.Tick += new
              //    EventHandler(tmrDelayedCall_Tick);
              //    tmrDelayedCall.Start();
              //}
          }
     

    hook 类实现 IDisposable接口

  • 相关阅读:
    jmeter-plugins-manager安装
    JMeter安装
    charles
    url地址有哪些组成?
    服务器的响应状态码
    jQuery链式编程
    jQuery 实现单选反选以及三元运算
    jQuery选择器的基本和层级
    将jmeter返回的json数据转码
    DOM的事件
  • 原文地址:https://www.cnblogs.com/z_lb/p/1997758.html
Copyright © 2011-2022 走看看