Coder Social home page Coder Social logo

pydirectinput's People

Contributors

cetteup avatar learncodebygaming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pydirectinput's Issues

Clicks not working in-game.

Whenever I click it doesn't work:

pydirectinput.click(1751,827,button="right)

and what this does in the game I'm playing, it's basically cancel for example auto-pathing, but when I right click using that line of code, it's hold so it rotates de camerca, and I tried clicking again with Python to cancel the camera moving, but it gets stuck, it probably has a way to detect outside inputs. (the keyboard seems to work just fine, but the mouse is troubling)

And witht the left click it's the same:

pydirectinput.click(1751,827)

And by click 1 time the character moves to a certain place, but instead of doing it, since it's holding down, it starts "running mode".

So you can already imagine my problem, I want to click an item, and instead of doing that, the character starts running, that would normally be canceled by right-clicking, but since it's also bad, it now starts moving the camera and there's no way out of there unless I intervene. Any ideas? The game is pretty old around 2007, so I don't know what else info I should give you, other than the fact that it uses DirectX 9, so yeah, pretty old.

How to make the mouse move slowly?

I found that when using pydirectinput to move the mouse, it almost instantaneously moved to the specified coordinates, which made some games not work properly when suddenly given this command and might move to other strange coordinates.
I can add duration to pyautogui to make mouse movement slower and softer, but pyautogui is not supported
So do I have any parameters that make the mouse move slowly to the target?

Doesn't seem to function as expected

When I want to relatively move. using move or moveRel with parameters (0, 1) in CS:GO. The player makes a 180 and looking at the ground. Did I do anything wrong?

Can you add some new functions?

Can you add some new functions?
Like Pyautogui's locateOnScreen function and center function:
xy = pyautogui.locateOnScreen('test.png') center= pyautogui.center(xy) pyautogui.click(center)

why only perform once

I used moveTo in the while{},but it only perform once then it not work,other normal,this code is for a game

Write function slow, interval not working

Copying this issue report from YouTube by HostGrady: "I have noticed the "write" function is quite slow in comparison to autogui's version. On top of that the interval function doesnt really function at all. Idk if this is known but it would be cool to communicate via a bot using this version of pyautogui"

keyDown/Up not working for Page Up/Down

With windows applications, e.g. Google Chrome, if I use

pydirectinput.keyDown("pageup")

(and also keyUp) then the actual typed key is '3' (or '9' for pagedown), i.e. the extended scan code (?) attribute seem to be ignored. Briefly scanning how cursor keys are handled, there seems to be a need for similar checking for extended keycodes.

Note: I tested this also with cursor up/down and they work fine.

I't possible that other extended keys don't work as well.

Doubleclick not working proprely in League of Legends

Hi, I am currently working to create a league of legends simple bot for custom games and I am stuck at the purchase of items while the double click is not working as intended because of the delay I guess. I don't know where I should modify the delay in the files so I am bringing so may found the answer.

Numpad not working

For some reason trying to simulate numpad inputs doesnt work for me.

import time, pydirectinput
try:
while True:
time.sleep(1)
pydirectinput.press('numpad5')
time.sleep(1)
pydirectinput.press('pageup')

except KeyboardInterrupt:
quit

I also tried using 'num5' and it still doesn't work. Also yes numpad is on

Breaks after a screenshot

Running a screenshot using something like mss (https://github.com/BoboTiG/python-mss)

with mss.mss() as sct:
     return sct.grab(region)

will offset all the x and ycoordinates for things such as moveTo(x,y) to a different spot on the monitor, and it remains that way until the .py file is done.

The size() always returns 3840x2160 correctly, but its position is initally squashing screensize somehow, and then reverting to the actual dimensions after I screenshot. Here is an example of using position() before and after:

Out[]:
  pos = (2559, 1439)
  took a screenshot
  pos = (3839, 2159)

By taking an arbitrary screenshot to set the offset before calling input, I can circumvent this issue, but I am curious if there is a way to prevent this from occurring.

Arrow keys not working properly

I tried to simulate arrow key presses for a DirectX 11 game but only 'up' is working as expected. 'right', 'left' and 'down' are mapped to different keys or don't work.

I think it needs to add a parameter, the window handle

Is it possible to add an argument that can send instructions to a process with a known window handle?For now, it only works with the very front window. So it would be nice if it could increase the window handle parameters.

Can't keyDown when UAC is enabled

Im trying to register keyboard events using keyDown method but it never works with a program that is running with admin privileges.

pydirectinput.keyDown(button)
sleep(random.uniform(0.3, 1))
pydirectinput.keyUp(button)

It's funny because I can move the cursor and click on the screen using pyautogui.mouseDown

pydirectinput.mouseDown(button=button)
sleep(random.uniform(0.3, 1))
pydirectinput.mouseUp(button=button)

I already tried Pywinauto, Pyautogui, Pynput, Autopy and I'm using Pyuac to grant admin privileges with powershell running with admin but nothing works.

OBS: If I disable my Windows UAC the script works.

not working in Linux Arch

This python library is not working for me in Arch Linux. What is this windll dependency ?

source: simple.py

import pyautogui
import pydirectinput
pydirectinput.moveTo(100, 150) # Move the mouse to the x, y coordinates 100, 150.

I get this error on running it.

[zeekus@archlinux ~]$ python3 simple.py 
Traceback (most recent call last):
  File "/home/zeekus/simple.py", line 2, in <module>
    import pydirectinput
  File "/home/zeekus/.local/lib/python3.10/site-packages/pydirectinput/__init__.py", line 6, in <module>
    SendInput = ctypes.windll.user32.SendInput
AttributeError: module 'ctypes' has no attribute 'windll'

Mouse movement not working

'''
import pydirectinput
while True:
pydirectinput.move(100, 0)
print("hek")
'''
The mouse dosent move

Automating antivirus scan initiation ?

I am trying to automate my AVG virus scan through Pydirectinput. I am able to bring the mouse up to the button but the mouse click does not get registered. Anyway, this can be done ?

click function not working

I want to click the keys on the "on-screen keyboard" provided by windows and I am currently using windows 11.

I have used these command.......

py.moveTo(int(clocX), int(clocY))

if clicked == True:
py.click()

Here clocX and clocY are the co-ordinates value given by the user, when the user wants to click the py.click() function it will work.
Only on the "on-screen keyboard" its not working, else where for opening any app or file its working perfectly fine.

Please help....

Does not work in Black Desert Online

Here is my code

import time
import pydirectinput as pdi


time.sleep(3)
pdi.keyDown('w')
pdi.keyDown('d')
time.sleep(5)

pdi.keyUp('w')
pdi.keyUp('d')

And there is no any reponse in game.

Input Detection as artificial

Is it possible for directinputs themselves sent through code to be detected as artificial by the target programs? Ofcourse any automation would involve having randomized intervals between actions to make the process seem less artificial but curious if the inputs themselves can be distinguished. This seems to be the case with "SendInput" actions, being detected by game services.

Slow press even with _pause = False

Hi!
First of all, thanks for working to make this library happen!

I'm currently implementing a bot that uses a NN to predict which key should be pressed and then I input it with the press() function. My problem is that when I'm not doing any input I can get about 60-70 fps (measured withing the mss loop for screen recording) but when using press() it drops down to about 3 fps and 4 fps if I use _pause=False.

I tryed using only the functions:

def PressKey(hexKeyCode):
    extra = ctypes.c_ulong(0)
    ii_ = Input_I()
    ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008, 0, ctypes.pointer(extra) )
    x = Input( ctypes.c_ulong(1), ii_ )
    ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))

def ReleaseKey(hexKeyCode):
    extra = ctypes.c_ulong(0)
    ii_ = Input_I()
    ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008 | 0x0002, 0, ctypes.pointer(extra) )
    x = Input( ctypes.c_ulong(1), ii_ )
    ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))

And I recover the 60 fps but it does miss some inputs randomly.
Are there any other ways of making pydirectinput faster?

Thanks a lot in advance!

Delay (I have also posted this on the pyautogui repo)

I'm trying to make a bot for the Roblox game Funky Friday. It's a rhythm game based off Friday Night Funkin.

fnf

It's not registering all notes, only pressing one note at a time.
Here is my code:

import pyautogui
import pydirectinput

leftColor = (194, 75, 153)
downColor = (0, 255, 255)
upColor = (18, 250, 5)
rightColor = (249, 57, 63)

leftX = 731
#leftY = 189
downX = 888
#downY = 199
upX = 1024
#upY = 191
rightX = 1177
#rightY = 183

y = 189

leftKey = 'left'
downKey = 'down'
upKey = 'up'
rightKey = 'right'

while True:
	if pyautogui.pixelMatchesColor(leftX, y, (leftColor), tolerance = 50): #i also made the tolerance at 80 at one point
		print("LEFT")
		pydirectinput.press(leftKey)
	elif pyautogui.pixelMatchesColor(downX, y, (downColor), tolerance = 50):
		print("DOWN")
		pydirectinput.press(downKey)
	elif pyautogui.pixelMatchesColor(upX, y, (upColor), tolerance = 50):
		print("UP")
		pydirectinput.press(upKey)
	elif pyautogui.pixelMatchesColor(rightX, y, (rightColor), tolerance = 50):
		print("RIGHT")
		pydirectinput.press(rightKey)

Windows 10 x86_64

Mouse click so long

The problem is that after calling the function, the program seems to heal by pressing the mouse button by 0.01, which is why the logic in the application breaks down. How can I do a faster pressing of the mouse button?
i use - pydirectinput.click()

DirectInput does not work too, what should i do?

I made a basic auto clicker to automate a process at my job but pydirectinput and pyautogui is not working with this program. Both is working normally at other programs but its just not working with what I need. It is a custom made program for company which we use to control data, it is pretty basic thing.

I tried both library but didn't work, what should I do?

mouse moving with 1s pausing

I was using moveTo() function and I notice that, after moving to destination, there will be a short pause about 1 s and you can not do any operation in that 1 s

does this still work cross platform

hi

does this still work cross platform? i tried using PyAutoGUI and pynput in an attempt to make my program cross platform but i ran into issues on windows with direct input so started using a custom ctypes basd input method (basically the same as yours but with only key down and up because that is all i needed). i would like to still make this project cross platform but have since completely refactor my code to the new method so it is hard to test (i'm not great at regular commits).

so will your library work on in a non windows environment? i.e. will it pass through to PyAutoGUI if it is run on unix?

also could you not just have it pass through all the functions of PyAutoGUI that do work on windows so users only need to import your library? like a wrapper that overrides the parts that dont work on windows?

moveto function not working with valorant

Hi, I tried this library today with valorant but both pyautogui and pydirectinput isn't working but, the clicks are working fine in both.

import pydirectinput as pydx
pydx.moveTo(x,y)

Cannot type "/" when using the .type command

I've been trying to type something with "/" but it doesn't work. I've tried multiple fixes but they have all failed. I have seen other people just type the slash without anything special besides the .type command. Please help!

Mouse Movement Not Working

I am trying to use python to create some nice and handy Minecraft scripts in order to ally coding and gaming.

I have been using pyautogui and pydirectinput for a decent amount of time and have always tried to find ways around the issue setting up stuff In-Game rather than coding it.

The mouse movements functions like move() and moveTo() do not work at all within the recent versions of Minecraft (after 1.8.9 I believe). I have tried looking in the modules themselves but I'm not experienced enough to tweak those and I do not know where to look for alternative ways to send mouse inputs.

If anyone would be kind enough to guide me on how to do it (or offer their solution if someone worked on it already).

EDIT: Forgot to look at the closed issues, there was one addressing the exact same topic, unfortunately the solution there does not work for me.

Thank you in advance for all advices,
Xeomia

Can't do 360s in game. Hits the border and stops spinning

The left Fortnite game border is located at x position 1921. When the mouse has come to that position the rotation just stops.
When I use my normal mouse I can continue spinning, even is the x position also is 1920.

with pydirectinput
https://user-images.githubusercontent.com/42636768/103135357-0e227c80-46b8-11eb-8cce-5da913315780.mp4

with my mouse
https://user-images.githubusercontent.com/42636768/103135363-21354c80-46b8-11eb-9a7d-1e8c7e0dd08b.mp4

`import mouse
import time
import pydirectinput
import pyautogui

pydirectinput.PAUSE = 0

while True:
move_amount = (-100, 0)
pydirectinput.move(move_amount[0], move_amount[1])
print(pydirectinput.position())
time.sleep(1)

`

MEDIA_PLAY_PAUSE Key

Is there a way to use keys like "MEDIA_PLAY_PAUSE"? I tried to implement the scancode of this key (0x122), but somehow only hex values with 2 digits are read.

Occasional input omit

I am using pydirectinput for macros for fighting games.
It has been great with the combos, but I have noticed that pydirectinput can sometimes omit some of the inputs, even some single ones such as

press("enter")
time.sleep(1)
press("u")
time.sleep(1)
press("u")
time.sleep(4)
press("s")
time.sleep(1)
press("u")

some of these "presses" are omitted now and then.
Thanks for the wonderful package, though.

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.