Imports System.Drawing Imports System.Windows.Forms Imports System.IO Imports System.Text Public Class Form1 Public x, y, ini, cnt As Long Public k, kchar As String Public m(), keysA() As String Public xp(), yp() As Long Public keys = New List(Of String)() Dim col As Color Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.KeyPreview = True 'https://docs.microsoft.com/ja-jp/office/vba/api/access.form.keypreview 'http://rucio.cloudapp.net/ThreadDetail.aspx?ThreadId=30670 ini = 0 End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp Me.Text = $"MouseUp:{e.Button} , {e.Location}" cnt = cnt + 1 ReDim Preserve m(cnt), xp(cnt), yp(cnt), keysA(cnt) 'フォーム上の座標でマウスポインタの位置を取得する '画面座標でマウスポインタの位置を取得する Dim sp As System.Drawing.Point = System.Windows.Forms.Cursor.Position '画面座標をクライアント座標に変換する Dim cp As System.Drawing.Point = Me.PointToClient(sp) 'X座標を取得する Dim x As Integer = cp.X 'Y座標を取得する Dim y As Integer = cp.Y 'https://dobon.net/vb/dotnet/system/cursorposition.html Dim rc, gc, bc As Long If e.Button = MouseButtons.Left Then 'MsgBox(kchar & "クリックしました!(" & x & "," & y & ")") ' Me.CreateGraphics.Clear(Me.BackColor) m(cnt) = "L" col = Color.FromArgb(255, 0, 0) End If If e.Button = MouseButtons.Right Then 'MsgBox(kchar & "クリックしました!(" & x & "," & y & ")") ' Me.CreateGraphics.Clear(Me.BackColor) m(cnt) = "R" col = Color.FromArgb(0, 255, 0) End If xp(cnt) = x yp(cnt) = y 'https://dobon.net/vb/bbs/log3-46/27779.html keysA(cnt) = TakeOut(keys) keys.Clear() Invalidate() End Sub