| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1170 人关注过本帖
标题:有没更好的代码解决这个问题
只看楼主 加入收藏
c鳌白
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:24
专家分:101
注 册:2019-11-10
结帖率:75%
收藏
 问题点数:0 回复次数:0 
有没更好的代码解决这个问题
写了一个代码,感觉太程序化了,有没有更好代码实现功能。

小白一个,望大大们指点!
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>

void dkjsq()
{
    ShellExecuteA(0, "open", "\"C:\\Program Files (x86)\\Tencent\\QQ\\Bin\\QQScLauncher.exe\"", 0, 0, 1);
}
void hujsq()
{
    HWND win = FindWindowA("TXGuiFoundation", "QQ");//hwnd 窗口的编号
    //    //FindWindowA寻找窗口,根据类名,标题
    if (win == NULL)
     {
         printf("\n获取QQ窗口失败!");
     }
     printf("\n获取QQ窗口成功!");
     int i = 0;
     while (i < 644)
     {
         SetWindowPos(win, NULL, 0, i, 500, 470, 0);
         Sleep(150);
          i += 10;
          if (i == 640)
          {
              HWND chak = FindWindowA("TXGuiFoundation", "QQ");
              if (chak == NULL)
              {
                  printf("第二次获取失败");
              }
              int t = 0;
              while (t < 1450)
              {
                  SetWindowPos(win, NULL, t, 640, 500, 470, 0);
                  Sleep(150);
                  t += 10;
                  if (t == 1450)
                  {
                      HWND chak = FindWindowA("TXGuiFoundation", "QQ");
                      if (chak == NULL)
                      {
                          printf("第三次获取失败");
                      }
                      int a = 640;
                      while (a > 0)
                      {
                          SetWindowPos(win, NULL, 1450, a, 500, 470, 0);
                          Sleep(150);
                          a -= 10;
                          
                          if (a==0)
                          {
                              HWND chak = FindWindowA("TXGuiFoundation", "QQ");
                              if (chak == NULL)
                              {
                                  printf("第四次获取失败");
                              }
                              int b = 1450;
                              while (b>0)
                              {
                                  SetWindowPos(win, NULL, b, 0, 500, 470, 0);
                                  Sleep(150);
                                  b -= 10;
                                 
                              }
                              }
                        
                      }
                  }
              }
          }
     }
}




void main()
{

    dkjsq();
    Sleep(5000);
    hujsq();
   


}
搜索更多相关主题的帖子: QQ win 代码 NULL Sleep 
2019-11-10 09:03
快速回复:有没更好的代码解决这个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022464 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved