Popup or Input box On Top

Asked by Jeff_Vallis

1.1.0(2015-08-20_01:00nightly)/Mac10.10.5/Java8(64)1.8.0_25-b17

When Script Runs Popup or Input is hidden behind the main screen
Is there anyway to Force it to appear ontop

my workaround is to make the text so long that some of it appears on the right hand side and I can click on it to bring it to the front
(Running from command line)

Question information

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

Sorry, no easy way.

With some basic Java knowledge you might create your own popup and input dialogs that are forced to be always on top.

or use something like this (tested on OS X 10.11 with final version 1.1.0):

switchApp("Safari")

def myPopup(message, app):
  switchApp("SikuliX")
  popup(message)
  switchApp(app)

def myInput(message, app):
  switchApp("SikuliX")
  ret = input(message)
  switchApp(app)
  return ret

myPopup("can you see me", "Safari")
print myInput("can you see me", "Safari")

Revision history for this message
masuo (masuo-ohara) said :
#2

I don't Know Mac, but I can display dialog box to front on Windows.
I always use addHotkey() in this case.

DialogBoxTitle = "Sikuli Input"
def waitInput():
    popup("Do you stop script?", DialogBoxTitle)

def ComeBackDialogBox(event):
    App.focus(DialogBoxTitle)

Env.addHotkey(Key.UP, KeyModifier.CTRL, ComeBackDialogBox)
waitInput()

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

@masuo
nice workaround, but does not work on Mac (focus on individual windows by title not available).

But I doubt, that this is the wanted solution anyways:
You have to press the key, to get the dialog to front.
But how do you know, that a dialog box was displayed?
You do not see it, since it is hidden behind other windows.

... but I will address this in version 2 anyways.

Revision history for this message
masuo (masuo-ohara) said :
#4

@RaiMan
When I am going to click OK button in SikliX dialog box, sometimes I click another window.
So I always use addHotkey().

Revision history for this message
masuo (masuo-ohara) said :
#5

@Jeff_Vallis
Sorry my script is not available on mac.

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#6

Explanation

The Browser Screen is not full screen
so
popup("=====================================================================Manual Move===============================================")
is below but some of it shows on the edge

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#7

1.1.1(2015-11-26_01:00nightly)/Mac10.11.2/Java8(64)1.8.0_25-b17
Tried again on latest release hoping it was solved
Also Tried - RaiMan (raimund-hocke) said on 2015-10-16: Suggestion this failed as well in the IDE so I Guess will fail from the command line

Some Info:
my Script is Choose_Login
Running a script from the command line I find that the following processes are running after I start the Script

/bin/bash /Applications/Sikuli/runsikulix -r /Users/Jeff/Desktop/SikuliScripts/Choose_Login.sikuli
/bin/bash /tmp/pmd-inline-5C2C6A40-F58F-479A-BBC5-3C266F53FF78.tmp
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Support/fontwor
/usr/bin/java -Xmx512M -Dfile.encoding=UTF-8 -Xdock:icon=/Applications/Sikuli/SikuliX.app/Contents/Resources/sikulix.ic

is there a way to use this info to get focus from the browser back to SikuliX

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

--- 1. SikuliX.app
With the final 1.1.0 and already with the pre-finals of 1.1.0, the app should be in /Applications/SikuliX.app (setup produces a SikuliX.app, that should be moved to /Applications).
In the setup folder you also have a runsikulix shell script, that checks different places and finally /Applications/SikuliX.app.

But you might as well use
/Applications/SikuliX.app/run (instead of runsikulix!)

--- 2. ... nevertheless switchApp("SikuliX") does not work, since the dock icon does not have the name SikuliX, which seems to be a problem with Java (bugs are reported there) and OS X 10.9+

I will check an alternative solution as a workaround with AppleScript and report back.

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

ok, this is a workaround (tested with OS X 10.11):

# a function that runs an applescript, that brings SikuliX to front
def sikulixToFront():
    cmd = '''
    applescript
    tell application "System Events"
        set xapp to first item of (processes whose displayed name is "SikuliX")
    end tell
    set frontmost of xapp to true
    '''
    runScript(cmd)

# test: Safari to front
switchApp("Safari")
wait(2)

#instead of App.focus("SikuliX")
sikulixToFront()
popup("continue?")

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

made it a bug

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#11

now using
/Applications/Sikuli/SikuliX.app/run -r /Users/Jeff/Desktop/SikuliScripts/TestSwitch.sikuli
as I have SikuliX.app in a Sikuli Folder
The Applescript worked fine
# a function that runs an applescript, that brings SikuliX to front
def sikulixToFront():
   cmd = '''
   applescript
   tell application "System Events"
       set xapp to first item of (processes whose displayed name is "SikuliX")
   end tell
   set frontmost of xapp to true
   '''
   runScript(cmd)

# test: Safari to front
switchApp("Safari")
wait(2)

#instead of App.focus("SikuliX")
sikulixToFront()
popup("continue?")