⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.vb

📁 查看文件密码
💻 VB
字号:
Imports System.Text

Public Class MainFrm

    Declare Function RegisterHotKey Lib "user32.dll" Alias _
        "RegisterHotKey" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Boolean
    Declare Function UnRegisterHotKey Lib "user32.dll" Alias _
        "UnregisterHotKey" (ByVal hwnd As IntPtr, ByVal id As Integer) As Boolean
    Declare Function WindowFromPoint Lib "user32" Alias _
        "WindowFromPoint" (ByVal xPoint As Integer, ByVal yPoint As Integer) As Integer
    Declare Function SendMessageA Lib "user32" Alias _
        "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer

    Const WM_HOTKEY = &H312
    Const Key_ALT = &H1
    Const Key_CONTROL = &H2
    Const Key_SHIFT = &H4
    Const GWL_WNDPROC = (-4)
    Const WM_GETTEXT = &HD
    Const WM_GETTEXTLENGTH = &HE
    Dim lngPosX, lngPosY As Integer
    Dim intHwnd As Integer
    Const intLengthA = 1500
    Dim Str As New StringBuilder(intLengthA)

    Private Sub TimerGetTxt_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerGetTxt.Tick
        lngPosX = Windows.Forms.Cursor.Position.X
        lngPosY = Windows.Forms.Cursor.Position.Y
        LBMousXY.Text = lngPosX & "," & lngPosY
        intHwnd = WindowFromPoint(lngPosX, lngPosY)
        SendMessageA(intHwnd, WM_GETTEXT, intLengthA, Str)
        Me.TxtBoxStr.Text = Str.ToString.Trim
    End Sub

    Private Sub BtExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtExit.Click
        UnRegisterHotKey(Handle, 0)
        Application.Exit()
    End Sub

    Private Sub MainFrm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        UnRegisterHotKey(Handle, 0)
        Application.Exit()
    End Sub

    Private Sub MainFrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '注册Ctrl+T的组合键
        RegisterHotKey(Handle, 0, Key_CONTROL, Asc("T"))
    End Sub

    Protected Overrides Sub WndProc(ByRef m As Message)
        If m.Msg = WM_HOTKEY Then
            Me.TimerGetTxt.Enabled = Not Me.TimerGetTxt.Enabled
            If Me.TimerGetTxt.Enabled Then
                Me.LBColorShow.BackColor = Color.Lime
            Else
                Me.LBColorShow.BackColor = Color.Tomato
            End If
        End If
        MyBase.WndProc(m)
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -