加载中…
个人资料
chenhui530
chenhui530
  • 博客等级:
  • 博客积分:0
  • 博客访问:12,834
  • 关注人气:9
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
相关博文
推荐博文
谁看过这篇博文
加载中…
正文 字体大小:

快捷隐藏QQ界面和托盘脱离老板的监控

(2012-08-13 21:47:26)
标签:

隐藏qq

脱离老板监控

杂谈

分类: VB编程

好吧!我承认我是一个工作不负责的员工,哈哈!

相信大家都得承认,QQ在大家生活工作中已经是必不可少的工具了,而很多公司却怕员工上QQ不务正业,而不允许员工上QQ。而少了QQ我们的生活确实失去了很多光彩,而QQ是我们时常沟通交流,甚至是找人的工具,很多情况下手机也不如QQ管用,因为QQ有庞大的关系链。好了找了这么多借口哈哈,我只是为什么大家找个用QQ的借口了。我们用QQ又怕老板看到怎么办呢?所以这个工具就出世了,我们只需要按快捷键就可以迅速的隐藏所有QQ相关的窗口,也可以按快捷键迅速的把所有隐藏的QQ相关窗口马上还原。而我们也可以按快捷键迅速的清理战场(结束QQ进程以及清理托盘图标)。这样只要不是老板站在你背后了就没有关系了哈哈。

 

程序主要是由处理热键和枚举隐藏窗体来实现。下面是关键性代码:

 

窗口代码:

Private Sub Form_Initialize()
    If App.PrevInstance Then
        End
    End If
    App.TaskVisible = False
End Sub

Private Sub Form_Load()

    g_lpPreWinProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf CallbackMsgs) '调用函数
   
    RegisterHotKey Me.hWnd, 10000, MOD_CTRL, VK_F12
    RegisterHotKey Me.hWnd, 10001, MOD_CTRL, VK_F11
    RegisterHotKey Me.hWnd, 10002, MOD_CTRL, VK_F10
    RegisterHotKey Me.hWnd, 10003, MOD_CTRL, VK_F9
   
    Me.Hide
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If g_hWndsCount Then
        Erase g_hWnds
    End If
    If g_dwQQProcessCount Then
        Erase g_dwQQProcessIds
    End If
   
    SetWindowLong Me.hWnd, GWL_WNDPROC, g_lpPreWinProc
    UnregisterHotKey Me.hWnd, 10000
    UnregisterHotKey Me.hWnd, 10001
    UnregisterHotKey Me.hWnd, 10002
    UnregisterHotKey Me.hWnd, 10003
End Sub

热键模块:

Public g_lpPreWinProc As Long


Public Function CallbackMsgs(ByVal wHwnd As Long, ByVal wMsg As Long, ByVal wp_id As Long, ByVal lp_id As Long) As Long
    If wMsg = WM_HOTKEY Then
        Call DoFunctions(wp_id)
        CallbackMsgs = 1
        Exit Function
    End If
    CallbackMsgs = CallWindowProc(g_lpPreWinProc, wHwnd, wMsg, wp_id, lp_id)
End Function

Private Sub DoFunctions(ByVal vKeyID As Long)
    On Error GoTo ErrorLine
    If vKeyID = 10000 Then
        HideQQ
        HideQQIcon
    ElseIf vKeyID = 10001 Then
        RestoreQQWindows
        ShowQQIcon
    ElseIf vKeyID = 10002 Then
        KillQQ
        RefreshQQIcon
    ElseIf vKeyID = 10003 Then
        Unload frmMain
    End If
ErrorLine:

End Sub

 

隐藏和恢复QQ窗口相关模块:

Public Sub HideQQIcon()  '隐藏
    Dim dwProcessId As Long, hWnd As Long, hProcess As Long, lpIconText As Long
    Dim i As Integer
    Dim Count As Long
    Dim szIconText As String
    Dim Length As Long
   
    hWnd = FindWindow("Shell_TrayWnd", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "TrayNotifyWnd", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "SysPager", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "ToolbarWindow32", vbNullString)
    If hWnd = 0 Then Exit Sub
   
    GetWindowThreadProcessId hWnd, dwProcessId
    hProcess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, dwProcessId)
   
    If hProcess = 0 Then Exit Sub
   
    lpIconText = VirtualAllocEx(ByVal hProcess, ByVal 0&, 512, MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

    Count = SendMessage(hWnd, TB_BUTTONCOUNT, 0, 0)

    For i = 0 To Count - 1
        szIconText = Space$(256)
        Length = SendMessage(hWnd, TB_GETBUTTONTEXTA, i, ByVal lpIconText)
        ReadProcessMemory hProcess, ByVal lpIconText, ByVal szIconText, Len(szIconText), 0
        If Length <> -1 Then
            szIconText = Left$(szIconText, InStr(1, szIconText, Chr$(0)) - 1)
            If Left(szIconText, 2) = "QQ" Or szIconText = "" Then
                SendMessage hWnd, TB_HIDEBUTTON, i, ByVal True
                SendMessage hWnd, TB_AUTOSIZE, 0, 0
            End If
        End If
    Next
    Call VirtualFreeEx(hProcess, ByVal lpIconText, ByVal 0&, MEM_RELEASE)
    CloseHandle hProcess
End Sub

Public Sub ShowQQIcon()   '显示列表
    Dim dwProcessId As Long, hWnd As Long, hProcess As Long, lpIconText As Long
    Dim i As Integer
    Dim Count As Long
    Dim szIconText As String
    Dim Length As Long
   
    hWnd = FindWindow("Shell_TrayWnd", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "TrayNotifyWnd", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "SysPager", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "ToolbarWindow32", vbNullString)
    If hWnd = 0 Then Exit Sub
   
    GetWindowThreadProcessId hWnd, dwProcessId
    hProcess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, dwProcessId)
   
    If hProcess = 0 Then Exit Sub
   
    lpIconText = VirtualAllocEx(ByVal hProcess, ByVal 0&, 512, MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

    Count = SendMessage(hWnd, TB_BUTTONCOUNT, 0, 0)

    For i = 0 To Count - 1
        szIconText = Space$(256)
        Length = SendMessage(hWnd, TB_GETBUTTONTEXTA, i, ByVal lpIconText)
        ReadProcessMemory hProcess, ByVal lpIconText, ByVal szIconText, Len(szIconText), 0
        If Length <> -1 Then
            szIconText = Left$(szIconText, InStr(1, szIconText, Chr$(0)) - 1)
            If Left(szIconText, 2) = "QQ" Or szIconText = "" Then
                SendMessage hWnd, TB_HIDEBUTTON, i, ByVal False
                SendMessage hWnd, TB_AUTOSIZE, 0, 0
            End If
        End If
    Next
    Call VirtualFreeEx(hProcess, ByVal lpIconText, ByVal 0&, MEM_RELEASE)
    CloseHandle hProcess
End Sub

Public Sub RefreshQQIcon()
    Dim hWnd As Long
    Dim X, Y As Long
    Dim rTrayToolBar As RECT
    Dim pos As Long

    hWnd = FindWindow("Shell_TrayWnd", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "TrayNotifyWnd", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "SysPager", vbNullString)
    If hWnd = 0 Then Exit Sub
    hWnd = FindWindowEx(hWnd, 0, "ToolbarWindow32", vbNullString)
    If hWnd = 0 Then Exit Sub
     
    GetClientRect hWnd, rTrayToolBar
     
    For X = 1 To rTrayToolBar.Right - 1
        For Y = 1 To rTrayToolBar.Bottom - 1
            pos = (X And &HFFFF) + (Y And &HFFFF) * &H10000
            PostMessage hWnd, WM_MOUSEMOVE, 0, pos
        Next Y
    Next X

End Sub

0

阅读 评论 收藏 转载 喜欢 打印举报/Report
  • 评论加载中,请稍候...
发评论

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

      

    新浪BLOG意见反馈留言板 电话:4000520066 提示音后按1键(按当地市话标准计费) 欢迎批评指正

    新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

    新浪公司 版权所有