Delphi write QQ message sending group (simulate the push key genie)

Source: Internet
Author: User

This article is for study purposes only and cannot be used for illegal purposes. repost this article.

Address: http://blog.csdn.net/sushengmiyan/article/details/8774780

Function used: enumwindows and enumwindowsproc

Source code:

Unit execution; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, clipbrd; Type tform1 = Class (tform) edtmsg: tedit; lbltip: tlabel; btntry: tbutton; lblmsgwindow: tlabel; labels: tlabel; Procedure btntryclick (Sender: tobject); Private {private Declarations} public {public declarations} end; var form1: tform1; function enumwindowsproc (hwnd: hwnd; lparam: lparam): Boolean; stdcall; implementation {$ R *. DFM} procedure tform1.btntryclick (Sender: tobject); begin if trim (edtmsg. text) = ''then begin showmessage ('Enter the message to be sent, the message cannot be blank '); End else begin enumwindows (@ enumwindowsproc, 0); end; function enumwindowsproc (hwnd: hwnd; lparam: lparam): Boolean; stdcall; var windowtext: string; windowclass: string; sendhwnd: DWORD; tdiahandle: thandle; tedithandle: thandle; role: thandle; C: Cardinal; processhandle: longword; begin if (iswindowvisible (hwnd) or isiconic (hwnd) and (getwindowlong (hwnd, gwl_hwndparent) = 0) or (getwindowlong (hwnd, rows) = longint (getdesktopwindow) and (getwindowlong (hwnd, gwl_exstyle) and ws_ex_toolwindow = 0) then begin setlength (windowtext, getwindowtextlength (hwnd) + 2); getwindowtext (hwnd, pchar (windowtext), getwindowtextlength (hwnd) + 2); windowtext: = string (pchar (windowtext); setlength (windowclass, 512 ); getclassname (hwnd, pchar (windowclass), 512); windowclass: = string (pchar (windowclass); If samestr (windowclass, 'txguifounder') then begin bringwindowtotop (hwnd ); form1.lblmsgcontextwindow. caption: = windowtext; If clipboard. hasformat (cf_text) Then clipboard. clear; form1.edtmsg. selectall; form1.edtmsg. copytoclipboard; keybd_event (vk_control, mapvirtualkey (vk_control, 0), 0, 0); keybd_event (ord ('V'), mapvirtualkey (ord ('V'), 0 ), 0, 0); keybd_event (ord ('V'), mapvirtualkey (ord ('V'), 0), keyeventf_keyup, 0); keybd_event (vk_control, mapvirtualkey (vk_control, 0), keyeventf_keyup, 0); keybd_event (vk_return, mapvirtualkey (vk_return, 0), 0, 0); end; Result: = true; end.

We often have this kind of requirement in the network. It is very troublesome to send a sales promotion content to the QQ group or QQ friends and send it one by one manually, so we need a set of good tools to help us, so I wrote this stuff. We have a lot of support.

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.