Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Sikuli in systray


  • Please log in to reply
No replies to this topic
kife42
  • Members
  • 1 posts
  • Last active: Sep 15 2011 06:33 PM
  • Joined: 02 Sep 2011
wrote this Autohotkey script to make Sikuli easier to use with windows.
i'd post it on a Sikuli forum, but there is no Sikuli forum. ^_^;

features:
open a Sikuli script at startup
run a script at startup
switch between scripts using systray
configurable icon remains in systray while script runs in background
use multiple run scripts to show different icons
cancel script using systray menu
kill all background Sikuli processes using systray menu
closing Sikuli closes systray icon, closing systray icon closes Sikuli

-Ryan

; NOTES:
; 9/15/11 - sometimes Sikuli will continue to run a script even if alt-shift-c has "cancelled" it.  so to force these processes to close, i created the Kill All Javaw.exe menu option in the systray.
; Ryan Nakahara

; SETTINGS

script_name = test1.sikuli
script_directory = c:\abc
python_path = C:\abc\sikuli\Sikuli-X-1.0rc3 (r905)-win32\Sikuli-IDE

;Menu, Tray, Icon, C:\abc\Question.ico ; uncomment and configure this line to change the systray icon

; add or remove "-r" to run in foreground or background mode
args = 

menu, tray, add, test script 1, script1
script1_name = test1.sikuli
menu, tray, add, test script 2, script2
script2_name = test2.sikuli
menu, tray, add, test script 3, script3
script3_name = test3.sikuli

; comment out as needed
menu, tray, add, Cancel Script (Alt-Shift-C), cancelScript
menu, tray, add, Kill All Javaw.exe (all Sikuli processes), killJavaw
menu, tray, add  ; Creates a separator line.
menu, tray, add, Window Spy, WindowSpy
menu, tray, add, Edit Autohotkey, edit
menu, tray, add, Reload Autohotkey, reload
menu, tray, add, Exit, ExitSub
menu, tray, NoStandard


;=======================================================


#Persistent
SetTitleMatchMode 2
OnExit, ExitSub
RunWait javaw -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dpython.path="%python_path%\sikuli-script.jar" -jar "%python_path%\sikuli-ide.jar" %args% %script_directory%\%script_name% , %python_path%\libs, hide
ExitApp


script1:
 WinClose %script_name%
 script_name = %script1_name%
 RunWait javaw -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dpython.path="%python_path%\sikuli-script.jar" -jar "%python_path%\sikuli-ide.jar" %args% %script_directory%\%script_name% , %python_path%\libs, hide

script2:
 WinClose %script_name%
 script_name = %script2_name%
 RunWait javaw -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dpython.path="%python_path%\sikuli-script.jar" -jar "%python_path%\sikuli-ide.jar" %args% %script_directory%\%script_name% , %python_path%\libs, hide

script3:
 WinClose %script_name%
 script_name = %script3_name%
 RunWait javaw -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dpython.path="%python_path%\sikuli-script.jar" -jar "%python_path%\sikuli-ide.jar" %args% %script_directory%\%script_name% , %python_path%\libs, hide

WindowSpy:
 ifWinExist ahk_class AU3Reveal 
  WinActivate 
  else 
 Run %A_AhkPath%\..\AU3_Spy.exe 
 return

edit:
 edit
 return

reload:
 reload
 return

ExitSub:
 Send {Shift Down}{Alt Down}c{Shift Up}{Alt Up}
 SetTitleMatchMode 2
 WinClose %script_name%
 ExitApp

cancelScript:
 Send {Shift Down}{Alt Down}c{Shift Up}{Alt Up}
 Return

killJavaw:
 DetectHiddenWindows, On 
 Process, Exist, javaw.exe 
 pid:=errorlevel 
 Loop 
 { 
    IfWinExist, ahk_pid %pid% 
    { 
       WinClose 
    } 
    else if A_Index>1 
       break 
    else msgbox, None found 
 } 
 return