i am making a autoclicker and i face a problem:
mouse = Controller() while true: if win32api.GetAsyncKey(0x01)&0x8000 > 0: mouse.click(Button.left)
when i hold left click it works but only click one time because it reset the mouse state. I would like to know how i can simulate a click without triggering getasynckey.
The autoclicker has to click when i hold left click.I tried pynput listener, pygame listener and pyautogui.leftclick() but none of these works.
thanks you.
Related
I'm just trying to simulate a mouse click every second but once the first click starts, the program just completely halts and I have no idea why
The program will continue if I press CTRL+C but then it halts again after it clicks:
import pyautogui
import time
while True:
time.sleep(1)
print("Clicking")
pyautogui.click()
And it doesn't matter which mouse library I use to simulate the click, it always halts. It should be clicking every second without interruption. What's wrong?
The only reason i think it does so is because it clicks at some place where it is not supposed to(by default the position is your current mouse pointer), so the pyautogui.click() takes 2 parameters x,y try specifying the the exact coordinate and it should work. To find the coordinates of a position place your mouse pointer there and run pyautogui.position().
So I'm developing a small game in Pyglet and I have across this weird behavior which I don't know how to solve. It seems like a Pyglet bug, but it's weird that I cannot find others users reporting this problem.
The problem is that after a key is pressed, if I left click right after the key press, the event is ignored. This is repeatable, always. What's funny is that if I right click, the event is always working fine. Only left click is the problem. Also on_mouse_motion() is blocked for 1 second after any key is pressed. If I don't press any keyboard keys, all mouse events work just fine.
I have tested this with Pyglet versions 1.3.0, 1.4.10 and 1.5.11 and all have the same behavior. I also tested this on 2 different computers and behavior is the same. I also tried with Vsync ON and OFF and with mouse exclusive to pyglet window. Using Windows 10 and Python 3.7.4-64b.
Here is a simple code to reproduce the problem, just press a key and then left click within 1 second:
import pyglet
window = pyglet.window.Window()
#window.event
def on_key_press(symbol, modifiers):
print('A key was pressed')
#window.event
def on_mouse_press(x, y, button, modifiers):
print('Mouse event')
pyglet.app.run()
EDIT: The problem is the Synaptics touchpad which is configured to disable the touchpad during typing on laptops.
It seems the problem is the Synaptics touchpad which is configured to disable the touchpad during typing on laptops:
https://superuser.com/questions/399341/touchpad-does-not-respond-when-i-am-holding-key-on-the-keyboard
I connected an external mouse to the laptop and the problem is gone.
I want to create a program that if the user pressed shift and button-1 (left click), a GUI will pop up.
However, I can only listen for key presses and mouse clicks separately using pynput. Is there a way to listen for those two things at the same time?
Here is the simple solution:
https://github.com/boppreh/mouse
https://github.com/boppreh/keyboard
import mouse
import keyboard
import time
while True:
if mouse.is_pressed(button='left') and keyboard.is_pressed('shift'):
print("Left mouse button and shift is pressed")
time.sleep(0.5)
Hi how can I detect my touch with touchframe?
The first time the mouse worked OK when I connected my frame, touched the cursor ran and clicked. But this code fragment event didn't work. Why? How can I change the code to detect the touch event?
def on_click(x,y,button,pressed):
print("mouse click")
playerOff()
listener.stop()
I have a Python 3.6.3 script that incorporates PyQt5. The GUI has a button that toggles play and pause of a video file. Pressing the spacebar also toggles play and pause. The button works fine all the time. The spacebar also works as intended, except at the very start of executing the script. I need to click some other event first (such as a button or slider bar) before the spacebar will correctly triggers the signal to pause or play the video. I want to start playing the video with the spacebar when the script starts up. Here is how I create the connections in the same __init__(self) function . As you can see, clicking on the button and pressing the spacebar both connect the signal to the same function (self.pauseVideo).
self.btnPause = QtWidgets.QPushButton(self.centralwidget)
self.btnPause.clicked.connect(self.pauseVideo)
self.spacebar = QShortcut(QKeySequence(Qt.Key_Space), self)
self.spacebar.activated.connect(self.pauseVideo)
Suggestions on how to get the spacebar to trigger the signal when the script first starts?
After a lot more searching, reassigning keyboard shortcuts (without success), etc., I found this post PyQt widget keyboard focus. I inserted
self.setFocusPolicy(Qt.StrongFocus)
into __init__(self) and it seemed to solve my problem! Now I'm just hoping it doesn't cause other issues.