Coder Social home page Coder Social logo

Comments (12)

RaiMan avatar RaiMan commented on May 21, 2024 1

confirmed:
does not work, if window title contains unicode character.

possible workaround:
use a compound part of the window title, that does not contain any unicode characters.

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024 1

focus() always returns the App instance, but does not guarantee that it worked (currently no reliable check internally).

so this does not really make sense:

    new_app = app_instance.focus()
    print("%s focused ? %s " % (app_instance.getName(), new_app.getName()))

To get all available info about an App instance, simply use

print "myApp:", myApp

App has a rather verbose toString() implementation.

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024

Could you paste the offending snippet exactly as you use it?

switchApp method in org/sikuli/natives/WinUtil.java line 332 not implemented

it is indeed implemented, but the code is in the bundled native lib written with C++.

So it might have something to do with the unicode characters.

Also, is there any better way to work around to set focus on the app easily?

Not really. You might try to click on the app symbol in the taskbar. And of course you can find/click some part of the window, that is visible.

from sikulix1.

SeanKim777 avatar SeanKim777 commented on May 21, 2024

Thank you for quick reply. below is the my test code. I've tested with # -- coding: utf-8 -- heading but more got more strange result. below code was tested without # -- coding: utf-8 --

def check(app_instance):
    print("%s is running? %s" % (app_instance.getName(), app_instance.isRunning()))
    print("%s has window? %s" % (app_instance.getName(), app_instance.hasWindow()))
    new_app = app_instance.focus()
    print("%s focused ? %s " % (app_instance.getName(), new_app.getName()))

calculator = App("Calculator.exe") 
check(calculator)

chrome = App("Chrome.exe")
check(chrome)

** Result**
Calculator.exe is running? True
Calculator.exe has window? True

[error] App.focus failed: no window for [4668:Calculator.exe (CicMarshalWnd)] Calculator.exe
Calculator.exe focused ? Calculator.exe

Chrome.exe is running? True
Chrome.exe has window? True

Chrome.exe focused ? Chrome.exe

calculator

taskmgr

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024

-- coding: utf-8 -- heading

Not needed, since already set internally before script run. Does not have any influence on strings at script run, only tells the interpreter about the encoding of the script text.

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024

Have a look at the Debug feature in the docs.

For this test for example:

Debug.on(3)
calc = App("Calculator.exe") 
calc.open()
calc.focus()

would have revealed enough information "voluntarily" ;-)

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024

... and for testing short snippets I have added the feature in the IDE, that allows to run only some lines of a larger script (right-mouse on a line number)

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024

... and finally: I have to do some digging, to find out, what can be done or wether it is not possible with the current App implementation.

from sikulix1.

SeanKim777 avatar SeanKim777 commented on May 21, 2024

Thank you for your kind reply πŸ₯‡

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024

Hey, gold medal ;-)

In Germany we have a saying: As you shout into a forest, you get it back.

It definitely is the more motivating when answering questions/complains the more the caller shows up with some effort to help me understand the problem and how it came up.

All the best.

from sikulix1.

RaiMan avatar RaiMan commented on May 21, 2024

Bad news: no quick fix, only a workaround.
See #53 (comment)

from sikulix1.

balmma avatar balmma commented on May 21, 2024

Pull request #82 might fix this one. But keep in mind, that if you want to find an App using the window title and the title contains Unicode characters you have to use a Unicode String literal. E.g. App.focus(u"Über.txt - Editor") or App(u"Über.txt - Editor"). focus().

from sikulix1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.