This article describes the VB realization of the "QQ beauty picking game" cheating device. Share to everyone for your reference. Specifically as follows:
More boring, the principle is very simple, with VB speed is relatively slow, but the implementation is very easy.
Option Explicit Private Type spoint x as Long y as Long end Type Private Declare Function GetDC Lib "user32" (ByVal H Wnd as Long) as Long Private Declare Function getpixel Lib "GDI32" (ByVal hdc as Long, ByVal x as Long, ByVal y as Long) A s Long Private Declare Function setwindowpos Lib "user32" (ByVal hwnd as Long, ByVal hwndinsertafter as Long, ByVal x as L Ong, ByVal y as Long, ByVal CX as Long, ByVal Cy as Long, ByVal wflags as Long) as long Private Const hwnd_topmost& = -1 ' Place the window at the top of the list and at the front of any topmost window private Const swp_nosize& = &h1 ' Keep window size Private Const swp_nomove& = &h2 ' Keep
Window position Private Sub form_load () SetWindowPos Me.hwnd, hwnd_topmost, 0, 0, 0, 0, swp_nomove Or swp_nosize ' Sets the window to always be in the front End Sub
' The RGB value of the Long type is decomposed into 3 component Sub Colorrgb (Color as Long, C () As Integer) const byn As Integer = 256 Const ByN2 as Long = 65536 C (1) = (color mod byn) c (2) = ((color mod ByN2) \ Byn) C (3) = (color \ ByN2) End Sub Private Sub getpoint () Dim p1 (497, 447) As Long, p2 (4447) as Long, C1 (3) As Integer, C2 (3) As Integer ' array size matches the size of the picture Dim Pic1 as Spoint, pic2 as Spoint ' set the screen position of two pictures pic1.x = 8 Pic1.y = pic2.x = 517 Pic2.y = In the Dim h as long, HD as Long, R as Long, I as Integer, J as Intege
R HD = GetDC (0) ' read two pictures for i = 0 to 497 for j = 0 to 447 p1 (i, j) = GetPixel (HD, i + pic1.x, j + pic1.y) P2 (i, j) = GetPixel (HD, i + pic2.x, J + pic2.y) Next Next ' contrast, Mark difference Dim t as Boolean t = True for i = 0 To 497 for j = 0 to 447 call Colorrgb (P1 (i, J), C1 ()) Call Colorrgb (P2 (i, J), C2 ()) If (Abs (C1 (1)-
C2 (1)) > Or abs (C1 (2)-C2 (2)) > Or abs (C1 (3)-C2 (3)) >) Then t = not t If t Then Picture1.forecolor = &H0& Else picture1.forecolor = &HFF00& End If E LSE Picture1.forecolor = P1 (i, j) End If Picture1.pset (i, J) Next Next End Sub Private sub Pict Ure1_click () me.visible= False DoEvents GetPoint me.visible = True End Sub
I hope this article will help you with your VB programming.