← Back to team overview

sikuli-driver team mailing list archive

[Question #215002]: Help a newbie with a basic script please. Mine doesn't work.

 

New question #215002 on Sikuli:
https://answers.launchpad.net/sikuli/+question/215002

Hi I am new to Sikuli. Looks like a very cool program but is very different from Autoit which I am very comfortable with. I need to create a very basic script for mac, but can't seem to do it. I have carpal tunnel and from time to time play a little bit of Diablo. My script on autoit does a very basic function.
1) Waits in the background.
2) When a hot key is pressed; ie Num4 it will hold left click for 2.5 seconds, when Num5 is pressed it will hold right click for 3 seconds. This way I can avoid having to click again and agan. 

After reading through the Sikuli instructions I wrote the following but it does not work. 

def Rattack():
    mouseDown(Button.RIGHT)
    wait(3)
    mouseUp(Button.RIGHT)
def Lattack():
    mouseDown(Button.LEFT)
    wait(2)
    mouseUp(Button.LEFT)

Env.addHotkey(Key.NUM4,KeyModifier.SHIFT, Rattack)
Env.addHotkey(Key.NUM5,KeyModifier.SHIFT, Lattack)
 
myApp = App("Diablo III")
myApp.focus()
 
playground = App.focusedWindow()

while True:
    sleep(1)

-----Also is there any way to use the Env.addHotkey without a modifier key. I'd like to press only numpad4. 


Here is how I did it in auto it:


HotKeySet('{Numpad4}', 'Lclick')
HotKeySet('{Numpad5}', 'Rclick')
WinActivate('Diablo III')
WinMove('Diablo III', '', 0, 0)


While 1 
sleep (100)
Wend


Func LClick()
   Send("{SHIFTDOWN}")
   MouseDown("left")
   Delay(2500)
   MouseUp("left")
   Send("{SHIFTUP}")
EndFunc  

Func LClick()
   MouseDown("right")
   Sleep(3000)
   MouseUp("right")
EndFunc  

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.