定时式获取鼠标处xy坐标和窗口对象(winapi)
来源:互联网 发布:网易班车路线 知乎 编辑:程序博客网 时间:2024/06/05 06:33
看了一下.hook比较麻烦.反正弄个小东西,就使用了这个方式;
#include <windows.h>
/*
* ini解析模块
* 下载地址:http://ndevilla.free.fr/iniparser/
* 使用方式:解压后把src中的所有文件复制到本工程中的iniparser目录中
* 接着把里面的c后缀文件添加到工程中,否则会出现链接不了的问题
*/
#define ID_TEXT 2
#define INI_NAME "keys.ini"
#define IDT_TIME 10
/*
* 函数声明部分
*/
void create_default_ini_file(char *ini_name);
void parse_ini_file(char * ini_name);
/*
* 声明结束
*/
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "通用全局快捷键发送程序";
dictionary * ini ;
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"通用全局快捷键发送程序", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
UpdateWindow (hwnd) ;
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* 消息处理 */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
POINT mmPoint;
char wTitle[256], gTitle[120];
HWND mHwnd;
switch (message) {
case WM_CREATE :
SetTimer (hwnd, IDT_TIME, 10, NULL);//运行就设置定时刷新
return 0 ;
case WM_TIMER:
GetCursorPos (&mmPoint);//获取坐标
mHwnd = WindowFromPoint (mmPoint);//由坐标得够本
int gType = GetWindowText (mHwnd, gTitle, 100);//够本得窗口标题
wsprintf (wTitle, TEXT ("X : %d, Y : %d, mHnd:%d, gType: %d, wtitle: %s "), mmPoint.x, mmPoint.y, mHwnd, gType, gTitle);
SetWindowText (hwnd, wTitle);//在程序窗口显示标题
return 0;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
KillTimer (hwnd, IDT_TIME);//取消定时
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
}
- 定时式获取鼠标处xy坐标和窗口对象(winapi)
- 获取鼠标XY坐标
- js中获取各种窗口的大小和鼠标坐标
- js获取各种窗口的大小和鼠标坐标
- js中获取各种窗口的大小和鼠标坐标
- Java获取窗口鼠标坐标以及键盘
- 鼠标定坐标连线画图(面向对象)
- 获取事件目标对象的位置坐标或者鼠标位置坐标(兼容IE和火狐)
- js event对象获取鼠标坐标
- vb6源码后台点击任意窗口指定坐标XY位置,支持FLASH和一般的游戏
- WinAPI: OffsetWindowOrgEx - 移动窗口坐标原点
- WinAPI: SetWindowOrgEx - 设置窗口坐标原点
- Android listview和gridview获取当前xy坐标是第几个item
- [C#]获取和设置鼠标的坐标
- C#获取和设置鼠标的坐标
- VC 获取鼠标当前位置坐标和RGB
- C++获取程序窗口外的鼠标坐标
- C#如何获取鼠标相对当前窗口的坐标
- ie的open方法不支持窗口名中包含小数点
- ie中top/self都是只读
- 一作恶的网站强制弹出窗口代码
- 自动从头到尾播放清风dj网的代码
- c语言列举window进程
- 定时式获取鼠标处xy坐标和窗口对象(winapi)
- man rsyslog.conf 帮助内容输出到文件
- postfix 日志过滤与linux 日志 模块rsyslog配置
- [转]利用winapi向其它进程发送键盘按键消息
- 全部虚拟键盘键码
- C++模板
- 键盘扫描码
- 很实用(极少使用的词)的键盘消息转发(热键间接设置程序) [有代码]
- ie选项中禁用动画显示并不会禁用object之类的控件