QQ game plug-in production tutorial (to touch)

xiaoxiao2021-03-06  91

These days, QQ game plug-in is a scenery. Russian square, connected, the plug-in layer of these games is endless. In fact, the principle of this type of plug is generally the same. Below I will explain the production principle of QQ plug-in as an example with QQ game. Observe the QQ game to touch the game interface and the rules of the game, find that the player is looking for a composite requirements in a fixed game area and then click the two mouse to remove the square to achieve the purpose of score. Therefore, we can use the simulated human observations, and the mouse click to implement the external automatic elimination square, complete the overall situation. Acquired mesencing (simulator observation): To determine which block can be eliminated, we can determine the type of block by getting the color a point, and then establish a block matrix, then select the Suitable in the matrix. About colors, we use several API functions getPixel, getdc, releasedc. (For detailed introduction, please refer to MSDN or various API-related materials) Simulation mouse: We use mouse_event to simulate the mouse movement, click, and bounce. Personally think that it is better to use PostMessage, which is just to expound simply. The following is VB implementation code (with detailed note): 'Module' ************* Module: modmain ***************** ' author: Cyril'Email: terry6394@126.com'Web: http://www.sguca.com/other 'writing date: 2004.10.23' edit date: 2002.10.23 'reproduced Please keep this information' Copyright (a ) CYRIL 405 studio '****************************************************** Option expedition

'API Statement Public Declare Function FindWindow Lib "user32" Alias ​​"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long , ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPrivate Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As LongPrivate Declare Sub mouse_event Lib "user32" ( ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As LongPrivate Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As LongPrivate Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As longprivate declare function g etWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long'API type definition Private Type POINTAPI x As Long y As LongEnd TypePrivate Type RECT Left As Long Top As Long Right As Long Bottom As Longend Type

'Square type definition public enum box_typeox = 0dog = 1panda = 2chicken = 3cat = 4frog = 5Monkey = 6END ENUM

'Custom block data type x, y bit block coordinates, TYPE is a square type.' In Easy, it is also like some other attributes in Easy. For example, whether it is with a channel attribute .Public Type Box X as integer y as integer type As BOX_TYPE End type 'Api constant' mouse event constants Private Const MOUSEEVENTF_LEFTDOWN = & H2 Private Const MOUSEEVENTF_LEFTUP = & H4 Private Const MOUSEEVENTF_MOVE = & H1 Private Const MOUSEEVENTF_ABSOLUTE = & H8000 Public Const HWND_TOPMOST = -1 Public Const SWP_NOSIZE = & H1 Public Const SWP_NOMOVE = & H2 'from defines constants 'upper left corner of the playing field coordinates Const GAME_LEFT As Integer = 176 Const GAME_TOP As Integer = 102' length and width of each block Const BOX_WIDTH As Integer = 48 Const BOX_HEIGHT As Integer = 48 'game window handle Public g_WindowHwnd As Long' block matrix (8 * 8) Public boxs (7, 7) As BOX '********** procedure name: getBoxs ******************' author: Cyril 'Book Date: 2004.10.23' Editor Date: 2002.10.23 'Objective: Get the current scene, establish a square matrix' method: getBoxs 'Application to: mainmod module' ************* ************************************** PUBLIC FUNCTION getBoxs () Dim i as integer 'matrix line DIM J AS INTEGER 'Matrix DIM Color1 AS Long' Color (22, 22) DIM Color2 As Long 'Color (22, 17) FOR i = 0 to 7 for J = 0 to 7 with Boxs (i, j) .x = Game_LEFT 22 Box_Width * J .y = Game_top 22 Box_HEight * i 'Take the color of each block coordinate (22, 12) and (22, 17) position Color color1 = getColor (.x, .y) color2 = getColor .x, .y - 5) 'Determine a block type with two points. if color1 = 16777215 and color2 = 16777215 THEN .TYPE =

Panda If color1 = 2097151 And color2 = 1353909 Then .type = Chicken If color1 = 4473924 And color2 = 14209230 Then .type = Dog If color1 = 13828048 And color2 = 3862322 Then .type = Frog If color1 = 8623264 And color2 = 5805536 Then. TYPE = monkey if color1 = 10921638 and color2 = 9408399 Then .type = cat if color1 = 15398649 and color2 = 1655140 thrype ​​= ox end with next j next = ox end with next j next = ox end with next j next = ox end with next j next = ox end with next j next = ox End with next j next = ox end with next j next = ox ion? In order to facilitate understanding, here is a relatively simple algorithm - Vibridation method. (This is also an algorithm for EASY to touch the original version). 'Its main thinking is to list the possibility of 16 elimination blocks. Once there is a match, the mouse click action is immediately executed. 'If you have to make your plug-in more powerful, you must make a better algorithm.

'********** procedure name: killBox ******************' Author: Cyril 'Writing Date: 2004.10.23' Edit Date: 2002.10. 23 'Purpose: Eliminate a square' method: killbox 'Description: No' return value: no 'Application to: mainmod module' ******************************** ********************** Public Function Killbox () DIM I AS INTEGER DIM J AS Integer getBoxs ':' | situation for i = 0 to 4 for j = 0 To 7 if Boxs (i, j) .Type = Boxs (i 2, j) .Type and Boxs (i, j) .type = Boxs (i 3, j) .Type Then MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i 1, j) .x, boxs (i 1, j) .y exit function end if next j next i '_' | case for i = 0 To 5 for j = 0 to 6 if Boxs (i, j) .type = Boxs (i 2, j 1) .Type and Boxs (i, j) .type = Boxs (i 1, j 1) .TYPE THEN MouseClick Boxs (i, J) .x, Boxs (i, j) .y mouseclick boxs (i, j 1) .x, Boxs (i, j 1) .y exit function end if next j next I '_' | situation for i = 0 TO 5 For j = 1 to 7 if Boxs (i, j) .Type = Boxs (i 2, j - 1) .Type and Boxs (i, j) .type = Boxs (i 1, j - 1) .type THEN MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i, j - 1) .x, Boxs (i, j - 1) .y exit function end if next j next i ' |: Situation for i = 3 to 7 for j = 0 to 7 if Boxs (i, j) .type = Boxs (i - 2, j) .type and boxs (i, j) .type =

Boxs (i - 3, j) .Type Then MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i - 1, j) .x, Boxs (i - 1, j). Y EXIT FUNCTION END IF NEXT J NEXT I '_ | situation for i = 2 to 7 for j = 0 to 6 if Boxs (i, j) .Type = Boxs (i - 1, j 1) .Type and Boxs ( I, j) .Type = Boxs (i - 2, j 1) .Type Then MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i, j 1) .x, Boxs (i, j 1) .y exit function end if next j next i '| _ case for i = 2 to 7 for j = 1 to 7 if Boxs (i, j) .type = Boxs (i - 1, J - 1) .Type and Boxs (i, j) .Type = Boxs (i - 2, j - 1) .Type Then MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs I, J - 1) .x, Boxs (i, j - 1) .y exit function end if next j next i '_ - situation for i = 1 to 7 for j = 0 to 5 if Boxs (i, j ) .type = Boxs (i - 1, j 2) .Type and Boxs (i, j) .type = Boxs (i - 1, j 1) .Type the mouseclick boxs (i, j) .x, Boxs (i, J MouseClick Boxs (i - 1, j) .x, Boxs (i - 1, j) .y exit function end if next j next i '-_ _ case for i = 0 to 6 for j = 0 TO 5 if Boxs (i, j) .Type = Boxs (i 1, j 2) .Type and Boxs (i, j) .type = Boxs (i 1, j 1) .type kilick boxs (i , J) .x, Boxs (i, j) .y mouseclick boxs (i 1, j) .x, boxs (i

1, j) .y exit function end i '-_- situation for i = 1 to 7 for j = 1 to 6 if Boxs (i, j) .Type = Boxs (i - 1, j - 1 ) .Type and Boxs (i, j) .Type = Boxs (i - 1, j 1) .TYPE THEN MOUSECLICK Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i - 1 , J) .x, Boxs (i - 1, j) .y exit function end if next j next i '_-_ case for i = 0 to 6 for j = 1 to 6 if Boxs (i, j) .type = Boxs (i 1, j - 1) .Type and Boxs (i, j) .Type = Boxs (i 1, j 1) .type dam t m mcClick Boxs (i, j) .x, Boxs (i, J MouseClick Boxs (i 1, j) .x, Boxs (i 1, j) .y exit function end if next j next i '| | Situation for i = 1 to 6 for j = 0 to 6 if Boxs (i, j) .Type = Boxs (i 1, j 1) .Type and Boxs (i, j) .type = Boxs (i - 1, J 1) .TYPE THEN MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i, j 1) .x, Boxs (i, j 1) .y exit Function end if next j next i '--_ case for i = 1 to 7 for j =

2 to 7 if Boxs (i, j) .Type = Boxs (i - 1, j - 2) .Type and Boxs (i, j) .type = Boxs (i - 1, j - 1) .type the mouseclick boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i - 1, j) .x, boxs (i - 1, j) .y exit function end if next j next i '- Situation for i = 0 to 7 for j = 3 to 7 if Boxs (i, j) .Type = Boxs (i, j - 2) .Type and Boxs (i, j) .type = Boxs (i, j - 3 ) .Type Then MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i, j - 1) .x, Boxs (i, j - 1) .y exit function end if next j Next I '_ _ situation for i = 0 to 6 for j = 2 to 7 if Boxs (i, j) .Type = Boxs (i 1, j - 2) .Type and Boxs (i, j) .type = Boxs (i 1, j - 1) .Type Then MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i 1, j) .x, Boxs (i 1, j) .y exit function end if n EXT J NEXT I '- - Sample for i = 0 to 7 for J = 0 to 4 if Boxs (i, j) .Type = Boxs (i, J 2) .Type and Boxs (i, j) .type = Boxs (i, j 3) .TYPE THEN MouseClick Boxs (i, j) .x, Boxs (i, j) .y mouseclick boxs (i, j 1) .x, Boxs (i, j 1) The mouse simulation here uses the mouse event. You can also be implemented in SendMessage.

'********** procedure name: mouseClick ******************' Author: Cyril 'Writing Date: 2004.10.23' Edit Date: 2002.10. 23 'Purpose: Simulation Mouse Click' Method: MouseClick (Byval X as long, byval y as long "Description: x - squares relative to the X; Y - square relative to the Y; 'return value of the game window: No 'Application to: mainmod module' **************************************************** ** Public Sub Mouseclick (BYVAL X As Long, Byval Y As Long) Dim Po As Pointapi 'Po Click on the Mouse Location DIM KX As Long' Square Absolute Y Coordinate DIM KY AS LONG 'Solver DIM WinRect As Rect 'Game window Rect' gets the rect getWindowRect g_windowhwnd of the game window, WinRect 'absolute coordinate = the relative coordinate of the game window the relative coordinate of the game in the game KX = WinRect.Left x ky = WinRect.top Y' Get the mouse click front position GetCursorPos po 'simulated mouse movement mouse_event MOUSEEVENTF_MOVE Or MOUSEEVENTF_ABSOLUTE, kX * 65535/1024, kY * 65535/768, 0 &, 0 &' simulated mouse down pop mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_ABSOLUTE, 0, 0, 0 &, 0 & 'click- Return to the original location setCursorpos PO.x, Po.yend Sub '********** procedure name: getColor ******************' Author: Cyril 'Writing Date: 2004.10.23' Edit Date: 2002.10 .23 'Purpose: Take a point in the game' method: getColor (Byval newx as long, byval newxi as long) Description: NewX - Take the color of the color of the pod; Newy - point to colors Y; (x, y is relative to the game window) 'Return value: long' Application to: mainmod module '************************ *************************** PUBLIC FUNCTION GETCOLOR (BYVAL NEWX As Long, BYVAL NEWY As Long AS Long Dim Windowdc As long "Get game scene WindowDC = GetDC (g_windowhwnd) ' Take the scene (newx, newy) Coordinate color getColor = getpixel (windowdc, newx, newy) release scene (do not miss this)

ReleaseDC g_windowhwnd, windowdcend function '==== in the form ======== in the form ======== in the form === Option expedition' ###### ######################################################################################################################################################################################################################################################################################################## ########## ## Process Name: command5_click '## Parameters: No' ####################################################################################################################################################################################################################################################################### #################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@Ptervidator? Command6.enabled command5.enabled = not command5.Enabled Timer1.enabled = truend subrship ################################################################################################################################################################################################################################################################# ################################## '## process name: Command6_Click' ## parameters: None '## ######################################################################################################################################################################################################################################################################################################## ############## Private submmand6_click () Timer1.enabled = false command6.enabled = not command6.enabled command5.enabled = not command5.enabledend subrship =@########## ######################################################################################################################################################################################################################################################################################################## ######## ## Process Name: form_load '## Parameters: No' ######################################################################################################################################################################################################################################################################## ######################################################################################################## To the pair ") 'window always setwindowpos me.hwnd, hw ND_topmost, 0, 0, 0, 0, swp_nomove or swp_nosizeend sub '############################################################################################################################################################################################################################################################## ########################## process name: label2_click '## Parameters: No' ##### ######################################################################################################################################################################################################################################################################################################## ########### private sub Label2_click () end sub '############################################################################################################################################################################################################################################################### #####################################################################################################################################################################################################################################################################################

转载请注明原文地址:https://www.9cbs.com/read-102147.html

New Post(0)