有没更好的代码解决这个问题
写了一个代码,感觉太程序化了,有没有更好代码实现功能。小白一个,望大大们指点!
#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();
}