This is my first question so apologies in advanced for everything I'll do wrong in the next lines.
I am having issues with the doubleClick function from pyautogui on mac with OSX.
Lately I have written some python code using the following libraries
from time import sleep
from random import uniform as r
from pyautogui import click, doubleClick, press, moveTo, mouseDown, mouseUp
from webbrowser import open_new_tab
Even by trying the simplest combination
x1, y1 = (300, 375)
doubleClick(x=x1, y=y1)
there is no action taking place. I have tried two quick clicks with an interval, both also got no results from that.
I am experiencing this as a major issues and have checked now on several mac machines (5+) and the issue is always there and I cannot find any reference in other questions or on the internet.
Is anyone else experiencing the same?
Thank you already for your help.
Had the same problem. Found a fix here. (Just make sure you first activated the window you need to double click in, with a single click. I forgot and now it works perfectly.)
Related
I'm trying to auto resize a PySimpleGUI window.
consider the following:
import PySimpleGUI as sg
CommandWindow = sg.Multiline(size=(80,20),echo_stdout_stderr=True,key=OUTPUT_KEY,visible=False)
window = sg.Window("FOO", layout=[CommandWindow],element_justification='center')
when the event is triggered, a sg.Multiline element's visible trait is updated to True.
then I refresh the window and it resizes (expands) to fit the element shown inside.
when I change the visible trait to False again, the window maintain its size and doesnt shrink back.
the execution as follows:
window[OUTPUT_KEY].update(visible=True/False)
window.refresh()
I think this will perhaps be the best answer I can come up with since StackOverflow answers do not age well, especially for the PySimpleGUI project which is ever-evolving.
The Demo Browser utility is made specifically to help answer questions like this. Of course, the documentation should also be used (PySimpleGUI.org).
The Demo Programs serve many purposes. One is to show specific techniques. The Demo Browser is a way for you to quickly and easily search, edit, and execute this code.
The attached screenshot is what I see when searching for "shrink" using this tool (as of Aug 2022...). The first item answers this specific issue. Maybe I got lucky? "I would rather be lucky than good". The docs and tools provided with PySimpleGUI are the best place to turn for questions rather than SO. They'll be the most accurate, the most up to date, and are part of the project itself.
Good lucky Jedi!
what solved it for me, Thanks to #Mike from PSG,
is using:
sg.Pin(,shrink=True)
as shown in docs: https://www.pysimplegui.org/en/latest/call%20reference/#layout-helper-funcs
Hi all so basically I’m new to python and using pyautogui
I have been able to do basic operations like moving the mouse to the specified coordinates
The problem
Pyautogui clicks on the button which is (Start learning Java now >>) on
w3 school website.
I want it to click and move to the next page but apparently, it clicks but there is no action.
in the ideal situation, it should click the button and move on to the next page but it doesn't do it although I see the click
Since I'm new to Python in general coming from a non-coding background.
I would love to have some opinion on this and a possible workaround
My operating system is Windows and my laptop is a Lenovo yoga s730
Below is the script/code Im using:
import pyautogui
import webbrowser
import time
webbrowser.open("https://www.w3schools.com/java/")
pyautogui.tripleClick(x = 700, y= 783)
Thanks
I guess you're trying to perform the click before the page has fully loaded, your code is quite correct, try this I hope it helps:
import pyautogui
import webbrowser
import time
webbrowser.open("https://www.w3schools.com/java/")
time.sleep(5) # wait for the page to load
pyautogui.click(700, 783)
if you would like to use some clever workaround the loading time use something like the concept refered to in this answer https://stackoverflow.com/a/56672841/13770671
pyautogui's click method's issue:
I am running the script from Spyder, if I click anything on Spyder's window the click works fine.
If I execute a script to open Outlook, then click on anything, the click does not happen. Although I am able to use the "moveTo" functionality properly.
Things I have tried as suggested by doing google search:
pyautogui.click()
pyautogui.click()
OS : mac os high sierra
Note:
In order to reach any located image I have to do coordinates/2, as it is a Retina 2x display.
Any workaround or any help will be greatly appreciated.
To anyone who might stumble into the same issue on a Mac, I was able to get it working by using a workaround that is using the pynput library.
Code:
import pyautogui
from pynput.mouse import Button, Controller
mouse = Controller()
pyautogui.moveTo(x,y)
mouse.click(Button.left)
OS X Mojave, the following works for me:
pyautogui.moveTo(pos)
pyautogui.dragTo(button='left')
pyautogui.click() throws an attribute error but pyautogui.dragTo() works instead.
I just found out that in mac setting, I did not check the tip in front of PyCharm in privacy setting. After doing that, my pyautogui.click() function works.
I was also facing same issue, Here is what I tried :
Just add one more line pyautogui.dragTo() to focus on that particular selected area:
pyautogui.moveTo(990,28)
pyautogui.dragTo()
pyautogui.click()
I am using the pyautogui library, and it was working...and for some reason after I reinstalled my Ubuntu system I dont manage to use it.
I show below the code, just several lines copied from the Docs.
The only information about the error, showed in picture I found is this link mentioning "BadValue error", which I dont really understand (100 and 200 are inside range)
https://tronche.com/gui/x/xlib/event-handling/protocol-errors/default-handlers.html
import pyautogui
pyautogui.moveTo(100, 200)
pyautogui.position()
pyautogui.click()
pyautogui.click(100, 200)
Thanks a lot!
Picture with code and execution error
Well, I don't know why this error is coming, because in PyCharm, it works perfectly. But I noticed that the first 3 lines are unnecessary so try this code and tell me if it helps:
from pyautogui import *
click(100, 200)
I am trying to send a couple basic text commands to a flash program running in Firefox on Windows 7, but I am unable to get pywinauto working for me.
Right now, I have just been able to accomplish the very basic task of connecting to Firefox plugin-container by directing it to the path using the following code:
from pywinauto import application
app = application.Application()
app.connect_(path = r"c:\Program Files (x86)\Mozilla Firefox\plugin-container.exe")
The next step seems to be something to the effect of:
app.plugin-container.Edit.TypeKeys('Text')
However, I can't reference the plugin-container window using '.plugin-container', or any combination of those words. I have tried adding a title variable to the connect_() function and I have tried everything I can think of to find out how to type the command.
The example I am basing this off of is the notepad sample:
from pywinauto import application
app.start_(ur"notepad.exe")
app.Notepad.Edit.TypeKeys(u"{END}{ENTER}SendText d\xf6\xe9s "
u"s\xfcpp\xf4rt \xe0cce\xf1ted characters!!!", with_spaces = True)
It doesn't matter to me if I use pywinauto or Firefox. If it is any easier to do this using a different module or Internet Explorer, I'm on board for whatever accomplishes the task. I am using Python version 2.7.2 and would prefer it over any version changes.
Any help at all is appreciated. I am pretty lost in all this.
As the author of pywinauto - I think you are going to have a hard time. pywinauto only really helps with standard windows controls, and I don't think that flash controls are implemented as standard windows controls (Buttons, Edit boxes, etc).
OFf the top of my head - I would think Sikuli may be a better starting point (http://sikuli.org/).
Another option may be 'http://code.google.com/p/flash-selenium/' - I just googled for "automating flash input" - and it turned up in one of the first articles I clicked.
Thanks for trying pywinauto - I just don't think it is best suited for Flash automation.