6、用vb6写一个仿照SPY++的东西,供大家参考学习用

6、用vb6写一个仿照SPY++的东西,供大家参考学习用,第1张

概述用以学习EnumWindowsProc、SendMessage、WindowFromPoint、WindowFromPoint、ShowWindow、EnableWindow、FindWindow等等API的用法 共有3个窗体,分别为form1,form2,form3,和一个模块Module1 form1代码:form1有label(0~5)标签,text1、text2.。。。text5等5个te

用以学习EnumwindowsProc、SendMessage、WindowFromPoint、WindowFromPoint、ShowWindow、EnableWindow、FinDWindow等等API的用法

共有3个窗体,分别为form1,form2,form3,和一个模块Module1

form1代码:form1有label(0~5)标签,text1、text2.。。。text5等5个textBox

Private Sub Form_Load()    Success = SetwindowPos(Me.hwnd,-1,3)    Me.left = Screen.WIDth - 1900    Me.top = Screen.Height - 1710End SubPrivate Sub Form_Unload(Cancel As Integer)    EndEnd SubPrivate Sub Label1_MouseUp(Index As Integer,button As Integer,Shift As Integer,x As Single,y As Single)    If button And 2 Then PopupMenu Form3.tfileEnd SubPrivate Sub Timer1_Timer()If GetAsyncKeyState(vbKeyF2) Then    Form2.ListVIEw1.ListItems.Clear    EnumChildwindows Text1.Text,AddressOf EnumwindowsProc,ByVal 0&    Form2.ShowEnd IfIf GetAsyncKeyState(vbKeyF3) Then    Clipboard.Clear    Clipboard.SetText Text4.Text    MsgBox "窗口标题已保存至剪贴板。",vbOKOnly,"提示"End If        Static lX As Long,lY As Long,stayTime As Long    On Local Error Resume Next    Dim P As POINTAPI,h As Long,hD As Long,r As Long    GetCursorPos P    lX = P.x: lY = P.y    Px.x = P.x    Px.y = P.y    '设备环境是一个结构,它定义了一系列图形对象及其相关的属性,以及会影响输出结果的绘图方式。这些图形对象包括:画笔(用于画直线),'笔刷(用于绘图和填充),位图(用于屏幕的拷贝或滚动),调色板(用于定义可用的颜色集),剪裁区(用于剪裁和其他 *** 作),路径(用'于绘图和画图 *** 作)。设备环境函数用于对设备环境进行创建、删除或获取信息    h = WindowFromPoint(lX,lY) '取得点所在控件的句柄    hD = GetDC(h)    ScreenToClIEnt h,P    r = GetPixel(hD,P.x,P.y)    ReleaseDC h,hD    Text1.Text = h    Text2.Text = hD    Text3.Text = Hex(r)    Text3.Backcolor = r            Dim WindowText As String,Classname As String    WindowText = String(64,0)    GetwindowText Text1.Text,WindowText,Len(WindowText)    Classname = String(64,0)    GetClassname Text1.Text,Classname,64    Text4.Text = left(WindowText,InStr(1,vbNullChar) - 1)    Text5.Text = left(Classname,vbNullChar) - 1)End Sub


form2代码:form2只有一个ListvIEw1控件

Private Sub ListVIEw1_MouseUp(button As Integer,y As Single)If Trim(ListVIEw1.SelectedItem.ListSubItems(2).Text) = "可用" Then   Form3.tenable = False   Form3.tdisable = TrueElse   Form3.tenable = True   Form3.tdisable = FalseEnd IfIf Trim(ListVIEw1.SelectedItem.ListSubItems(3).Text) = "可见" Then   Form3.tshow = False   Form3.thIDe = TrueElse   Form3.tshow = True   Form3.thIDe = FalseEnd IfIf button And 2 Then PopupMenu Form3.teditEnd Sub


form3是菜单,无控件,菜单内容请看代码:

Private Sub tdisable_Click()  Dim i As Long  i = EnableWindow(Form2.ListVIEw1.SelectedItem.Text,0)  '第2参非0即为ENABLE  Form2.ListVIEw1.SelectedItem.ListSubItems(2).Text = "禁用"End SubPrivate Sub tenable_Click()  Dim i As Long  Dim s As String  i = EnableWindow(Form2.ListVIEw1.SelectedItem.Text,1)  '第2参非0即为ENABLE  Form2.ListVIEw1.SelectedItem.ListSubItems(2).Text = "可用"End SubPrivate Sub tshow_Click()  Dim i As Long  i = ShowWindow(Form2.ListVIEw1.SelectedItem.Text,1)  '第2参非0即为ENABLE  Form2.ListVIEw1.SelectedItem.ListSubItems(3).Text = "可见"End SubPrivate Sub thIDe_Click()  Dim i As Long  i = ShowWindow(Form2.ListVIEw1.SelectedItem.Text,0)  '第2参非0即为ENABLE  Form2.ListVIEw1.SelectedItem.ListSubItems(3).Text = "隐藏"End SubPrivate Sub tquit_Click()EndEnd SubPrivate Sub tunlock_Click()Const WM_USER = &H400Const EM_SETReadonly = (WM_USER + 31)  Dim i As Long  i = SendMessage(Form2.ListVIEw1.SelectedItem.Text,EM_SETReadonly,True,ByVal 0&)End Sub


module1的代码:

Public Declare Function FinDWindow lib "user32" Alias "FinDWindowA" (ByVal lpClassname As String,ByVal lpWindowname As String) As LongPublic Declare Function GetCursorPos lib "user32" (lpPoint As POINTAPI) As LongPublic Declare Function GetDC lib "user32" (ByVal hwnd As Long) As LongPublic Declare Function ReleaseDC lib "user32" (ByVal hwnd As Long,ByVal hdc As Long) As LongPublic Declare Function GetPixel lib "gdi32" (ByVal hdc As Long,ByVal x As Long,ByVal y As Long) As LongPublic Declare Function ScreenToClIEnt lib "user32" (ByVal hwnd As Long,lpPoint As POINTAPI) As LongPublic Declare Function WindowFromPoint lib "user32" (ByVal xPoint As Long,ByVal yPoint As Long) As LongPublic Declare Function SetwindowPos lib "user32" (ByVal h&,ByVal hb%,ByVal x%,ByVal y%,ByVal cx%,ByVal cy%,ByVal f%) As IntegerPublic Declare Function GetwindowText lib "user32" Alias "GetwindowTextA" (ByVal hwnd As Long,ByVal lpString As String,ByVal cch As Long) As LongPublic Declare Function GetwindowTextLength lib "user32" Alias "GetwindowTextLengthA" (ByVal hwnd As Long) As LongPublic Declare Function GetClassname lib "user32" Alias "GetClassnameA" (ByVal hwnd As Long,ByVal lpClassname As String,ByVal nMaxCount As Long) As LongPublic Declare Function EnumChildwindows lib "user32" (ByVal hWndParent As Long,ByVal lpEnumFunc As Long,ByVal lParam As Long) As LongPublic Declare Function IsWindowEnabled lib "user32" (ByVal hwnd As Long) As LongPublic Declare Function IsWindowVisible lib "user32" (ByVal hwnd As Long) As LongPublic Declare Function EnableWindow lib "user32" (ByVal hwnd As Long,ByVal fEnable As Long) As LongPublic Declare Function ShowWindow lib "user32" (ByVal hwnd As Long,ByVal nCmdshow As Long) As LongPublic Declare Function ReleaseCapture lib "user32" () As LongPublic Declare Function SendMessage lib "user32" Alias "SendMessageA" (ByVal hwnd As Long,ByVal wMsg As Long,ByVal wParam As Long,lParam As Any) As Long'截获热键Public Declare Function GetAsyncKeyState lib "user32" (ByVal vkey As Long) As IntegerPublic Type POINTAPIx As Longy As LongEnd TypePublic Function EnumwindowsProc(ByVal hnd As Long,ByVal lParam As Long) As Boolean    Dim sSave As String,Ret As Long        Dim isEnabled As Boolean,IsEn As String    Dim isVisable As Boolean,IsVi As String        isEnabled = IsWindowEnabled(hnd)    isVisable = IsWindowVisible(hnd)        If isEnabled = True Then       IsEn = "  可用"    Else       IsEn = "  禁用"    End If        If isVisable = True Then       IsVi = "  可见"    Else       IsVi = "  隐藏"    End If          Ret = GetwindowTextLength(hnd)    sSave = Space(Ret)    GetwindowText hnd,sSave,Ret + 1        Dim Classname As String    Classname = String(64,0)    GetClassname hnd,64    Classname = left(Classname,vbNullChar) - 1)            Dim ListTemp As Variant      Set ListTemp = Form2.ListVIEw1.ListItems.Add(,hnd)      ListTemp.SubItems(1) = sSave      ListTemp.SubItems(2) = IsEn      ListTemp.SubItems(3) = IsVi      ListTemp.SubItems(4) = Classname        EnumwindowsProc = True '=true继续列举到结束,=false则停止列举    End Function


仅供大家参考学习,偶尔用于解除某些软件中按钮的限制,呵呵,当然不要报太大希望,人家都有防止此类情况的措施的。

代码下载链接:http://download.csdn.net/detail/icbyboy/5005114

总结

以上是内存溢出为你收集整理的6、用vb6写一个仿照SPY++的东西,供大家参考学习用全部内容,希望文章能够帮你解决6、用vb6写一个仿照SPY++的东西,供大家参考学习用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1281530.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存