看板 Visual_Basic 關於我們 聯絡資訊
請輸入專案類型(網站專案或者應用程式專案): 小型專案測試 請教一下,我想要寫個小程式, 可以在螢幕的畫面上不同位置,自動執行滑鼠的按鍵動作, 目前有找到相關的程式碼, 但是是限於執行專案的介面上, 不過我是想可以執行程式後, 在螢幕桌面上的任何位置都可執行滑鼠的按鍵動作, 不曉得該如何改程式碼的部分呢?! 目前找到的程式碼部分如下: ' mouse_event moves in a coordinate system where ' (0, 0) is in the upper left corner and ' (65535,65535) is in the lower right corner. ' Convert the coordinates. Dim screen_bounds As Rectangle = Screen.GetBounds(pt) Dim x As Integer = CInt(pt.X * 65535 / screen_bounds.Width) Dim y As Integer = CInt(pt.Y * 65535 / screen_bounds.Height) 謝謝各位達人們!!! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.238.119.170 ※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1528813818.A.0D5.html
MOONRAKER: 這個程式碼就邏輯座標/pixel座標轉換而已 06/13 10:30
MOONRAKER: 這樣也算跟滑鼠事件相關 那我應該是周星馳 06/13 10:31
chinoyan: XY定義好了,但,你的API CALL 呢? 06/13 21:28
morningjis: Private Declare Sub mouse_event Lib "user32" 06/18 13:08
morningjis: 那這個邏輯座標是只在專案視窗畫面 06/18 13:09
morningjis: 那我要怎麼才能轉換到 專案視窗外的桌面畫面上呢?! 06/18 13:10
morningjis: 我的pt定義為 06/18 13:11
morningjis: Dim pt As Point = Me.PointToScreen(m_Target) 06/18 13:11
chinoyan: MOUSE_EVENT 是全局的 06/20 06:06