Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlevel.click_on_pat Often Fails With no images defined png:/tmp/somernd #852

Open
3 of 16 tasks
dginovker opened this issue May 6, 2023 · 4 comments
Open
3 of 16 tasks
Labels
bug help-wanted scripting Issues related to Scripts or the scripting API

Comments

@dginovker
Copy link

AutoKey is a Xorg application and will not function in a Wayland session. Do you use Xorg (X11) or Wayland?

Xorg

Has this issue already been reported?

  • I have searched through the existing issues.

Is this a question rather than an issue?

  • This is not a question.

What type of issue is this?

Bug

Choose one or more terms that describe this issue:

  • autokey triggers
  • autokey-gtk
  • autokey-qt
  • beta
  • bug
  • critical
  • development
  • documentation
  • enhancement
  • installation/configuration
  • phrase expansion
  • scripting
  • technical debt
  • user interface

Other terms that describe this issue if not provided above:

highlevel

Which Linux distribution did you use?

Arch Linux x86_64

Which AutoKey GUI did you use?

Qt

Which AutoKey version did you use?

Latest git (May 6th, 2023)

How did you install AutoKey?

Git

Can you briefly describe the issue?

With the following code:

path = "/home/xacket/.config/autokey/data/myimage.png"

# try to click the image, catch and print the error if it fails
try:
  autokey.scripting.highlevel.click_on_pat(path, 1, (50, 50), 32000)
except Exception as e:
  print("Didn't find {} on the screen".format(path))

I often see

X Error of failed request:  BadColor (invalid Colormap parameter)
  Major opcode of failed request:  91 (X_QueryColors)
  Resource id in failed request:  0x0
  Serial number of failed request:  456
  Current serial number in output stream:  456
convert: unable to read image header `-' @ error/xwd.c/ReadXWDImage/227.
convert: no images defined `png:/tmp/tmp1s6e_yoa' @ error/convert.c/ConvertImageCommand/3342.
Didn't find /home/xacket/.config/autokey/data/myimage.png on the screen

Can the issue be reproduced?

Sometimes

What are the steps to reproduce the issue?

  1. Put the above code in Autokey
  2. Save an image at the path, make sure the image is on the screen
  3. Assign a hotkey to the script
  4. Hit the hotkey

What should have happened?

The image should be clicked

What actually happened?

For random periods of 60 seconds it works, then it doesn't

Do you have screenshots?

No response

Can you provide the output of the AutoKey command?

No response

Anything else?

It seems to not work after editing hotkey scripts recently, but then starts working later? Really not sure. Also I'm editing the hotkey scripts external to the built-in editor, but I can't imagine that's related.

Many thanks for Autokey!

@josephj11 josephj11 added bug help-wanted scripting Issues related to Scripts or the scripting API labels May 6, 2023
@josephj11
Copy link
Contributor

As much as I keep promoting this feature, no one seems to use it, so we have very little experience with it. I think this is its first ever reported bug.

We could really use some input from people such as yourself who are actually using it - on Gitter and with anything you want to add to our wiki and examples.

Hopefully, one of our devs can take a look at this. (We are very short on developer resources.)

Although I think this is a killer feature that really should get used a lot, I would caution developers not to rely on it too heavily. The Xautomation project has been inactive for several years and it is very unlikely to work with Wayland. (Currently, AutoKey doesn't work with Wayland either, but we're working on that.)

@Elliria
Copy link
Contributor

Elliria commented May 6, 2023

I've got no experience with using the highlevel API calls, but I took a look at the documentation for the autokey.scripting.highlevel.click_on_pat() call.

When looking at this line in your code, I noticed that you're missing the restore_pos part of the call, so perhaps AutoKey is getting lost since it hasn't been returned to the initial mouse position after the click:

autokey.scripting.highlevel.click_on_pat(path, 1, (50, 50), 32000)

That might explain why it sometimes works and sometimes doesn't, since it stands to reason that it would sometimes be in the starting position, but other times wouldn't.

@josephj11
Copy link
Contributor

josephj11 commented May 6, 2023

restore_pos defaults to false.

In Python, defining function arguments is a big deal. This article is amazingly clear and detailed.

I'm not sure, but I think the way the API function call was coded is probably fine.
(That article was a lot to absorb at one time!)

What the heck does a tolerance of 32000 do? I see the definition of tolerance, but not what the values actually mean.

@Elliria
Copy link
Contributor

Elliria commented May 7, 2023

restore_pos defaults to false.

My point, exactly.

What the heck does a tolerance of 32000 do? I see the definition of tolerance, but not what the values actually mean.

I'm not sure, but I'm guessing it means that it has a very high tolerance for fuzzy matches. I've done something similar in CSS, where you can set different tolerances. When you want to be sure that one of the things you're setting tolerances for always takes precedence, you just give it a ridiculously-high number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help-wanted scripting Issues related to Scripts or the scripting API
Projects
None yet
Development

No branches or pull requests

3 participants