码迷,mamicode.com
首页 > 其他好文 > 详细

鼠标连点器

时间:2019-02-01 17:12:12      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:count   ssid   txt   span   key   atoi   lse   zip   cstring   

//快捷键开启关闭连点器
void
CmouseClickDlg::OnHotKey( UINT uMsg, UINT wParam, UINT lParam ) { if(!m_canClick) { CString str; m_txtTime.GetWindowText(str); m_interval = atoi(str); m_pWindowTimer = SetTimer(0, m_interval, NULL); m_canClick = true; } else { m_canClick = false; KillTimer(m_pWindowTimer); } }
//timer回调模拟点击
void
CmouseClickDlg::OnTimer( UINT nIDEvent ) { if(!m_canClick) return; static int lasttick = 0; if (lasttick == 0) { lasttick = GetTickCount(); } TRACE("TIME: %d\r\n", GetTickCount()-lasttick); lasttick = GetTickCount(); CPoint pt; GetCursorPos(&pt); CWnd* pWnd = WindowFromPoint(pt); HWND hWnd = pWnd->GetSafeHwnd(); if(!hWnd) { MessageBox(_T("获取句柄失败")); return; } DWORD dwPId = 0; ::GetWindowThreadProcessId(hWnd, &dwPId); if(!dwPId) { MessageBox(_T("获取PID失败")); return; } ::ScreenToClient(hWnd, &pt); DWORD para = pt.y << 16 | pt.x; ::PostMessage(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, para); ::PostMessage(hWnd, WM_LBUTTONUP, MK_LBUTTON, para); }

 

下载源码

鼠标连点器

标签:count   ssid   txt   span   key   atoi   lse   zip   cstring   

原文地址:https://www.cnblogs.com/barrysgy/p/10346182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!