最近在使用PostMessage來撰寫鍵盤滑鼠輔助程式
測試發現
鍵盤跟滑鼠的模擬在記事本跟小畫家都可正常執行
但在遊戲中卻只有鍵盤可被模擬
滑鼠模擬都完全沒有反應
透過SPY++測試
我送出之Mouse Message已有成功被接收到
而且與直接在遊戲中產生的Message完全一致
但是沒反應就是沒反應
程式碼如下
Dim lParam As Integer = y * 65536 + x
Dim testlParam As Integer = (y + 30) * 65536 + (x + 5)
Call SendMessage(hwd, 132, 0, testlParam) 'NCHitTest
Call SendMessage(hwd, 32, hwd, 33619969) 'SetCursor
Call PostMessage(hwd, WM_LBUTTONDOWN, 1, lParam) 'ButtonDown
Call PostMessage(hwd, 1025, 2508, 1) 'W_MUSER+1
Sleep(300)
Call SendMessage(hwd, 132, 0, testlParam) 'NCHitTest
Call SendMessage(hwd, 32, hwd, 33685505) 'SetCursor
Call PostMessage(hwd, WM_LBUTTONUP, 0, lParam) 'ButtonUp
Call PostMessage(hwd, 1025, 2508, 1) 'WMUSER+1
SPY++攔截我送出的Message
S WM_NCHITTEST xPos:760 yPos:315
R WM_NCHITTEST nHittest:HTCLIENT
S WM_SETCURSOR hwnd:000A0570 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONDOWN
R WM_SETCURSOR fHaltProcessing:False
P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:760 yPos:315
P message:0x0401 [使用者定義:WM_USER+1] wParam:000009CC lParam:00000001
P message:0x0401 [使用者定義:WM_USER+1] wParam:000009CC lParam:00000001
S WM_NCHITTEST xPos:760 yPos:315
R WM_NCHITTEST nHittest:HTCLIENT
S WM_SETCURSOR hwnd:000A0570 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONUP
R WM_SETCURSOR fHaltProcessing:False
P WM_LBUTTONUP fwKeys:0000 xPos:760 yPos:315
SPY++攔截系統送出的Message
S WM_NCHITTEST xPos:258 yPos:339
R WM_NCHITTEST nHittest:HTCLIENT
S WM_SETCURSOR hwnd:000A0570 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONDOWN
R WM_SETCURSOR fHaltProcessing:False
P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:253 yPos:309
P message:0x0401 [使用者定義:WM_USER+1] wParam:000009CC lParam:00000001
P message:0x0401 [使用者定義:WM_USER+1] wParam:000009CC lParam:00000001
S WM_NCHITTEST xPos:258 yPos:339
R WM_NCHITTEST nHittest:HTCLIENT
S WM_SETCURSOR hwnd:000A0570 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONUP
R WM_SETCURSOR fHaltProcessing:False
P WM_LBUTTONUP fwKeys:0000 xPos:253 yPos:309 |