← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #698136]: Two `def` functions, doesn't work, only bottom one works, why

 

Question #698136 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/698136

bhavanitech posted a new comment:
RaiMan,

Thanks, that solved the issue, another issue I face is the script is
consuming too much of RAM like anywhere between 500MB - 1GB. Also
exported script is as a runnable jar but didn't notice much reduction of
RAM usage (may be slightly).

**SPECS**
Win7 (x64), 
6 GB RAM,  
500 GB HDD,  (C:\ - 12 GB free space)
Thinkpad T520 - intel i5 (4th Gen)
JAVA 8 (update 301 , 2021) - updated

**Screenshots**:

[Win Task Manger - ram usage by java.exe - sikuli _ide/  runnable
JAR](https://i.imgur.com/2rvmjuw.png)

[script:](https://i.imgur.com/dP845h9.png)


------------------------CODE start:------------------------------

def SetfocusDevToolStylesFilter(event):
    wait(.05)
    click(Pattern("btnstyles.png").similar(0.40).targetOffset(-30,0))
    wait(.05)
    click(Pattern("inputfilter.png").similar(0.50).targetOffset(-100,0))
    
Env.addHotkey(Key.END, KeyModifier.ALT+KeyModifier.CTRL, SetfocusDevToolStylesFilter)

def SetfocusDevToolComputedStylesFilter(event):
    wait(.15)
    click(Pattern("btncomputed.png").similar(0.52).targetOffset(-30,0))
    wait(.1)
    
Env.addHotkey(Key.PAGE_DOWN, KeyModifier.ALT+KeyModifier.CTRL, SetfocusDevToolComputedStylesFilter)

def hkx(evt):
    print "terminating"
    global running
    running = False

Env.addHotkey("x", KeyModifier.ALT+KeyModifier.CTRL, hkx);

running = True

while running:
    wait(1)

------------------------CODE END:------------------------------

Also, how to cleanly exit/termiate the runnable jar, when I press the hotkey ctrl+alt+x (def hkx(evt)) to terminate it shows FATAL ERROR
"System.out is broken (console output) . You will not see any message anymore! Save your work and restart the IDE!"

[FATAL error screenshot](https://i.imgur.com/J3F5P3y.png)

Thanks for your help, very much appreciated.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.