#๐Ÿ”’ why dose moving the mouse through code not move the mouse in game? and how do I fix this?

49 messages ยท Page 1 of 1 (latest)

cyan roostBOT
#

@tranquil sentinel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tranquil sentinel
#

and heres the code:
import keyboard._mouse_tests
import pytchat #https://pypi.org/project/pytchat/
import time
import keyboard #https://pypi.org/project/keyboard/
import mouse #https://pypi.org/project/mouse/
from screeninfo import get_monitors #https://pypi.org/project/screeninfo/

#example:
#https://www.youtube.com/live/XtagNPBFPZw
#===================
#URL = "XtagNPBFPZw"

running = True

screen_size = tuple

URL = "XtagNPBFPZw"

#commands

walking commands

WALK_COMMAND = "walk"
WALK_BACK_COMMAND = "back"
SPRINT_COMMAND = "sprint"

turning commands

TURN_LEFT_COMMAND = "left"
TURN_RIGHT_COMMAND = "right"

#initialising
chat = pytchat.create(video_id=URL)

for m in get_monitors():#prints every monitor
print(str(m))
if m.is_primary == True:
screen_size = [m.width, m.height]

#if running and livestream is going
while running:
while chat.is_alive():
current_mouse_position = mouse.get_position()

c = chat message

    for c in chat.get().sync_items():
        print(f"{c.datetime} [{c.author.name}]- {c.message}")#prints time, auther, and message to the consol

walking commands

        if WALK_COMMAND.lower() in str(c.message).lower():#if "walk" is in message
            keyboard.press("w")
            time.sleep(2)
            keyboard.release("w")

        if WALK_BACK_COMMAND.lower() in str(c.message).lower():#if "walk" is in message
            keyboard.press("s")
            time.sleep(2)
            keyboard.release("s")

        if SPRINT_COMMAND.lower() in str(c.message).lower():#if "walk" is in message
            keyboard.press("shift")

turning commands

        if TURN_LEFT_COMMAND.lower() in str(c.message).lower():#if "walk" is in message
            mouse.move(screen_size[0] / 2 ,screen_size[1] / 2, True, 0)
            mouse.move(screen_size[0] / 4 ,0, False, 2)
strange grotto
#

Does walk work?

tranquil sentinel
#

it just presses down the w key for about 2 seconds same thing for back but it just holds the s key (it dose work)

strange grotto
#

Do you know the screen size and screen width? If you do try replacing screen_size[0] and screen_size[1] with the actual values

#

Also I found this function

mouse.move_relative(dx, dy)

#

Like try instead of mouse.move(screen_size[0] / 2 ,screen_size[1] / 2, True, 0) and mouse.move(screen_size[0] / 4 ,0, False, 2)

Try mouse.move_relative(-10, 0)

#

@tranquil sentinel

tranquil sentinel
#

sorry my internet went out for a bit

#

I will try tha

#

t

strange grotto
#

K, tell me if it works

tranquil sentinel
#

mouse.move_relative dosent seem to exist in the mouse module

strange grotto
#

so for the mouse.move functions, what are the parameters?

tranquil sentinel
#

and replaceing the variables with acual values dose nuthing

#

*nuthing defferent

hollow shoal
#

!paste

cyan roostBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

hollow shoal
#

!code

cyan roostBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

strange grotto
#

Can you screen shot, when you do mouse.move(,) a box with the documentation should pop up, screenshot that

tranquil sentinel
#

(x value , y value, absolute, duration)

#

x and y are any, duration is intager, and absolute is bool

strange grotto
#

try mouse.move(10, 0)

#

I dont think you need the other two parameters

tranquil sentinel
#

that dident work

strange grotto
#

Whats the error?

tranquil sentinel
#

the mose dose move so there is no error it just dosent move the cammera ingame

strange grotto
#

Wait so the mouse moves but the camera in game doesnt move?

tranquil sentinel
#

yea

strange grotto
#

umm

#

I think the mouse lib isnt the best idea then

tranquil sentinel
#

what should I use then?

strange grotto
#

I looked on google, mouse is the best option but if it still doesnt work

#

its probably a thing with anticheat

#

If u really want to

#

U have to look into in game code

#

cause anti cheat

#

sry

#

prob find a online tutorial, sry

tranquil sentinel
#

ok I will try other games to see if it is the anticheat

#

ok thanks

tranquil sentinel
strange grotto
#

if u want i can help u look into this later

tranquil sentinel
#

no it works now but thanks

cyan roostBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.