C # take QQ session record

Source: Internet
Author: User

Many people should know that QQ's child window handle is not available in the Winuser library function can be obtained,

because there is no nativehandle it is the logical control of painting Directui, WPF, but Directui

and not as WPF pure DirectX rendering frame, but the two concepts are equal, the control is only logically not true

the positive meaning of the existence in the control, since there is no way to get its content, very simple Microsoft provides two sets of different

class Library, C + + main application Microsoft Active Accessibility  /  MSAA You don't think it's a game.

MSAA/antialiasing, you can also use the UI Automation /UI Automation, C # primarily uses UIA, but

. NET , if a native UIAutomationCore.dll is needed in the. NET upper -level com wrapper

class Library is,interop.uiautomationclient , but the meaning of the two is not big, . NET upper wrapper class library just

the performance is not as fast as the native, you choose that . all the same, if you're interested, you can check it out. Windows Automation API

Above is just a running result, the software has been successfully obtained to chat record

Speed is not fast, add project references first

UIAutomationClient.dll and UIAutomationTypes.dll two bullets,

OK to confirm the reference and then add the namespace reference,

    Using System;    Using System.Text;    Using System.Windows.Automation;    Using System.Runtime.InteropServices;    Using System.Collections.Generic;    Using System.Windows.Forms;

First, we need to declare the win32native functions and constants that we need to use.

Public abstract partial class win32native{[DllImport ("User32.dll")] [Return:marshalas (Unmanagedtype.bool)] Priv    Ate static extern bool EnumWindows (lpenumwindowsproc lpenumfunc, int lParam);    [DllImport ("user32.dll", CharSet = CharSet.Ansi)] [Return:marshalas (Unmanagedtype.bool)] private static extern Bool getclassname (int hWnd, StringBuilder buf, int Nmaxco    UNT);    [DllImport ("user32.dll", CharSet = CharSet.Auto, SetLastError = True)] [Return:marshalas (Unmanagedtype.bool)] private static extern Bool GetWindowText (int hWnd, StringBuilder lpstring, int    nMaxCount); [DllImport ("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] private static extern int Getwindowtextlength (in    T hWnd);    [DllImport ("User32.dll")]    [Return:marshalas (Unmanagedtype.bool)] public static extern Bool IsWindow (IntPtr hWnd);    Private delegate bool Lpenumwindowsproc (int hwnd, int lParam);    public const int NULL = 0; Private Const int maxbyte = 255;}

Below we write a scan on the desktop how many QQ top-level windows code,

we're not going to scan the merged window. you just need to scan the top-level window.

public abstract partial class win32native{private static volatile list<int> hWnd    Collect;        private static bool Scansessionwindow (int hwnd, int lParam) {StringBuilder buf = new StringBuilder (maxbyte); if (GetClassName (hwnd, BUF, Maxbyte) && buf. ToString () = = "Txguifoundation") if (Getwindowtextlength (HWND) > 0 && GetWindowText (hwnd, BUF, Maxby TE)) {string str = buf.                ToString (); if (str! = "Txmenuwindow" && str! = "QQ" && str = "Increase duration") {Console.wri                    Teline ("\ T" + (Hwndcollect.count + 1) + ":" + str);                Hwndcollect.add (HWND);    }} return true;        } public static int[] Getsessionwindow () {hwndcollect = new list<int> ();        EnumWindows (Scansessionwindow, NULL);    return Hwndcollect.toarray (); }}

I've added a couple of conditions up there that have been removed and may be enumerated

But to our meaningless window,

Getsessionwindow/Fetch Session window

Sansessionwindow/Scan Session window

public static partial class program{    private static void Findusermessage (INTPTR hwnd)    {        if (! Win32native.iswindow (HWND))            Console.WriteLine ("QQ Session window has been closed.");        else        {            automationelement element = Automationelement.fromhandle (hwnd);            element = element. FindFirst (treescope.descendants, New PropertyCondition (Automationelement.nameproperty, "message"));            if (element! = null && element. current.isenabled)            {                ValuePattern Vptextedit = element. Getcurrentpattern (Valuepattern.pattern) as ValuePattern;                if (vptextedit! = null)                {                    string value = VpTextEdit.Current.Value;                    Console.WriteLine (value);                    MessageBox.Show (value);}}}}    

Findusermessage/Find User messages

in the above we see first do a check whether the window handle is valid if valid in the following

Created a automationelement/Automation member object, if we need to

Search and return a single member, then we only need to use FindFirst if we need to

Search and return all members, then we just need to use FindAll, we're on top

Use only one name attribute condition PropertyCondition (automationelement.nameproperty, "message")

Why the news, then let's take a closer look

Well, you should find out now why it's "news" and not the other, right?

public static partial class program{    [STAThread]    private static void Main (string[] args)    {        Console.title = string. Empty;        Console.WriteLine ("Scan the QQ User's session window.");        int[] hwndofsession = Win32native.getsessionwindow ();        if (hwndofsession.length <= 0)            Console.WriteLine ("No Scan to any available QQ message window.");        else        {            Console.WriteLine ("Look for the session record interface.");            foreach (int hwnd in hwndofsession)                findusermessage ((INTPTR) HWND);        }        Console.WriteLine ("Thank you for using, QQ conversations has been scanned.");        Console.readkey (false);}    }

The code above is about stitching together a couple of functions to accomplish what we need to do. first get on the desktop there

How many QQ draw the word handle, and then iterate to find the user message, in fact, if it can be placed in the

start scanning on the computer. Send to your own mailbox or update to the server will be a good

Play of the things, but the premise that you must be able to get it to someone else's computer, a little joke .

Want to catch husband cheating evidence rich, hehe, mobile version may be able to save her,

Source code: Http://pan.baidu.com/s/1kTBxOdL

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

C # take QQ session record

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.