2014-07-21 61 views
-1

我合成,如下圖所示使用SendInput鼠標事件。 它一切正常。當我使用鼠標鉤子來檢測合成值(或者只是使用ProcMon)時,我得到了我發送的內容。具體而言,dwExtraInfo還在1024API:參數dwExtraInfo被覆蓋

現在,當我使用Windows 7,dwExtraInfo會自動被Windows替換爲一個號碼:-11054848。我不知道這是從哪裏來的,我在MSDN上沒有找到關於此的任何信息。

起初,我以爲是Windows只是「與」編一個值,我的價值,但我想這是不是這樣的。

有誰知道這是怎麼回事?

Dim inputevents(0) As INPUT_Type ' holds information about each event 

Dim mouseevent As MOUSEINPUT ' temporarily hold mouse input info 

With mouseevent 
    .dX = 0 ' no horizontal movement 
    .dy = 0 ' no vertical movement 
    .mouseData = 0 
    .dwFlags = MOUSEEVENTF_LEFTDOWN 
    .dwTime = 0 ' use the default 
    .dwExtraInfo = 1024 'this is my custom value 
End With 

' Copy the structure into the input array's buffer. 
inputevents(0).dwType = INPUT_MOUSE ' mouse input 
CopyMemory inputevents(0).xi(0), mouseevent, Len(mouseevent) 

' Now that all the information for the four input events has been placed 
' into the array, finally send it into the input stream. 
Dim lRet& 
lRet = SendInput(1, inputevents(0), Len(inputevents(0))) 

這就是我如何閱讀Windows消息。 我想我很有經驗,它總是工作得很好:

 Dim nMouseDat As WinSubHook2.tMSLLHOOKSTRUCT 'Low-level mouse data 
     'lParam points to the low-level mouse data, copy it to dat 
     nMouseDat = hkMs.xMSLLHOOKSTRUCT(lParam) 
     'Here nMouseDat.dwExtraInfo should be 1024, but instead it is -11054848 
+0

這是代碼的一部分。我們看不到類型聲明。我們不能看到調用GetMessageExtraInfo的代碼 –

+0

@DavidHeffernan你是對的。我編輯了我的帖子並添加了鉤子代碼。在Windows-7之前的版本上,我的預期一直如常。 – tmighty

+0

標準的64位損失。太多的VB6代碼,所以MOUSEINPUT.dwExtraInfo可能沒有聲明爲IntPtr。 Len()從根本上說是錯誤的,CopyMemory是毫無意義的。 –

回答

3

Windows 7的產生範圍的消息額外的消息信息WM_MOUSEFIRSTWM_MOUSELAST允許客戶端查詢鼠標輸入消息的來源。原因在於Windows爲響應觸摸輸入而生成鼠標輸入,爲未實現專用觸摸支持的應用程序提供最低限度的支持。

這是在System Events and Mouse Messages記錄。常數MI_WP_SIGNATURE被宣佈爲0xFF515700。將其轉換爲有符號整數並得到-11054848

+0

非常感謝您的信息!所以Windows完全殺死了我的「用戶價值」,我無能爲力,對吧? – tmighty

+1

@tmighty:我不知道有一種方法可以防止Windows覆蓋郵件的額外信息。 ['GetMessageExtraInfo'](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644954.aspx)的文檔包含以下線索:*額外信息的含義是特定於設備的。*我的解釋是,這是*驅動程序定義的*而不是*應用程序定義的*,但文檔在這個特定的主題上什麼都不明確。 – IInspectable