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

📄 form1.frm

📁 variant code in this rar zipped package
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "取得密码"
   ClientHeight    =   2595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3090
   LinkTopic       =   "Form1"
   ScaleHeight     =   2595
   ScaleWidth      =   3090
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command5 
      Caption         =   "退 出"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   840
      TabIndex        =   5
      Top             =   2160
      Width           =   1575
   End
   Begin VB.CommandButton Command4 
      Caption         =   "停止密码自动显示"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1680
      TabIndex        =   4
      Top             =   1440
      Width           =   1095
   End
   Begin VB.CommandButton Command3 
      Caption         =   "停止取得密码显示"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1680
      TabIndex        =   3
      Top             =   720
      Width           =   1095
   End
   Begin VB.Timer Timer2 
      Interval        =   1000
      Left            =   2520
      Top             =   2160
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取得密码   显示"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   240
      TabIndex        =   2
      Top             =   720
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "启动密码自动显示"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   240
      TabIndex        =   1
      Top             =   1440
      Width           =   1095
   End
   Begin VB.Timer Timer1 
      Interval        =   50
      Left            =   120
      Top             =   2160
   End
   Begin VB.Label Label1 
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   18
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2775
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Type pointAPI
    x As Long
    y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As pointAPI) As Long

Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, _
ByVal yPoint As Long) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) _
As Long

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal _
hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long

'判断一个窗口句柄是否有效
Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long

'这个函数屏蔽一个窗口客户区的全部或部分区域。这会导致窗口在事件期间部分重画
Private Type RECT
     Left As Long
     Top As Long
     Right As Long
     Bottom As Long
    End Type
Private Declare Function InvalidateRect& Lib "user32" (ByVal hwnd As Long, lpRect As Any, ByVal bErase As Long)

Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const WM_GETTEXT = &HD
Private Const WM_PAINT = &HF
Private Const EM_SETPASSWORDCHAR = &HCC
Private Const WM_ERASEBKGND = &H14
Private MyPoint As pointAPI

Private Sub Command1_Click()
Timer2.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = True

End Sub

Private Sub Command3_Click()
Timer1.Enabled = False
Label1.Caption = ""
End Sub

Private Sub Command4_Click()
Timer2.Enabled = False
End Sub

Private Sub Command5_Click()
End
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 50
Timer2.Interval = 1000
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub

Private Sub Timer1_Timer()
    Dim curwnd As Long
    Dim strLong As Long
    Dim rtn As Long
    Dim TempStr As String
        
    TempStr = Space(255)
    strLong = Len(TempStr)
    GetCursorPos MyPoint
    curwnd = WindowFromPoint(MyPoint.x, MyPoint.y)
    rtn = SendMessage(curwnd, WM_GETTEXT, strLong, TempStr)
    Label1.Caption = TempStr
        
End Sub

Private Sub Timer2_Timer()
   Dim curwnd As Long
   Dim isWnd As Boolean
Dim temp As Long
  
Timer2.Enabled = True
GetCursorPos MyPoint
curwnd = WindowFromPoint(MyPoint.x, MyPoint.y)
isWnd = IsWindow(curwnd)
    If isWnd <> 0 Then
     temp = SendMessage(curwnd, EM_SETPASSWORDCHAR, 0, 0)
     temp = InvalidateRect(0, 0, 1)
     End If
End Sub

⌨️ 快捷键说明

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