Need A Bit Of Help With My Script

02/24/2011 21:28 SSnipeRR#1
i have this script for a bot that i am making... but in order to make it so that it "imitate" a 'click' other then useing "my mouse/keybord" i vas told to use this UDF... :)

but i cant seam to get it to work... :(

PHP Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <PostMessage.au3>
#Region ### START Koda GUI section ### Form=
HotKeySet("{ESC}","Terminate")
$Form1 GUICreate("RS FM Bot"22299192124)
$Label1 GUICtrlCreateLabel("RuneScape Firemaking Bot"48815017)
$Button1 GUICtrlCreateButton("Start"64408933$WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit

EndSwitch

If 
$nMsg $Button1 Then Button1()

WEnd



Func Button1
()
    
$hWnd WinGetHandle("RuneScape - The Number 1 Free Multiplayer Game - Mozilla Firefox")
    
Sleep(1000)
    
_PostMessage_Click($hWnd,1045,189,"Left")
    
Sleep(500)
    
_PostMessage_Send($hWnd,"{UP down}")
    
Sleep(2000)
    
_PostMessage_Send($hWnd,"{UP up}")
    
Sleep(500)
    
_PostMessage_Click($hWnd,992,186,"Left"
this is the start of the script but when i start it it dose nothing... :( any one can tell me what the problem is???

or if there is another way to do it...

(i would like it so i can have 2 bot's running at once or one bot + me playing/scripting...)

i have yet another question... :)

can anyone tell me how to get ik so when i type "10" in my GUI input it will run 10 loops and then stop?!? i have it so i can set it in the script manualy but it would be nice to get the GUI to work proberly... :)

and one last thing... ;)

can i get the GUI to "count" aswell?!? so it shows me that it hase made "x" Loops?!?

Regards SSnipeRR
02/25/2011 18:47 derpo#2
You need an end of the Function Button1 (EndFunc) and you need the Function Terminate.
Here's the code fixed :
PHP Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <PostMessage.au3>
HotKeySet("{ESC}","Terminate")
$Form1 GUICreate("RS FM Bot"22299192124)
$Label1 GUICtrlCreateLabel("RuneScape Firemaking Bot"48015017)
$Loops GUICtrlCreateInput("",60,17,93,23)
$Button1 GUICtrlCreateButton("Start"64408933$WS_GROUP)
$txtloop GUICtrlCreateLabel("Loop : ",0,83,222,17)
GUISetState(@SW_SHOW)

While 
1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit

    EndSwitch

    If 
$nMsg $Button1 Then
        
If GUICtrlRead($LoopsThen
            $loopnumber 
GUICtrlRead($Loops)
            
$hWnd WinGetHandle("RuneScape - The Number 1 Free Multiplayer Game - Mozilla Firefox")
            For 
$i 0 To $loopnumber Step 1
                GUICtrlSetData
($txtloop,"Loop : "&$i)
                
Sleep(1000)
                
_PostMessage_Click($hWnd,1045,189,"Left")
                
Sleep(500)
                
_PostMessage_Send($hWnd,"{UP down}")
                
Sleep(2000)
                
_PostMessage_Send($hWnd,"{UP up}")
                
Sleep(500)
                
_PostMessage_Click($hWnd,992,186,"Left")
            
Next
            GUICtrlSetData
($txtloop,"Loop : ")
        Else
            
MsgBox(0,"Bot","You have to enter a number of loops!")
        EndIf
    EndIf

WEnd

Func Terminate
()
    Exit
EndFunc 
02/25/2011 20:06 SSnipeRR#3
oki thanks... i will try this and see if this will help...

(tho it was only a plug uot from the script so EndFunc is lower down just did not post it cus the full script is a bit long... :S but the normal
PHP Code:
MouseClick() 
vorks fine in the script just the "imitatet" mouseclick's dont... :(


Edit:

i have tryed the script you fixed... same problem... nothing... it counts the loops tho... :) thanks...

but it dosent eaven fix on the window... :(
02/25/2011 21:09 derpo#4
If you have problems with _PostMessage_Click too, you have to change Left to left
You don't need down and up. The third parameter for the UDF is the Delay between Down and Up in ms.
Example :
Instead of
PHP Code:
_PostMessage_Send($HWnd,{UP down})
Sleep(1000)
_PostMessage_Send($HWnd,{UP up}) 
,just use
PHP Code:
_PostMessage_Send($HWnd,{UP},1000
02/25/2011 21:41 SSnipeRR#5
sry about the duple post... :S

well the problem is all of it...
PHP Code:
Func Button1()
    
$hWnd WinGetHandle("RuneScape - The Number 1 Free Multiplayer Game - Mozilla Firefox")  ;This Should aktivate the windowit dosent. :/
    
Sleep(1000)
    
_PostMessage_Click($hWnd,1045,189,"Left") ; this should click at the certen coordinatesit dosent do anything...
    
Sleep(500)
    
_PostMessage_Send($hWnd,"{UP down}")
    
Sleep(2000)
    
_PostMessage_Send($hWnd,"{UP up}")
    
Sleep(500)
    
_PostMessage_Click($hWnd,992,186,"Left"
oki i'll try make "Left" to "left" and see if that has any efeckt...

but it still need to aktivate the window... :/

thanks for the example... :)