[python][help] macro

02/17/2010 06:47 KevSmash#1
I wrote some bots, trouble is that I can't keep switching between autoitv3 or ahk and python anymore since my scripts are going to include packet manipulation/injection which is sensitive to time (it's not just flooding the same packet).

I'd like to change the mousepos, leftclick, and rightclick to write directly to mabi (really whatever works, I have the keyboard working), I'm under the impression that the mouse position I'm writing to sits in the center of the mabi screen and there's another mouse used by mabi. It'd be 100 times better if an assembly ninja could edit the correct mabi files to reference the mouse positions I'm writing to in the script below.


Code:
import sys, ctypes, time

i = 0

def mousepos(x,y):
    sleep( .5 )
    ctypes.windll.user32.SetCursorPos(x,y)
    
def leftclick():
    sleep( .2 )
    ctypes.windll.user32.mouse_event(0x00000002, 0, 0, 0, 0)
    sleep( .2 )
    ctypes.windll.user32.mouse_event(0x00000004, 0, 0, 0, 0)

def rightclick():
    sleep( .2 )
    ctypes.windll.user32.mouse_event(0x00000008, 0, 0, 0, 0)
    sleep( .2 )
    ctypes.windll.user32.mouse_event(0x00000010, 0, 0, 0, 0)

def sleep(v):
    time.sleep( v )
    
#### ~~~~~~~~~~ START MACRO ~~~~~~~~~
print "Start : %s" % time.ctime()
time.sleep( 5 )

while i <= 50:
    mousepos(113,44)
    mousepos(380,350)
    rightclick()
    mousepos(386,441) 
    leftclick()
    mousepos(455,482) 
    leftclick()
    mousepos(313,414)
    leftclick()    
    mousepos(380,375)
    rightclick()
    mousepos(384,507) 
    leftclick()
    mousepos(470,555)
    leftclick()
    mousepos(305,477)
    leftclick() 
    mousepos(380,400)
    rightclick()
    mousepos(466,523) 
    leftclick()
    mousepos(455,546) 
    leftclick()
    mousepos(251,410)
    leftclick()  
    sleep( 3 )
    

    i = i + 1

print "End : %s" % time.ctime()
I also tried using the win32api module instead of ctypes.

If your help proves useful, I'll give you a python packet injection script with hotkeys built in.
02/21/2010 19:42 KevSmash#2
Used py2exe, compiled it and ran as administrator (it's because I was on vista) instead of running it from IDLE.

Problem solved.