← Back to team overview

sikuli-driver team mailing list archive

[Bug 1461093] Re: switchApp()/ App.focus() should accept parts of title or regex

 

** Summary changed:

- switchApp() cannot focus to Outlook
+ switchApp()/ App.focus() should accept parts of title or regex

** Changed in: sikuli
       Status: New => In Progress

** Changed in: sikuli
   Importance: Undecided => Low

** Changed in: sikuli
   Importance: Low => Wishlist

** Changed in: sikuli
     Assignee: (unassigned) => RaiMan (raimund-hocke)

** Changed in: sikuli
    Milestone: None => 2.0.5

** Summary changed:

- switchApp()/ App.focus() should accept parts of title or regex
+ [request] switchApp()/ App.focus() should accept parts of title or regex

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1461093

Title:
  [request] switchApp()/ App.focus() should accept parts of title or
  regex

Status in Sikuli:
  In Progress

Bug description:
  1.1.0(2015-06-02_01:00nightly)/Windows6.1/Java8(64)1.8.0_45-b15
  OS: Windows 7 Professional SP1 64 bit

  +++ running this Java
  java version "1.8.0_45"
  Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
  Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

  Outlook:
  Microsoft Outlook 2013 (15.0.4719.1000) 32 bit

  Description: 
  The code snippet below cannot focus on an already opened (not minimized) Outlook instance. (I use it as a test to try nightly versions.) A few applications can be switched to, but O365 apps generally cannot. (The image file is a little icon from the application window, that is always present if the window can be seen.)

  The output is "If you have...", so ol != None, but the window is not
  brought to the front. Another interesting subject is the highlighted
  region, usually the last focused window.

  -----

  Debug.on(3)

  ol = switchApp('Outlook')
  wait(2)
  if ol == None or not ol.window():
      popError("Still cannot use the switchApp() / focus() function... :(")
      exit(1)

  try:
      mol = find("1433249332978.png")
      popup("switchApp() / focus() works! :)")
  except:
      ol.focusedWindow().highlight()
      popup("If you have Outlook window on top, then switchApp() / focus() works,\n" \ 
              "but find() cannot see it...")
   
  -----

  Debug log:
  [debug] Jython: requested to use as default region: R[0,0 1680x1050]@S(0)

  [debug] JythonScriptRunner: runPython: running script from IDE: C:/Users/####/SikuliX-1.1/TEST-switchAppFocus.sikuli
  [debug] WinUtil.getApp: !Outlook

  [debug] App.immediate: Outlook
  [debug] App.create: [5588:OUTLOOK.EXE]

  [debug] Region: find: waiting 3,0 secs for 1433249332978.png to appear in R[0,0 1680x1050]@S(0)
  [debug] Image: reused: 1433249332978.png (file:/C:/Users/####/SikuliX-1.1/TEST-switchAppFocus.sikuli/1433249332978.png)
  [debug] Region: checkLastSeen: not there

  [debug] Region: find: 1433249332978.png has not appeared [677 msec]

  [debug] Sikulix: cleanUp: 0

  -----

  Additional comments:
  I am now using a workaround to get the focus working:

  import os

  def focusAppWorkaround(titlePart):
      os.system(r'"C:\Full\path\to\appactivate.vbs" "' + titlePart + '"')

  
  ' appactivate.vbs
  Set objShell = WScript.CreateObject("WScript.Shell")
  Param0 = ""
  If (WScript.Arguments.Count > 0) Then
    Param0 = WScript.Arguments.Item(0)
    objShell.AppActivate Param0
  End If

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1461093/+subscriptions


References