Running Sikuli script in background and watching for hotkeys

Asked by Robert

Hi Thanks for the help earlier. My questions is listed as answered and I have the script running but there is one hiccup. I was wondering if someone can help with that please:

 Only way to send hotkeyevents is that the active window is the sikuli screen. Anyway to tell the script to wait for inputs from D3? So that when I press NUM4 in D3 it runs the script listed for hotkey Num 4. Once again thanks for the prompt help earlier really appreciate it. My script is below. Thanks.

def Rattack(event):
    myApp.focus()
    wait(1)
    mouseDown(Button.RIGHT)
    wait(3)
    mouseUp(Button.RIGHT)

def Lattack(event):
    myApp.focus()
    keyDown(Key.SHIFT)
    wait(0.5)
    mouseDown(Button.LEFT)
    wait(2)
    mouseUp(Button.LEFT)
    keyUp(Key.SHIFT)

Env.addHotkey(Key.NUM4,0, Rattack)
Env.addHotkey(Key.NUM5,0, Lattack)

myApp = App("Diablo III")
myApp.focus()
playground = App.focusedWindow()
while 1:
    wait(0.01)

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

try to add the hotkeys after switching to D3, this works for me with some Safari automations on my Mac M-Lion.

myApp = App("Diablo III")
myApp.focus()
playground = App.focusedWindow()

Env.addHotkey(Key.NUM4,0, Rattack)
Env.addHotkey(Key.NUM5,0, Lattack)

Revision history for this message
Robert (rsmomi) said :
#2

Thanks for the advise. Tried it like that and still no go. Sikuli-ide window needs to be the active window for it to work.

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

while 1:
    wait(0.01)

Revision history for this message
RaiMan (raimund-hocke) said :
#3

ok, then it might be necessary, to first activate something on the page by clicking and then wait a little.

If this does not help, then you might check, wether the normal way to add hotkeys (prefs -> keyboard) works with D3 at all.

Revision history for this message
Robert (rsmomi) said :
#4

Thanks for the help RaiMan. Its a no go though. D3 doesn't exist prefs-->hotkeys.
Seems like in sikuli-ide...hotkeys only work if sikuli is active window on MAC. Running D3 from Win 7 now so I can keep using my autoit scripts. If anyone has a way to do this through sikuli..it'll be awesome. Please let me know.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

May be I was not clear enough:

- Sikuli's hotkey feature works on my Mac OS X 10.8 with Safari being in foreground (I have some automations running this way, no need to have Sikuli in foreground)

- I did not mean prefs in D3 but the Mac Systempreferences (Applemenu)
-> Keyboard -> Keyboard Shortcuts -> Application Shortcuts
If this refuses to implement a shortcut for D3 or a shortcut implemented cannot be used, then Sikuli will not work either.

Can you help with this problem?

Provide an answer of your own, or ask Robert for more information if necessary.

To post a message you must log in.