View Single Post
  #1  
Old 02-03-2009, 01:43 AM
Nunk's Avatar
Nunk Nunk is offline
Ezudian
 
Join Date: Jul 2008
Location: Wilderness
Posts: 385
Reputation: 345
Nunk is a jewel in the roughNunk is a jewel in the roughNunk is a jewel in the roughNunk is a jewel in the rough
[function] Check for gas

This code i used at my ProMiners and it works very well. It check for gas under mouse. Btw... Those random updates.. did they remove gas?? If they did this is pretty useles..

simple example of use
Code:
Sub MyMiningThing()
Do Until Stop=True
MoveToRock
If Not GasFound Then LeftClick
Wait 2000,4000
Loop
End Sub
The function (you have to get all other things you need by yourself :))
Code:
Private Function GasFound(Percents As Integer)
Dim PixelChange As Integer, Xnow As Integer, Ynow As Integer, startX As Integer, startY As Integer
Dim RShdc As Long, x As Long, y As Long, Pixs(0 To 24, 0 To 25) As String
Dim PaintDebug As Integer, PixCount As Integer

PaintDebug = 1
RShdc = GetDC(selWnd)

startX = getx - 12
startY = GetY - 25

Xnow = 0
For x = startX To startX + 24
    Ynow = 0
        For y = startY To startY + 25
            Pixs(Xnow, Ynow) = GetPixel(RShdc, x, y)
            'If PaintDebug Then
             '   If Xnow = 0 Then SetPixel RShdc, x - 1, y, 9090
              '  If Ynow = 0 Then SetPixel RShdc, x, y - 1, 9090
               ' If x = startX + 18 Then SetPixel RShdc, x + 1, y, 9090
                'If y = startY + 18 Then SetPixel RShdc, x, y + 1, 9090
            'End If
            PixCount = PixCount + 1
            Ynow = Ynow + 1
        Next y
    Xnow = Xnow + 1
Next x
'Text1.Text = "PixCount " & PixCount & vbCrLf & Text1.Text

WaitMS Rand(30, 100)

Xnow = 0
Ynow = 0

For x = startX To startX + 24
    Ynow = 0
        For y = startY To startY + 25
            If Not GetPixel(RShdc, x, y) = Pixs(Xnow, Ynow) Then PixelChange = PixelChange + 1
            Ynow = Ynow + 1
        Next y
    Xnow = Xnow + 1
Next x
'Text1.Text = "PixelChange " & PixelChange & vbCrLf & Text1.Text

If Not PixelChange = 0 Then
AddToLog "PixelChange: " & Round(((PixelChange / PixCount)) * 100, 1) & "%"
'Text1.Text = "PixelChange " & (Int((PixelChange / PixCount) * 100)) & "%" & vbCrLf & Text1.Text
If Round(((PixelChange / PixCount) * 100), 0) >= Percents Then
GasFound = True
AddToLog "Possible Gas!"
mmouse2 627, 85
If Rand(1, 2) = 1 Then mmouse2 627, 85
WaitMS Rand(20, 150)
LClick
End If
End If
ReleaseDC selWnd, RShdc
End Function
Code:
Public Function GetY()
Dim wndRect As RECT
Dim mousexy As POINTAPI
GetWindowRect selWnd, wndRect
GetCursorPos mousexy
GetY = (mousexy.y - wndRect.Top)
End Function

Public Function GetX()
Dim wndRect As RECT
Dim mousexy As POINTAPI
GetWindowRect selWnd, wndRect
GetCursorPos mousexy
GetX = (mousexy.x - wndRect.Top)
End Function
Reply With Quote