VB.Net程序设计:密码查看器

前端之家收集整理的这篇文章主要介绍了VB.Net程序设计:密码查看器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

网上许多密码查看器,但要注册。要钱。自己要用到。所以自己用VB.Net写了一个。很简单的几十行代码
在win2000+vs2005测试通过。可以看密码框里*号下是什么内容。对于简单的密码框有效。

软件界面如下:

代码

[code=vb.net]

Imports System.Text

Public Class MainFrmClass MainFrm

Declare Function RegisterHotKey()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()Function UnRegisterHotKey Lib "user32.dll" Alias _
"UnregisterHotKey" (ByVal hwnd As IntPtr,ByVal id As Integer) As Boolean
Declare Function WindowFromPoint()Function WindowFromPoint Lib "user32" Alias _
"WindowFromPoint" (ByVal xPoint As Integer,ByVal yPoint As Integer) As Integer
Declare Function SendMessageA()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()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()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()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()Sub MainFrm_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
'注册Ctrl+T的组合键
RegisterHotKey(Handle,Key_CONTROL,Asc("T"))
End Sub

Protected Overrides Sub WndProc()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 SubEnd Class[/code]

原文链接:https://www.f2er.com/vb/263316.html

猜你在找的VB相关文章