调戏QQ

来源:互联网 发布:更改电信网络节点网址 编辑:程序博客网 时间:2024/05/06 06:14

本文中所用到的探测窗体信息的工具Spy下载地址:  http://download.csdn.net/detail/q269399361/8594303


#include <stdio.h>#include <stdlib.h>#include <Windows.h>typedef void (*animate)(HWND);void openqq(){//参数1:代表系统弹出//参数2:执行//参数3: 执行命令行//参数4、5: 默认0  用于扩展的参数//参数6:0隐藏打开 1正常打开  3 最大化打开 6最小化打开//可将参数3换成notepad  看参数6的效果ShellExecuteA(0,"open","\"C:\\Program Files (x86)\\Tencent\\QQ\\QQProtect\\Bin\\QQProtect.exe\"",0,0,1);}void closeqq(){system("taskkill /f /im qq.exe");}//获得QQ句柄HWND get_qq_wnd(){//使用Spy探测return FindWindowA("TXGuiFoundation","QQ");}//显示隐藏QQvoid show_hide_qq(HWND hWnd){show_hide:ShowWindow(hWnd,SW_HIDE);Sleep(1000);ShowWindow(hWnd,SW_SHOW);Sleep(1000);goto show_hide;}//1366x768的屏幕分辨率void move1(HWND hWnd){int x;//485是QQ登录窗口的宽度,460是高度,可用QQ截图查看SetWindowPos(hWnd,NULL,0,0,485,460,0);for ( x= 0; x < 1366-485; x+=10){SetWindowPos(hWnd,NULL,x,0,485,460,0);Sleep(30);}}void move2(HWND hWnd){int y=0;while (y < 768-460){SetWindowPos(hWnd,NULL,1366-485,y,485,460,0);Sleep(30);y+=10;}}void move3(HWND hWnd){int x=1366-485;do{SetWindowPos(hWnd,NULL,x,768-460,485,460,0);Sleep(30);x-=10;} while (x>0);}void move4(HWND hWnd){int y=768-460;start:SetWindowPos(hWnd,NULL,0,y,485,460,0);Sleep(30);y-=10;if(y>0)goto start;}void execute_animate(){HWND hWnd;int i;animate anis[]={move1,move2,move3,move4,show_hide_qq};//打开QQ后需要暂停2秒左右,ShellExecuteA的执行时异步的,不暂停 获得QQ的wnd会为空Sleep(2000);hWnd=get_qq_wnd();if (hWnd==NULL){printf("QQ没有运行成功");}else{for (i = 0; i < 5; i++){anis[i](hWnd);}}}int main(){closeqq();openqq();execute_animate();getchar();return 0;}

本片代码如上:


用到的技术:


Windows底层函数: ShellExecuteA、FindWindowA、SetWindow、SetWindowPos


循环的使用:for、while、do{}while、goto


函数指针和 typedef  的妙用、函数指针数组的使用、线程睡眠

0 0