[.NET] 請益讓滑鼠自動移動至設定處

看板Visual_Basic作者 (morning)時間5年前 (2018/06/12 22:30), 編輯推噓2(207)
留言9則, 3人參與, 5年前最新討論串1/2 (看更多)
請輸入專案類型(網站專案或者應用程式專案): 小型專案測試 請教一下,我想要寫個小程式, 可以在螢幕的畫面上不同位置,自動執行滑鼠的按鍵動作, 目前有找到相關的程式碼, 但是是限於執行專案的介面上, 不過我是想可以執行程式後, 在螢幕桌面上的任何位置都可執行滑鼠的按鍵動作, 不曉得該如何改程式碼的部分呢?! 目前找到的程式碼部分如下: ' 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

06/13 10:30, 5年前 , 1F
這個程式碼就邏輯座標/pixel座標轉換而已
06/13 10:30, 1F

06/13 10:31, 5年前 , 2F
這樣也算跟滑鼠事件相關 那我應該是周星馳
06/13 10:31, 2F

06/13 21:28, 5年前 , 3F
XY定義好了,但,你的API CALL 呢?
06/13 21:28, 3F

06/18 13:08, 5年前 , 4F
Private Declare Sub mouse_event Lib "user32"
06/18 13:08, 4F

06/18 13:09, 5年前 , 5F
那這個邏輯座標是只在專案視窗畫面
06/18 13:09, 5F

06/18 13:10, 5年前 , 6F
那我要怎麼才能轉換到 專案視窗外的桌面畫面上呢?!
06/18 13:10, 6F

06/18 13:11, 5年前 , 7F
我的pt定義為
06/18 13:11, 7F

06/18 13:11, 5年前 , 8F
Dim pt As Point = Me.PointToScreen(m_Target)
06/18 13:11, 8F

06/20 06:06, 5年前 , 9F
MOUSE_EVENT 是全局的
06/20 06:06, 9F
文章代碼(AID): #1R7zZw3L (Visual_Basic)
文章代碼(AID): #1R7zZw3L (Visual_Basic)