小刀人
-No business too small, no problem too big.
<2008年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
公告
  • Learn,Think,and Imagine...

    正在看的书:

    点击发送消息给我

留言簿(6)

随笔分类

随笔档案

文章档案

相册

CSDN

VC知识库

开发站点

技术blog

搜索

最新评论

阅读排行榜

评论排行榜

 
VC知识库BLOG   首页  新随笔  联系  聚合  登录 
  随笔-23 文章-0 评论-61 Trackbacks-0
用发送虚拟按键解决用Windows Media Player看东东的“特殊”问题中工具还是有些问题:
1、timer一直在工作;
2、找到Media Player的句柄值有些麻烦。
今天改了下,如下图:

这样用起来方便些。
主要代码:
       private void button1_Click(object sender, System.EventArgs e)
        

            SetForegroundWindow(NowHwnd);
            SendKeys.Send(
"%PP");
            SetForegroundWindow(NowHwnd); 
            SendKeys.Send(
"% N");
            StartMax();
         }


        
private void timer1_Tick(object sender, System.EventArgs e)
        
{   int myphwnd;
            StringBuilder interswap 
= new StringBuilder(256);

            GetCursorPos(
ref mypoint);
            Lx
=mypoint.x;
            Ly
=mypoint.y;
            myphwnd
=WindowFromPoint(Lx, Ly);

            GetWindowText(myphwnd,interswap, 
255);
            
if (interswap.ToString().IndexOf ("Media")>=0)
             
{
                NowHwnd 
= myphwnd;
                HwndSt.Text
="Media Player已锁定!";
                button1.Enabled
=true;
                timer1.Stop();
            }

            
else
            
{
                NowHwnd 
= myphwnd; 
                HwndSt.Text
=NowHwnd.ToString();
            }

                    
        }


        
private void button2_Click(object sender, System.EventArgs e)
        
{
            
            timer1.Start();
            StopMin();
            button1.Enabled
=false;
        }


        
private void button3_Click(object sender, System.EventArgs e)
        
{
            SetForegroundWindow(NowHwnd); 
            SendKeys.Send(
"% x");
            SetForegroundWindow(NowHwnd);
            SendKeys.Send(
"%PP");
            StopMin();

        }

        
//以下为更换按钮
        public void StopMin()
        
{
            button3.Visible
=false;
            button1.Visible
=true;
        }

        
public void StartMax()
        
{
            button3.Visible
=true;
            button1.Visible
=false;
        }

       
    

源代码下载
posted on 2006-04-14 12:58 小刀人 阅读(2646) 评论(0)  编辑 收藏
Comments
标题  
姓名  
主页
验证码 *
内容   
  登录  使用高级评论  Top
[使用Ctrl+Enter键可以直接提交]