Need to mention that im new with Python and i decided to create a bot for multiplayer game, to autobuy items on auctionhouse, using opencv and pyautogui, so far everything was going pretty well, the cursor was heading to the right point on the screen (reload auction), but
pyautogui.click(clicks=1) isnt working in game window.
IDE (PyCharm) is running with admin rights, googled alot about the topic, but nothing works so far. Will be pleased if anyone could help me, this is my first big project i really want to work with, so hopefully you guys can help me :D
additional info: game uses Battle Eye anticheat, engine Java (probably... Game is called Stalcraft, you can find it on steam, looks like its something Minecraft-based, but im not sure about it)
OS: Win 10 x64
Python:3.11
What i tried:
pyautogui library (tried pyautogui.MoveTo(x,y) and the method with pyautogui.locateCenterOnScreen("whatever.png",confidence=0.85 Need to mention that first method works only in IDE, the second one based on img recognition also works with browser. Tried this in other apps, but no results. It's just hovering cursor on the right place, but no clicks at all)
pydirectinput library
Here's what i got so far
import cv2
import random
import pyautogui
from time import sleep
import imutils
import numpy as np
import pydirectinput
pyautogui.FAILSAFE=True
rng=random.uniform(0.87, 1.3)
sleep(5)
pyautogui.size()
print(pyautogui.size())
pyautogui.position()
print(pyautogui.position())
pyautogui.moveTo(x=1344, y=342, duration=rng)
pyautogui.click(1344, 342, clicks=5)```
This might be very silly. But I had no luck with .click. In my sample I used .moveTo as you did, but then .mouseDown() and .mouseUp() to simulate a click. Also sometimes it required a delay between the two. I wonder if that combo would help instead?
pyautogui.mouseDown()
sleep(1)
pyautogui.mouseUp()
Related
I am attempting to get my script to open up a game through steam and then start a world. This all works fine up until the part where I need to navigate the game. I'm assuming that the modules that let you control the mouse just move to points rather than actually moving the mouse which the game doesn't pick up. The game only becomes responsive when I myself move the mouse around IRL.
I've tried using pyautogui, mouse, pynput, and a couple of more but have had no luck. The game doesn't respond until I intervene. I'd love any help ya'll could give me. Thanks.
Here's some of my code, if it helps.
import pyautogui
import time
def openWorld():
#pyautogui.moveTo(230, 530, 1)
pyautogui.click(x=230, y=530)
Well the problem is rather easy to understand. When playing a game, sometimes I need to use autoclicker. So in order to be able to watch some videos on youtube I need to use another monitor & autoclicker.
I wanted to create such autoclicker that would let me send any keyboard/mouse actions to specific window or even process (if it's possible). However I have no idea where to start?
There is a python library called pyautogui you can us it to automate stuff.
Installation
pip install pyautogui
your code should look simething like this
import time
import pyautogui
for ctr in range(10):
pyautogui.click()
time.sleep(1000)
Adjust the time based on requirement and refer this for more info about the library
Better to use power automate to make things simple
I have a simple screenshot in the code, how to show the cursor in the final image output? I read that it seems not possibile, but Python is a professional programming language it seems strange that isn't really possible, so please can you explain me how to show the cursor of the mouse in the screenshot? Maybe using an other method for the screenshow beside Pyautogui, thanks!
import pyautogui
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'C:\Users\quaranta\Desktop\Orologio\file name.png')
In one of my scripts, which used to work for about 2 months, I used the pyautogui module and the script remained unchanged. For the past 2 days, I have been trying to script something else to detect objects on my screen but it does not detect it.
Code:
import pyautogui
pyautogui.locateCenterOnScreen('Image.png')
In the above code, when I should get some output, I get None.
Any idea what I should do?
Thanks.
Please include the code you have tried so far along with the question. how to ask questions?
i want that upon opening my N73's camera cover,the camera software keeps working as usual,but that it is blocked by a black screen covering the whole screen so that it appears that the camera is not working... I know my requirement is weired but i need this.. ;)
Can anyone guide me to write a python script that does exactly this... i searched a lot over net for any existing apps but couldnot find one..
Thanks for helping..
I'm rather sceptical whether this can be achieved with PyS60. First of all, AFAIK for PyS60 program you'd need to start the interpreter environment first, autostarting when camera starts probably won't be possible.
Also, opening the camera cover probably does not have any callback so you won't be able to detect it from python however, you could try something like this presented in PyS60 1.4.5 doc (http://downloads.sourceforge.net/project/pys60/pys60/1.4.5/PythonForS60_1_4_5_doc.pdf):
>>> import appuifw
>>> import camera
>>> def cb(im):
... appuifw.app.body.blit(im)
...
>>> import graphics
>>> appuifw.app.body=appuifw.Canvas()
>>> camera.start_finder(cb)
Instead of blitting im you could just blit a black screen and store im. Or something. But seriously, this sounds like some very bad prank...