-
Oct 15th, 2020, 12:14 AM
#1
Thread Starter
New Member
Help with an error in a simple mouse simulation script
Hey guys I have written a pretty simple piece of code in visual basic 6.0 to simulate mouse clicks in a game I play, It seems to run perfectly fine up until the program has been running for a certain time (Roughly 2 hours I had to record it as it has happened multiple times at about 2 hours in)
I can't seem to figure out why the labels and counter disappear from the program and the timers and program stop running (I have attached a couple of images below of what happens)
Here is the code below any help would be much appreciated thank you.
Code:
Option Explicit
Private 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 Long
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Public Sub Wait(Optional ms As Long = 2000)
On Error Resume Next
Dim tc As Long
tc = GetTickCount
While GetTickCount < tc + ms: Sleep 1: DoEvents: Wend
End Sub
Public Function RandomNumber(ByVal MinValue As Long, Optional _
ByVal MaxValue As Long = 0)
On Error Resume Next
Randomize Timer
RandomNumber = Int((MaxValue - MinValue + 1) * Rnd) + MinValue
End Function
Public Sub KeyDown(KCC As KeyCodeConstants)
keybd_event KCC, 0, 0, 0
End Sub
Public Sub KeyUp(KCC As KeyCodeConstants)
keybd_event KCC, 0, KEYEVENTF_KEYUP, 0
End Sub
Private Sub cmd_Start_Click()
If cmd_Start.Caption = "Start" Then
cmd_Start.Caption = "Stop"
initializeTrainer
Else
End
End If
End Sub
Public Function initializeTrainer()
If GetPixel(GetWindowDC(0), 822, 480) = "4746367" Then 'Tree is spawned
Call SetCursorPos(RandomNumber(750, 850), RandomNumber(420, 570)) ' Click tree
lbl_Status.Caption = "Cutting"
Timer2.Enabled = False
lbl_Timeout.Caption = "0"
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
Wait (1600)
Timer1.Enabled = True
Else
If lbl_Timeout.Caption = "20" Then
cmd_Start.Caption = "Error"
lbl_Status.Caption = "Error"
Beep 500, 5000
Else
lbl_Status.Caption = "Idle..."
Timer2.Enabled = True
Wait (600)
Call initializeTrainer
End If
End If
End Function
Private Sub Timer1_Timer()
If GetPixel(GetWindowDC(0), 100, 55) = "0" Then
lbl_Status.Caption = "Not cutting"
Timer1.Enabled = False
lbl_Status.Caption = "Clearing inventory..."
Call clearInventory
End If
End Sub
Public Function clearInventory()
KeyDown vbKeyShift
If GetPixel(GetWindowDC(0), 808, 717) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(713, 728))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 850, 717) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(713, 728))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 892, 717) = "4617881" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(713, 728))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 934, 717) = "4617881" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(713, 728))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 808, 753) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(750, 765))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 850, 753) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(750, 765))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 892, 753) = "4617881" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(750, 765))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 934, 753) = "4617881" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(750, 765))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 808, 789) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(784, 799))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 850, 789) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(784, 799))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 892, 789) = "4617881" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(784, 799))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 934, 789) = "4617881" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(784, 799))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 808, 825) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(822, 833))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 850, 825) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(822, 833))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 892, 825) = "4617881" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(822, 833))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 934, 825) = "4617881" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(822, 833))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 808, 861) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(858, 871))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 850, 861) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(858, 871))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 892, 861) = "4617881" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(858, 871))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 934, 861) = "4617881" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(858, 871))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 808, 896) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(894, 907))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 850, 896) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(894, 907))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 892, 896) = "4617881" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(894, 907))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 934, 896) = "4617881" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(894, 907))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 808, 933) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(929, 940))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 850, 933) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(929, 940))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 892, 933) = "4617881" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(929, 940))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(GetWindowDC(0), 934, 933) = "4617881" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(929, 940))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
Wait (300)
KeyUp vbKeyShift
Call initializeTrainer
End Function
Private Sub Form_Load()
Call SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Private Sub Timer2_Timer()
lbl_Timeout.Caption = lbl_Timeout.Caption + 1
End Sub
Last edited by Shaggy Hiker; Oct 18th, 2020 at 09:03 AM.
Reason: Added CODE tags.
-
Oct 15th, 2020, 08:41 AM
#2
Re: Help with an error in a simple mouse simulation script
You call GetWindowDC(0) repeatedly and you never call ReleaseDC ever.
So, eventually you have used up every DC available from the pool provided by Windows, so programs can't get DCs when they need them, and your windows GUI environment begins to fail.
You shouldn't be calling GetWindowDC(0) repeatedly in a sub anyway.
You should call it once at the beginning of the sub where you need it, storing it in a variable, and use that variable as many times you need to reference the DC. At the end of the sub, call ReleaseDC to return the DC you used back to the pool.
Originally Posted by GetWindowDC documentation
After painting is complete, the ReleaseDC function must be called to release the device context. Not releasing the window device context has serious effects on painting requested by applications.
Originally Posted by ReleaseDC documentation
The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common DC.
Last edited by passel; Oct 15th, 2020 at 08:58 AM.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Oct 16th, 2020, 03:16 AM
#3
Thread Starter
New Member
Re: Help with an error in a simple mouse simulation script
Cheers for your reply man, I'm not sure if i'm able to reduce the amount of times it is called as it needs to check the pixel to see if there is an item in the slot. I did a bit of research and put it in the code and ran it and it got a little bit further but still did the same thing (GUI crashed) have I put this in correctly? Thank you.
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
If GetPixel(GetWindowDC(0), 715, 465) = "7258534" Then 'Tree is spawned
Call ReleaseDC(0, 0)
-
Oct 16th, 2020, 06:52 AM
#4
Re: Help with an error in a simple mouse simulation script
What he was saying is that you should call GetWindowDC() once at the top and assign it to a var then use that var in all your GetPixel() calls that follow rather than repeatign calling the GetWindowDC().
-
Oct 17th, 2020, 04:22 PM
#5
Re: Help with an error in a simple mouse simulation script
Code:
Dim screenDC As Long
screenDC = GetWindowDC(0)
If GetPixel(screenDC, 808, 717) = "4617881" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(713, 728))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
If GetPixel(screenDC, 850, 717) = "4617881" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(713, 728))
Wait (RandomNumber(260, 360))
Mouse_Click (vLeftclick)
lbl_Counter.Caption = lbl_Counter.Caption + 1
End If
'...
ReleaseDC 0, screenDC
Since you passed the value returned by the GetWindowDC as a parameter to GetPixel, you didn't save the value so had no way to return it.
You have to save the value so you can return it,
Since you have to return the DC given to you, "Call ReleaseDC(0, 0)" isn't doing any good as you wouldn't have been given an hDC equal to 0.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Oct 18th, 2020, 12:38 PM
#6
Re: Help with an error in a simple mouse simulation script
The more I thought about this, the more I realized I had to ask: Why???
Clearly, this is intended to automate some kind of harvesting in a game. If the game allows that, then it's fine with us. If it doesn't then this will be a temporary thing, at best. So....what is the point of automating? It's a game. If you find it boring, don't play it. If you don't find it boring, then why automate it? If you can make real world money by automating it, then that would certainly be interesting, but also kind of...weird. Maybe that's just me. The thought of paying real money so that you can gain some kind of advantage in an electronic game just seems bizarre, to me.
So, why are YOU doing it? Do you find that part boring? Does it make money?
My usual boring signature: Nothing
-
Oct 18th, 2020, 11:29 PM
#7
Thread Starter
New Member
Re: Help with an error in a simple mouse simulation script
I love playing the game, I just run it while i'm asleep and no it doesn't make any money haha.
Cheers for your replies I managed to fix the issue but am now having another issue here below after a few hours of runtime :\
Code:
Option Explicit
Private 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 Long
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Public Sub wait(Optional ms As Long = 2000)
On Error Resume Next
Dim tc As Long
tc = GetTickCount
While GetTickCount < tc + ms: Sleep 1: DoEvents: Wend
End Sub
Public Function RandomNumber(ByVal MinValue As Long, Optional _
ByVal MaxValue As Long = 0)
On Error Resume Next
Randomize Timer
RandomNumber = Int((MaxValue - MinValue + 1) * Rnd) + MinValue
End Function
Public Sub KeyDown(KCC As KeyCodeConstants)
keybd_event KCC, 0, 0, 0
End Sub
Public Sub KeyUp(KCC As KeyCodeConstants)
keybd_event KCC, 0, KEYEVENTF_KEYUP, 0
End Sub
Private Sub cmd_Start_Click()
If cmd_Start.Caption = "Start" Then
cmd_Start.Caption = "Stop"
initializeTrainer
Else
End
End If
End Sub
Public Function initializeTrainer()
Dim scrHwnd As Long
scrHwnd = GetDesktopWindow
Dim shDC As Long
shDC = GetDC(scrHwnd)
Timer_Logout.Enabled = True
lbl_Status.Caption = "Mining..."
If Not GetPixel(shDC, 44, 157) = "0" Then
Call SetCursorPos(RandomNumber(310, 360), RandomNumber(490, 550)) ' 1st ore
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(2200, 2400))
End If
If Not GetPixel(shDC, 44, 157) = "0" Then
Call SetCursorPos(RandomNumber(500, 580), RandomNumber(715, 775)) ' 2nd ore
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(2000, 2200))
End If
If Not GetPixel(shDC, 44, 157) = "0" Then
Call SetCursorPos(RandomNumber(710, 780), RandomNumber(500, 600)) ' 3rd ore
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(1900, 2100))
ReleaseDC scrHwnd, shDC
Call clearInventory
End If
End Function
Public Function clearInventory()
lbl_Status.Caption = "Clearing..."
KeyDown vbKeyShift
Dim scrHwnd As Long
scrHwnd = GetDesktopWindow
Dim shDC As Long
shDC = GetDC(scrHwnd)
If Not GetPixel(shDC, 44, 157) = "0" Then
If Not GetPixel(shDC, 820, 720) = "2700606" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(713, 728)) '1
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(220, 360))
End If '
End If
If Not GetPixel(shDC, 44, 157) = "0" Then
If Not GetPixel(shDC, 862, 721) = "2700606" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(713, 728)) '2
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(220, 360))
End If
End If
If Not GetPixel(shDC, 44, 157) = "0" Then
If Not GetPixel(shDC, 904, 719) = "2700606" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(713, 728)) '3
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(220, 360))
End If
End If
If Not GetPixel(shDC, 44, 157) = "0" Then
If Not GetPixel(shDC, 945, 721) = "2700606" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(713, 728)) '4
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(220, 360))
End If
End If
If Not GetPixel(shDC, 44, 157) = "0" Then
If Not GetPixel(shDC, 818, 757) = "2700606" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(750, 765)) '5
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(220, 360))
End If
End If
If Not GetPixel(shDC, 44, 157) = "0" Then
If Not GetPixel(shDC, 862, 756) = "2700606" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(750, 765)) '6
wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
wait (RandomNumber(220, 360))
End If
End If
KeyUp vbKeyShift
ReleaseDC scrHwnd, shDC
Call initializeTrainer
End Function
Private Sub Timer_Logout_Timer()
Dim scrHwnd As Long
scrHwnd = GetDesktopWindow
Dim shDC As Long
shDC = GetDC(scrHwnd)
If GetPixel(shDC, 513, 270) = "65535" Then
Timer_Logout.Enabled = False
KeyUp vbKeyShift
lbl_Status.Caption = "Relogging..."
ReleaseDC scrHwnd, shDC
Call SetCursorPos(RandomNumber(570, 590), RandomNumber(310, 320)) ' Existing user
wait (RandomNumber(170, 320))
Mouse_Click (vLeftclick)
wait (1000)
KeyDown vbKey7
KeyUp vbKey7
wait (RandomNumber(170, 320))
KeyDown vbKey9
KeyUp vbKey9
wait (RandomNumber(170, 320))
KeyDown vbKey8
KeyUp vbKey8
wait (RandomNumber(170, 320))
KeyDown vbKey9
KeyUp vbKey9
wait (RandomNumber(170, 320))
KeyDown vbKey5
KeyUp vbKey5
wait (1000)
Call SetCursorPos(RandomNumber(400, 440), RandomNumber(340, 350)) ' Log in
wait (RandomNumber(170, 320))
Mouse_Click (vLeftclick)
wait (RandomNumber(19000, 21000))
Call SetCursorPos(RandomNumber(470, 550), RandomNumber(340, 380)) ' Play
wait (RandomNumber(170, 320))
Mouse_Click (vLeftclick)
wait (RandomNumber(2000, 3000))
Call clearInventory
End If
End Sub
Private Sub Form_Load()
Call SetWindowPos(Form1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Attachment 179070
Attachment 179071
Last edited by Shaggy Hiker; Oct 19th, 2020 at 08:17 AM.
-
Oct 19th, 2020, 08:18 AM
#8
Re: Help with an error in a simple mouse simulation script
When you post code, please wrap it in tags. I prefer the [CODE][/CODE] tags, which you get with the # button, but some prefer the Highlight tags you get with the VB button.
My usual boring signature: Nothing
-
Oct 19th, 2020, 09:43 AM
#9
Re: Help with an error in a simple mouse simulation script
Originally Posted by eqwlyz
I love playing the game, I just run it while i'm asleep and no it doesn't make any money haha.
Cheers for your replies I managed to fix the issue but am now having another issue here below after a few hours of runtime :\
You still have code where you are calling GetDC but may not be calling ReleaseDC.
1) initializeTrainer
2) Timer_Logout_Timer
In both of those routines, your ReleaseDC call is inside an IF structure. If the code within that IF structure is not triggered because IF statement's condition returns false, then the ReleaseDC call is not executed.
Re-look at those two routines. Use indentation in your source code to help visually find these types of logic errors.
-
Oct 26th, 2020, 09:38 PM
#10
Thread Starter
New Member
Re: Help with an error in a simple mouse simulation script
Hey guys I am still getting the same error after a few hours of runtime i'm pretty sure i've done everything you guys have said here,
Code:
Option Explicit
Private 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 Long
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Public Sub Wait(Optional ms As Long = 2000)
On Error Resume Next
Dim tc As Long
tc = GetTickCount
While GetTickCount < tc + ms: Sleep 1: DoEvents: Wend
End Sub
Public Function RandomNumber(ByVal MinValue As Long, Optional _
ByVal MaxValue As Long = 0)
On Error Resume Next
Randomize Timer
RandomNumber = Int((MaxValue - MinValue + 1) * Rnd) + MinValue
End Function
Public Sub KeyDown(KCC As KeyCodeConstants)
keybd_event KCC, 0, 0, 0
End Sub
Public Sub KeyUp(KCC As KeyCodeConstants)
keybd_event KCC, 0, KEYEVENTF_KEYUP, 0
End Sub
Private Sub cmd_Start_Click()
If cmd_Start.Caption = "Start" Then
cmd_Start.Caption = "Stop"
Timer_Logout.Enabled = True
initializeTrainer
Else
End
End If
End Sub
Public Function initializeTrainer()
lbl_Status.Caption = "Mining..."
Call SetCursorPos(RandomNumber(310, 360), RandomNumber(490, 550)) ' 1st ore
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(2000, 2220))
Call SetCursorPos(RandomNumber(500, 580), RandomNumber(715, 775)) ' 2nd ore
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(1800, 2020))
Call SetCursorPos(RandomNumber(710, 780), RandomNumber(500, 600)) ' 3rd ore
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(1800, 1920))
Call clearInventory
End Function
Public Function clearInventory()
Dim scrHwnd As Long
scrHwnd = GetDesktopWindow
Dim shDC As Long
shDC = GetDC(scrHwnd)
lbl_Status.Caption = "Clearing..."
KeyDown vbKeyShift
If Not GetPixel(shDC, 820, 720) = "2700606" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(713, 728)) '1
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(180, 460))
End If
If Not GetPixel(shDC, 862, 721) = "2700606" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(713, 728)) '2
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(180, 460))
End If
If Not GetPixel(shDC, 904, 719) = "2700606" Then
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(713, 728)) '3
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(180, 460))
End If
If Not GetPixel(shDC, 945, 721) = "2700606" Then
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(713, 728)) '4
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(180, 460))
End If
If Not GetPixel(shDC, 818, 757) = "2700606" Then
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(750, 765)) '5
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(180, 460))
End If
If Not GetPixel(shDC, 862, 756) = "2700606" Then
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(750, 765)) '6
Wait (RandomNumber(80, 120))
Mouse_Click (vLeftclick)
Wait (RandomNumber(180, 360))
End If
KeyUp vbKeyShift
ReleaseDC scrHwnd, shDC
Wait (300)
If lbl_Elapsed.Caption = "240" Then
Timer_Logout.Enabled = False
lbl_Elapsed.Caption = "0"
lbl_Status.Caption = "Rebooting..."
lbl_Reboots.Caption = lbl_Reboots.Caption + 1
Call SetCursorPos(RandomNumber(876, 888), RandomNumber(970, 982)) ' Log out
Wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
Wait (RandomNumber(1200, 1300))
Call SetCursorPos(RandomNumber(855, 909), RandomNumber(915, 930)) ' Log out
Wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
Wait (RandomNumber(600000, 900000))
Call SetCursorPos(RandomNumber(558, 608), RandomNumber(300, 330)) ' Existing user
Wait (RandomNumber(120, 180))
Mouse_Click (vLeftclick)
Wait (RandomNumber(1200, 1300))
KeyDown vbKey7
Wait (RandomNumber(120, 180))
KeyUp vbKey7
Wait (RandomNumber(120, 180))
KeyDown vbKey9
Wait (RandomNumber(120, 180))
KeyUp vbKey9
Wait (RandomNumber(120, 180))
KeyDown vbKey8
Wait (RandomNumber(120, 180))
KeyUp vbKey8
Wait (RandomNumber(120, 180))
KeyDown vbKey9
Wait (RandomNumber(120, 180))
KeyUp vbKey9
Wait (RandomNumber(120, 180))
KeyDown vbKey5
Wait (RandomNumber(120, 180))
KeyUp vbKey5
Wait (RandomNumber(120, 180))
KeyDown vbKey7
Wait (RandomNumber(120, 180))
KeyUp vbKey7
Wait (RandomNumber(120, 180))
KeyDown vbKey8
Wait (RandomNumber(120, 180))
KeyUp vbKey8
Wait (RandomNumber(120, 180))
KeyDown vbKeyReturn
Wait (RandomNumber(120, 180))
KeyUp vbKeyReturn
Wait (30000)
Call SetCursorPos(RandomNumber(470, 550), RandomNumber(340, 380)) ' Play
Wait (RandomNumber(120, 180))
cmd_Start.Caption = "Stop"
Mouse_Click (vLeftclick)
Wait (RandomNumber(2000, 2100))
Call initializeTrainer
Else
Call initializeTrainer
End If
End Function
Private Sub Timer_Logout_Timer()
lbl_Elapsed.Caption = lbl_Elapsed.Caption + 1
End Sub
Private Sub Form_Load()
Call SetWindowPos(frmMiner.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Attachment 179136
-
Oct 27th, 2020, 07:55 AM
#11
Thread Starter
New Member
Re: Help with an error in a simple mouse simulation script
-
Oct 27th, 2020, 11:50 AM
#12
Re: Help with an error in a simple mouse simulation script
Don't see anything that would indicate memory leaks related to GetDC(); at least not with the code you posted in #10 above.
However, you are basically creating an infinite loop and stack recursion. Stack recursion can cause out of memory errors. That may be causing your problems?
Here's your code overview as is now:
Code:
cmd_Start calls initializeTrainer
initializeTrainer calls clearInventory
in clearInventory...
If lbl_Elapsed.Caption = "240" Then
' do stuff
Calls initializeTrainer -- infinite loop + stack recursion
Else
Calls initializeTrainer -- infinite loop + stack recursion
End If
If you added a MsgBox immediately after your "initializeTrainer" line in the button's click event, that msgbox would never trigger with the code you have as of now. Try it and see if that's true.
Last edited by LaVolpe; Oct 27th, 2020 at 12:14 PM.
-
Oct 27th, 2020, 09:53 PM
#13
Thread Starter
New Member
Re: Help with an error in a simple mouse simulation script
Hey I placed a message box in the button click event and it is true it doesn't trigger, i'm unsure how to fix this problem as it needs to run for long periods of time, Would it be better to have it restart the program every few hours or something?
-
Oct 28th, 2020, 10:05 AM
#14
Re: Help with an error in a simple mouse simulation script
Simply call your recurring routine from within a timer.
Inside the timer event:
1. Disable timer to prevent unwanted re-entrance due to your DoEvents calls
2. Call your initializeTrainer routine
3. Re-enable timer unless you want to set some restriction to end "trainer"
Do not call initializeTrainer from clearInventory; only allow initializeTrainer to be called from within the timer event.
-
Nov 4th, 2020, 09:57 PM
#15
Thread Starter
New Member
Re: Help with an error in a simple mouse simulation script
Hey man sorry to be a pain I thought I had resolved the issue but it seems to be doing the same thing, I've written another one here and the GUI crashed after about 6 hours in and I can't see where i'm going wrong with ReleaseDC.=.
Code:
'Camera - 286
Option Explicit
Private 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 Long
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Type POINTAPI
x As Long
y As Long
End Type
Public Sub Wait(Optional ms As Long = 2000)
On Error Resume Next
Dim tc As Long
tc = GetTickCount
While GetTickCount < tc + ms: Sleep 1: DoEvents: Wend
End Sub
Public Function RandomNumber(ByVal MinValue As Long, Optional _
ByVal MaxValue As Long = 0)
On Error Resume Next
Randomize Timer
RandomNumber = Int((MaxValue - MinValue + 1) * Rnd) + MinValue
End Function
Public Sub KeyDown(KCC As KeyCodeConstants)
keybd_event KCC, 0, 0, 0
End Sub
Public Sub KeyUp(KCC As KeyCodeConstants)
keybd_event KCC, 0, KEYEVENTF_KEYUP, 0
End Sub
Private Sub cmd_Start_Click()
If cmd_Start.Caption = "Start" And Not text_Spot.Text = "" Then
cmd_Start.Caption = "Stop"
text_Spot.Enabled = False
Timer_Logout.Enabled = True
Timer_Spot.Enabled = True
Else
End
End If
End Sub
Private Sub Timer_Logout_Timer()
lbl_Elapsed.Caption = lbl_Elapsed.Caption + 1
End Sub
Private Sub Form_Load()
Call SetWindowPos(frm_FlyFishing.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Private Sub Timer_Spot_Timer()
Dim scrHwnd As Long
scrHwnd = GetDesktopWindow
Dim shDC As Long
shDC = GetDC(scrHwnd)
Dim Found As Boolean
Timer_Spot.Enabled = False
Found = False
lbl_Status.Caption = "Locating..."
If text_Spot.Text = "1" Then
If Found = False Then
Call SetCursorPos(540, 514)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 545, 544) = "16777215" Then ' Spot 1 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(535, 545), RandomNumber(510, 520))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "1"
End If
End If
If Found = False Then
Call SetCursorPos(538, 474)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 543, 504) = "16777215" Then ' Spot 2 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(530, 544), RandomNumber(470, 480))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "2"
End If
End If
If Found = False Then
Call SetCursorPos(767, 217)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 772, 247) = "16777215" Then ' Spot 3 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(760, 773), RandomNumber(212, 222))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "3"
End If
End If
If Found = False Then
Call SetCursorPos(764, 176)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 769, 206) = "16777215" Then ' Spot 4 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(758, 769), RandomNumber(170, 182))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "4"
End If
End If
If Found = False Then
Call SetCursorPos(763, 144)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 768, 174) = "16777215" Then ' Spot 5 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(758, 768), RandomNumber(139, 149))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "5"
End If
End If
End If
If text_Spot.Text = "2" Then
If Found = False Then
Call SetCursorPos(540, 500)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 545, 530) = "16777215" Then ' Spot 2 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(535, 545), RandomNumber(495, 505))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "2"
End If
End If
If Found = False Then
Call SetCursorPos(539, 541)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 544, 571) = "16777215" Then ' Spot 1 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(535, 544), RandomNumber(537, 546))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "1"
End If
End If
If Found = False Then
Call SetCursorPos(764, 243)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 769, 273) = "16777215" Then ' Spot 3 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(758, 769), RandomNumber(238, 248))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "3"
End If
End If
If Found = False Then
Call SetCursorPos(765, 210)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 770, 240) = "16777215" Then ' Spot 4 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(760, 770), RandomNumber(205, 215))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "4"
End If
End If
If Found = False Then
Call SetCursorPos(762, 168)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 767, 198) = "16777215" Then ' Spot 5 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(757, 767), RandomNumber(163, 173))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "5"
End If
End If
End If
If text_Spot.Text = "3" Then
If Found = False Then
Call SetCursorPos(541, 513)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 546, 543) = "16777215" Then ' Spot 3 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(536, 546), RandomNumber(508, 518))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "3"
End If
End If
If Found = False Then
Call SetCursorPos(541, 477)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 546, 507) = "16777215" Then ' Spot 4 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(536, 546), RandomNumber(472, 482))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "4"
End If
End If
If Found = False Then
Call SetCursorPos(542, 437)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 547, 467) = "16777215" Then ' Spot 5 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(542, 552), RandomNumber(430, 447))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "5"
End If
End If
If Found = False Then
Call SetCursorPos(313, 776)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 318, 806) = "16777215" Then ' Spot 2 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(308, 318), RandomNumber(771, 781))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "2"
End If
End If
If Found = False Then
Call SetCursorPos(315, 820)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 320, 850) = "16777215" Then ' Spot 1 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(310, 320), RandomNumber(815, 825))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "1"
End If
End If
End If
If text_Spot.Text = "4" Then
If Found = False Then
Call SetCursorPos(539, 508)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 544, 538) = "16777215" Then ' Spot 4 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(539, 549), RandomNumber(503, 513))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "4"
End If
End If
If Found = False Then
Call SetCursorPos(539, 545)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 544, 575) = "16777215" Then ' Spot 3 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(534, 544), RandomNumber(540, 550))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "3"
End If
End If
If Found = False Then
Call SetCursorPos(540, 469)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 545, 499) = "16777215" Then ' Spot 5 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(535, 545), RandomNumber(464, 474))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "5"
End If
End If
If Found = False Then
Call SetCursorPos(316, 804)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 321, 834) = "16777215" Then ' Spot 2 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(311, 321), RandomNumber(799, 809))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "2"
End If
End If
If Found = False Then
Call SetCursorPos(313, 845)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 318, 875) = "16777215" Then ' Spot 1 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(308, 318), RandomNumber(840, 850))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "1"
End If
End If
End If
If text_Spot.Text = "5" Then
If Found = False Then
Call SetCursorPos(542, 501)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 547, 531) = "16777215" Then ' Spot 5 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(537, 547), RandomNumber(496, 506))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "5"
End If
End If
If Found = False Then
Call SetCursorPos(539, 542)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 544, 572) = "16777215" Then ' Spot 4 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(534, 544), RandomNumber(538, 548))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "4"
End If
End If
If Found = False Then
Call SetCursorPos(542, 580)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 547, 610) = "16777215" Then ' Spot 3 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(542, 552), RandomNumber(575, 585))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "3"
End If
End If
If Found = False Then
Call SetCursorPos(315, 846)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 320, 876) = "16777215" Then ' Spot 2 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(310, 320), RandomNumber(841, 851))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "2"
End If
End If
If Found = False Then
Call SetCursorPos(315, 879)
Wait (RandomNumber(900, 1200))
If GetPixel(shDC, 320, 909) = "16777215" Then ' Spot 1 Avail
Wait (RandomNumber(900, 1200))
Found = True
Call SetCursorPos(RandomNumber(310, 320), RandomNumber(873, 883))
Wait (RandomNumber(200, 300))
Mouse_Click (vLeftclick)
lbl_SpotNew.Caption = "1"
End If
End If
End If
ReleaseDC scrHwnd, shDC
If Found = False Then
lbl_Status.Caption = "Error"
Beep 500, 10000
Else
lbl_Status.Caption = "Fishing..."
text_Spot.Text = lbl_SpotNew.Caption
lbl_SpotNew.Caption = "0"
Wait (8000)
Timer_Status.Enabled = True
End If
End Sub
Private Sub Timer_Status_Timer()
Dim scrHwnd As Long
scrHwnd = GetDesktopWindow
Dim shDC As Long
shDC = GetDC(scrHwnd)
If lbl_Elapsed.Caption = "240" Or lbl_Elapsed.Caption = "241" Or lbl_Elapsed.Caption = "242" Or lbl_Elapsed.Caption = "243" Or lbl_Elapsed.Caption = "244" Then
Timer_Status.Enabled = False
Timer_Logout.Enabled = False
lbl_Elapsed.Caption = "0"
lbl_Status.Caption = "Rebooting..."
lbl_Reboots.Caption = lbl_Reboots.Caption + 1
Call SetCursorPos(RandomNumber(876, 888), RandomNumber(970, 982)) ' Log out
Wait (RandomNumber(160, 240))
Mouse_Click (vLeftclick)
Wait (RandomNumber(1200, 1300))
Call SetCursorPos(RandomNumber(855, 909), RandomNumber(915, 930)) ' Log out
Wait (RandomNumber(160, 240))
Mouse_Click (vLeftclick)
Wait (RandomNumber(600000, 900000))
Call SetCursorPos(RandomNumber(558, 608), RandomNumber(300, 330)) ' Existing user
Wait (RandomNumber(160, 240))
Mouse_Click (vLeftclick)
Wait (RandomNumber(1200, 1300))
KeyDown vbKey7
Wait (RandomNumber(160, 240))
KeyUp vbKey7
Wait (RandomNumber(160, 240))
KeyDown vbKey9
Wait (RandomNumber(160, 240))
KeyUp vbKey9
Wait (RandomNumber(160, 240))
KeyDown vbKey8
Wait (RandomNumber(160, 240))
KeyUp vbKey8
Wait (RandomNumber(160, 240))
KeyDown vbKey9
Wait (RandomNumber(160, 240))
KeyUp vbKey9
Wait (RandomNumber(160, 240))
KeyDown vbKey5
Wait (RandomNumber(160, 240))
KeyUp vbKey5
Wait (RandomNumber(160, 240))
KeyDown vbKey7
Wait (RandomNumber(160, 240))
KeyUp vbKey7
Wait (RandomNumber(160, 240))
KeyDown vbKey8
Wait (RandomNumber(160, 240))
KeyUp vbKey8
Wait (RandomNumber(160, 240))
KeyDown vbKeyReturn
Wait (RandomNumber(160, 240))
KeyUp vbKeyReturn
Wait (12000)
Call SetCursorPos(RandomNumber(470, 550), RandomNumber(340, 380)) ' Play
Wait (RandomNumber(160, 240))
Mouse_Click (vLeftclick)
Wait (RandomNumber(3000, 3300))
If Not GetPixel(shDC, 940, 938) = "2700606" Then
ReleaseDC scrHwnd, shDC
Call clearInventory
Else
ReleaseDC scrHwnd, shDC
Timer_Logout.Enabled = True
Timer_Spot.Enabled = True
End If
Else
If Not GetPixel(shDC, 66, 56) = "65280" Then
Timer_Status.Enabled = False
If Not GetPixel(shDC, 940, 938) = "2700606" Then
ReleaseDC scrHwnd, shDC
Call clearInventory
Else
ReleaseDC scrHwnd, shDC
Timer_Spot.Enabled = True
End If
End If
End If
End Sub
Public Function clearInventory()
lbl_Status.Caption = "Clearing..."
KeyDown vbKeyShift
Wait (RandomNumber(600, 900))
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(713, 728)) '3
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(713, 728)) '4
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(750, 765)) '5
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(750, 765)) '6
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(750, 765)) '7
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(750, 765)) '8
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(784, 799)) '9
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(784, 799)) '10
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(784, 799)) '11
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(784, 799)) '12
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(822, 833)) '13
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(822, 833)) '14
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(822, 833)) '15
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(822, 833)) '16
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(858, 871)) '17
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(858, 871)) '18
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(858, 871)) '19
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(858, 871)) '20
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(894, 907)) '21
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(894, 907)) '22
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(894, 907)) '23
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(894, 907)) '24
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(810, 828), RandomNumber(929, 940)) '25
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(850, 868), RandomNumber(929, 940)) '26
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(890, 908), RandomNumber(929, 940)) '27
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
Call SetCursorPos(RandomNumber(930, 948), RandomNumber(929, 940)) '28
Wait (RandomNumber(120, 260))
Mouse_Click (vLeftclick)
Wait (RandomNumber(120, 260))
KeyUp vbKeyShift
Wait (RandomNumber(120, 260))
Timer_Spot.Enabled = True
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|