#Need help with a thing pls

380 messages · Page 1 of 1 (latest)

crisp lance
#

I think, it will only take a few minutes, would make me really happy, and would be relatively easy for you, and if we believe chatgpt, the script also is only like 50 lines.
Here is what I am currently trying, and failing to do, and therefore am asking for help:

I´m playing Rise of Kingdom (you probably know it from its "bad" ads), basicly an open world strategy game, where everybody has his own city, wich is on the open map you can move around, etc.
Now, I´ll not go into the detail why I need it and explain the whole game, but there often are situations, where you have to find people that do bad things on the map.
So my Idea was, to make a bot, wich just moves the camera over the whole map (from the top right corner move down, then a bit to the right, then up again, etc.,etc.) and just stop / notify me when it sees the correct name / word on the screen.
And honestly, I don´t really see why that should be so hard to program, but my programming skills are very very limited.

So first I´d like to know, is it possible, then is it hard, and then ofc, would you be so kind to do it for me / give me a name, that may be bored enough to do it for me?
Or maybe explain to me, how to do it?

crisp meteor
#

Thanks for your question :clap:, if someone gives you an answer it would be great if you thanked them with a :white_check_mark: in response. This response will earn you both points for special roles on this server.

#

@crisp lance, you just advanced to Active!! 🎉🎉🎉

crisp lance
#

Here is what chatgpt told me, but tbh I dont really get it, since like already said, my programmin skills are pretty limited.

#

"
import pyautogui
import cv2
import numpy as np
import time

def find_name_on_screen(name_image_path):
screenshot = pyautogui.screenshot()
screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR)
name_image = cv2.imread(name_image_path)

result = cv2.matchTemplate(screenshot, name_image, cv2.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where(result >= threshold)

for pt in zip(*loc[::-1]):
    return pt  # Return the location of the found name
return None

def search_map(name_image_path, step_count=10, step_duration=0.5):
for _ in range(step_count):
for _ in range(step_count):
pyautogui.press('right') # Move the screen to the right
time.sleep(step_duration)

        location = find_name_on_screen(name_image_path)  # Search for the name
        if location:
            print(f"Name found at position: {location}")
            return location  # Stop if the name is found

    for _ in range(step_count):
        pyautogui.press('left')  # Move the screen back to the left
        time.sleep(step_duration)
    pyautogui.press('down')  # Move the screen down
    time.sleep(step_duration)

print("Name not found.")
return None

name_image_path = 'name_image.png' # Path to the image file of the name to search for

location = search_map(name_image_path)
if location:
print(f"Name found at position: {location}")
else:
print("Name not found.")
"

crisp meteor
crisp lance
#

😭

crisp meteor
#
import pyautogui
import cv2
import numpy as np
import time

def find_name_on_screen(name_image_path):
    screenshot = pyautogui.screenshot()
    screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR)
    name_image = cv2.imread(name_image_path)
    
    result = cv2.matchTemplate(screenshot, name_image, cv2.TM_CCOEFF_NORMED)
    threshold = 0.8
    loc = np.where(result >= threshold)
    
    for pt in zip(*loc[::-1]):
        return pt  # Return the location of the found name
    return None

def search_map(name_image_path, step_count=10, step_duration=0.5):
    for _ in range(step_count):
        for _ in range(step_count):
            pyautogui.press('right')  # Move the screen to the right
            time.sleep(step_duration)
            
            location = find_name_on_screen(name_image_path)  # Search for the name
            if location:
                print(f"Name found at position: {location}")
                return location  # Stop if the name is found

        for _ in range(step_count):
            pyautogui.press('left')  # Move the screen back to the left
            time.sleep(step_duration)
        pyautogui.press('down')  # Move the screen down
        time.sleep(step_duration)

    print("Name not found.")
    return None

name_image_path = 'name_image.png'  # Path to the image file of the name to search for

location = search_map(name_image_path)
if location:
    print(f"Name found at position: {location}")
else:
    print("Name not found.")
crisp lance
#

Huh?
That seems awfully simple

crisp meteor
#

thats the chatgpt code formated

#

i am just reading it

crisp lance
#

Ah ok ._.

crisp meteor
#

@crisp lance how do you move the camera in that game?

crisp lance
#

Either by dragging the cursor, or by ig the easier variation, by just using the arrow keys

crisp meteor
#

mb

#

@crisp meteor _0bytes's Question:

gen a script that moves through a game screen using arrow keys randomly and checks for a piece of text in python until it finds it

Certainly! Below is a simple Python script using the pyautogui library for automation and pytesseract for Optical Character Recognition (OCR). This script moves around randomly using the arrow keys and checks for a specified piece of text until it finds it.

import pyautogui
import pytesseract
from PIL import ImageGrab
import random
import time

# Configuration for pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'  # Path to tesseract executable
TARGET_TEXT = "Your target text"  # Replace with the text you are searching for
CHECK_INTERVAL = 5  # Seconds between each screen check
SEARCH_DURATION = 3600  # The maximum duration to run the search (in seconds)

def is_text_present(screen):
    """Check if the target text is present in the given screen image."""
    text = pytesseract.image_to_string(screen)
    return TARGET_TEXT in text

def move_randomly():
    """Move randomly using the arrow keys."""
    directions = [pyautogui.press('up'),
                  pyautogui.press('down'),
                  pyautogui.press('left'),
                  pyautogui.press('right')]
    random.choice(directions)

def search_for_text(timeout=SEARCH_DURATION):
    """Search for the text on the screen, moving randomly until the text is found or timeout."""
    start_time = time.time()
    while True:
        # Take a screenshot
        screen = ImageGrab.grab()
        
        # Check if the target text is in the screenshot
        if is_text_present(screen):
            print("Text found!")
            break
        
        # Move randomly
        move_randomly()
        
        # Check if the timeout has been reached
        if time.time() - start_time > timeout:
            print("Text not found within the timeout duration.")
#

break

    # Wait for a while before checking again
    time.sleep(CHECK_INTERVAL)

Start the search

search_for_text()


Before running the script, make sure you have the required Python packages installed:

1. Install `pyautogui` and `Pillow` for controlling the keyboard and capturing the screen:
   ```sh
   pip install pyautogui pillow
  1. Install pytesseract and Tesseract-OCR engine which is used for text detection from images:

    pip install pytesseract
    
  2. Download and install Tesseract from https://github.com/UB-Mannheim/tesseract/wiki. Then, put the correct path of the tesseract.exe in the script for pytesseract.pytesseract.tesseract_cmd.

Make sure to run the script with appropriate permissions to allow controlling the keyboard and screen. On some systems, you may need to run the script as an administrator or with sudo to permit the required system interactions.

crisp lance
#

Not randomly 👀
It's a square map, so ideally just in like a wave pattern (Move up, move right a bit , move down, move right a bit, move up, etc.)

crisp meteor
#

how big is the map

#

@crisp meteor _0bytes's Question:

can you say the code again didnt hear it

Certainly! Below is the Python script again:

import pyautogui
import pytesseract
from PIL import ImageGrab
import random
import time

# Configure pytesseract path to your installation
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'  # Windows example
# pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'  # Linux example
# pytesseract.pytesseract.tesseract_cmd = '/usr/local/bin/tesseract'  # macOS example

TARGET_TEXT = "Your target text"  # Replace with the text you're looking for
CHECK_INTERVAL = 5  # Seconds between each screen check
SEARCH_DURATION = 3600  # The maximum duration to search (in seconds)

def is_text_present(screen):
    """Check if the target text is present in the given screen image."""
    text = pytesseract.image_to_string(screen)
    return TARGET_text in text

def move_randomly():
    """Move randomly using the arrow keys."""
    move_keys = ['up', 'down', 'left', 'right']
    pyautogui.press(random.choice(move_keys))

def search_for_text(timeout=SEARCH_DURATION):
    """Search for the text on the screen, moving randomly until the text is found or timeout."""
    start_time = time.time()
    while True:
        # Grab the screen
        screen = ImageGrab.grab()

        # Check for the text on the screen
        if is_text_present(screen):
            print("Text found!")
            break

        # Move randomly
        move_randomly()

        # Break if the timeout is reached
        if time.time() - start_time > timeout:
            print("Text not found within the timeout duration.")
            break

        # Wait a bit before trying again
        time.sleep(CHECK_INTERVAL)

# Start the search process
search_for_text()

Please remember to replace "Your target text" with the actual text string you're looking for, and ensure the correct path to the Tesseract executable is set in t

#

he pytesseract.pytesseract.tesseract_cmd according to your system's installation. You'll need to have the Python libraries pyautogui, pillow, and pytesseract installed, as well as the Tesseract OCR engine itself.

crisp lance
crisp meteor
#

and how much does the camera covers

crisp lance
#

You can scroll in and out

#

want me to show you real quick?

crisp meteor
#

@crisp lance try this script also install this

#
   pip install pyautogui pillow
  1. Install pytesseract and Tesseract-OCR engine which is used for text detection from images:
  pip install pytesseract
  1. Download and install Tesseract from https://github.com/UB-Mannheim/tesseract/wiki. Then, put the correct path of the tesseract.exe in the script for pytesseract.pytesseract.tesseract_cmd.
crisp lance
#

Now the ultimate noob question, wich will probably make you cry:
Where do I put that ._. Like I´d put it into PyCharm, but then I wouldnt have an exe file

crisp lance
#

I did / am doing

#

Now?

crisp meteor
#

install using pip and run

crisp lance
#

Finished installing

crisp meteor
#

@crisp lance pip install pytesseract

#

and

crisp lance
crisp meteor
#

pip install pyautogui pillow @crisp lance

crisp meteor
#

you cant use pip?

#

wait let me search

crisp lance
crisp meteor
#

after finishing

#

just run the script

#

and put the target test

crisp lance
crisp meteor
#

ignore it

#

unless

#

there is a problem later on

crisp lance
#

Literally whole fk script says its not working 💀

crisp meteor
#

personally i would just save it for later but just ignore it completely

crisp meteor
#

put the script in pycharm

crisp lance
#

No module named pyautogui

crisp meteor
crisp lance
#

yes

#

Or do I have to do that in PyCharm again?

crisp lance
#

Or this is right, right?

crisp meteor
#

maybe pycharm has some sort of environments

crisp lance
#

Should I just use VsCode?

crisp meteor
crisp lance
#

Ye, it aint there

crisp meteor
#

PyAutoGUI

#

above

crisp lance
#

nvm its there

#

Fixed the spelling now, still not found

crisp meteor
#

keep it

#

pyautogui

#

also

#

install it from there

#

not find it

#

you just searched found and didn't click!

crisp lance
#

💀

#

ok works now

#

Ill do it with the others, 1 sec

crisp meteor
#

i like coffee with milk

#

milk with coffee

crisp lance
#

this one?

#

Or is it another one, and I gotta install that PIL thing?

crisp meteor
#

from means from

#

PIL.ImageGrab

#

that is also a thing

crisp lance
crisp meteor
crisp lance
#

PIL = pillow?

crisp meteor
#

mb true

crisp lance
#

You sure the used link is right?

crisp meteor
#

do you remember the install path

#

checkout C:\Program Files (x86) instead it may get the same file

#

wait

crisp meteor
#

mb

crisp meteor
#

read the scrip

#

t

#

few lnes

#

aftearfr

#

imports

crisp lance
#

ah ye

crisp meteor
#

i hate you

crisp lance
#

ik 😭

crisp lance
crisp lance
#

I´d go eat something real quick :)

#

(I love you, for not giving up on me, even with my incompetence)

crisp meteor
crisp meteor
#

try this

#

wait

#

what is your usernam

#

an

#

e

crisp lance
crisp meteor
# crisp lance jumij ig

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Tesseract-OCR\tesseract.exe'

crisp lance
#

1 sec, I'll finish eating and then try

crisp meteor
#

i am going to get back my 1800 messages with this one

crisp lance
#

K, back to work

crisp lance
#

Found it in appdate @crisp meteor

#

OMG no

#

The minute he goes offline, I find the right Path

#

_
ok... its working now, except its not working

#

There is no more error message, but it also aint doing anything

crisp meteor
crisp lance
#

YES

crisp meteor
#

omg

crisp lance
#

I just went to appdata, and searched like 5 minutes for it

crisp meteor
crisp lance
#

No. It doesnt move at all .-.

#

But there aint no error either

#

Wanna come call real quick? So I can stream? (dont have to talk)

crisp meteor
#

wait

#

@crisp lance

crisp lance
#

Hmh?

crisp meteor
#

there

#

is

#

an error

crisp lance
#

where?

crisp meteor
#

open up console

#

run

#

first

crisp lance
#

nah, thats bcs I stopped

crisp meteor
#

oh

#

umm can you like try the script on chat

#

to check if it moves arrows

crisp lance
#

ye it moves

#

but very very slow

#

and I think only in the Programm, not when I switch over to the game / another window

crisp meteor
#

ok

#

copy script

#

here

crisp lance
#

import pyautogui
import pytesseract
from PIL import ImageGrab
import random
import time
time.sleep(3)

Configure pytesseract path to your installation

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe' # Windows example

pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract' # Linux example

pytesseract.pytesseract.tesseract_cmd = '/usr/local/bin/tesseract' # macOS example

TARGET_TEXT = "MoNeTe Prime" # Replace with the text you're looking for
CHECK_INTERVAL = 2 # Seconds between each screen check
SEARCH_DURATION = 3600 # The maximum duration to search (in seconds)

def is_text_present(screen):
"""Check if the target text is present in the given screen image."""
text = pytesseract.image_to_string(screen)
return TARGET_TEXT in text

def move_randomly():
"""Move randomly using the arrow keys."""
move_keys = ['up', 'down', 'left', 'right']
pyautogui.press(random.choice(move_keys))

def search_for_text(timeout=SEARCH_DURATION):
"""Search for the text on the screen, moving randomly until the text is found or timeout."""
start_time = time.time()
while True:
# Grab the screen
screen = ImageGrab.grab()

    # Check for the text on the screen
    if is_text_present(screen):
        print("Text found!")
        break

    # Move randomly
    move_randomly()

    # Break if the timeout is reached
    if time.time() - start_time > timeout:
        print("Text not found within the timeout duration.")
        break

    # Wait a bit before trying again
    time.sleep(CHECK_INTERVAL)

Start the search process

search_for_text()

crisp meteor
#

import pyautogui
import pytesseract
from PIL import ImageGrab
import random
import time
time.sleep(3)

Configure pytesseract path to your installation

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe' # Windows example

pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract' # Linux example

pytesseract.pytesseract.tesseract_cmd = '/usr/local/bin/tesseract' # macOS example

TARGET_TEXT = "MoNeTe Prime" # Replace with the text you're looking for
CHECK_INTERVAL = 2 # Seconds between each screen check
SEARCH_DURATION = 3600 # The maximum duration to search (in seconds)

def is_text_present(screen):
"""Check if the target text is present in the given screen image."""
text = pytesseract.image_to_string(screen)
return TARGET_TEXT in text

def move_randomly():
"""Move randomly using the arrow keys."""
move_keys = ['up', 'down', 'left', 'right']
pyautogui.press(random.choice(move_keys))

def search_for_text(timeout=SEARCH_DURATION):
"""Search for the text on the screen, moving randomly until the text is found or timeout."""
start_time = time.time()
while True:
# Grab the screen
screen = ImageGrab.grab()

    # Check for the text on the screen
    if is_text_present(screen):
        print("Text found!")
        break

    # Move randomly
    move_randomly()

    # Break if the timeout is reached
    if time.time() - start_time > timeout:
        print("Text not found within the timeout duration.")
        break

    # Wait a bit before trying again
    time.sleep(CHECK_INTERVAL)

Start the search process

search_for_text()

#

wait

#

sorry

#

wrong send

#

@crisp lance

import pyautogui
import pytesseract
from PIL import ImageGrab
import random
import time
time.sleep(3)
# Configure pytesseract path to your installation
pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'  # Windows example
# pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'  # Linux example
# pytesseract.pytesseract.tesseract_cmd = '/usr/local/bin/tesseract'  # macOS example

TARGET_TEXT = "MoNeTe Prime"  # Replace with the text you're looking for
CHECK_INTERVAL = 2  # Seconds between each screen check
SEARCH_DURATION = 3600  # The maximum duration to search (in seconds)

def is_text_present(screen):
    """Check if the target text is present in the given screen image."""
    text = pytesseract.image_to_string(screen)
    return TARGET_TEXT in text

def move_randomly():
    """Move randomly using the arrow keys."""
    move_keys = ['up', 'down', 'left', 'right']
    pyautogui.press(random.choice(move_keys))

def search_for_text(timeout=SEARCH_DURATION):
    """Search for the text on the screen, moving randomly until the text is found or timeout."""
    start_time = time.time()
    while True:
        # Grab the screen
        screen = ImageGrab.grab()

        # Check for the text on the screen
        if is_text_present(screen):
            print("Text found!")
            break

        # Move randomly
        for i in range(200):
            move_randomly()

        # Break if the timeout is reached
        if time.time() - start_time > timeout:
            print("Text not found within the timeout duration.")
            break

        # Wait a bit before trying again
        time.sleep(CHECK_INTERVAL)

# Start the search process
search_for_text()
#

try this

crisp lance
#

its moving

#

but only IN the programming site

#

not in another window

crisp meteor
#

nice

crisp lance
crisp meteor
#

@crisp meteor _0bytes's Question:

pyautogui.press doesnt work in game window

pyautogui.press() might not work in a game window for several reasons:

  1. Game Protection: Some games have protection against simulated keyboard events to prevent cheating.
  2. Administrator Rights: Games often require higher privileges. Running your script as an administrator might help.
  3. DirectX/OpenGL: Games using these may not recognize synthetic events from tools like pyautogui.
  4. Game Focus: The game window must be in focus for keyboard events to be detected.
  5. Input Detection: Games might use raw input detection, which pyautogui doesn't support.

Solutions:

  • Run as Admin: Try running your script with administrator privileges.
  • Alt-Tab: Use pyautogui to alt-tab into the game window before sending keystrokes.
  • Game Input Settings: Change the game input settings if it allows non-raw input.
  • Alternative Libraries: Use libraries like DirectKeys or SendKeys which might work better with games.
  • Game Bots/APIs: Use game-specific bots or APIs designed to interact with games, if available.
crisp meteor
crisp lance
crisp meteor
#

what is the game name

crisp lance
#

Rise of Kingdoms

crisp meteor
#

simulated?

crisp lance
#

no

crisp lance
#

like it IS a programm

crisp meteor
#

@crisp meteor _0bytes's Question:

the game is Rise of Kingdoms

The game "Rise of Kingdoms" may have anti-botting measures or may not respond to synthetic events generated by libraries like PyAutoGUI. Typically, games that are designed to be played in real-time with competitive elements will have such measures to prevent cheating.

However, here are a few things you could try:

  1. Administrator Privileges: Run your script as an administrator since higher privileges might be required.
  2. Alternative Tools: Investigate if there are other tools or libraries that can simulate keystrokes at a lower level, like DirectInput for Windows.
  3. Compatibility Mode: Check if running the game in a different compatibility mode makes a difference.
  4. Game Settings: Look into the game’s settings to see if there are any options related to input methods that might affect how the game receives keystrokes.
  5. Virtual Machine: Run the game inside a virtual machine where the input is captured more directly by the virtualization software.
  6. Official API: Some games offer official APIs that allow for certain types of automation within the rules of the game.
  7. Hardware Emulation: Use tools or devices that emulate the electrical signals of an actual keyboard.

Always ensure you are not violating the game's Terms of Service when attempting such methods, as this could result in your game account being suspended or banned.

crisp lance
#

Exactly the same message 💀

crisp meteor
#

@crisp meteor _0bytes's Question:

DirectInput <- give example for

DirectInput is part of the legacy DirectX API that deals with input (keyboard, mouse, joystick, etc.) on Windows systems. It's worth noting that DirectInput is outdated and has been superseded by XInput for Xbox controllers, and raw input for mice and keyboards. However, there are no popular libraries similar to PyAutoGUI that implement DirectInput because it is primarily used for game development rather than automation.

For the purpose of automation or scripting inputs into a game that might not recognize high-level synthetic events created by PyAutoGUI, an alternative approach would be to use tools that can simulate keyboard events as if they are coming from the driver itself, essentially imitating a real hardware input.

An example of this is using the SendInput function in the Windows API to synthesize keystrokes. This function inserts keyboard or mouse input into the system input stream, making it appear as if the user has performed these actions.

Below is an example in Python of how you could possibly use the SendInput function through the ctypes library, which allows you to call functions in DLLs or shared libraries:

import ctypes
from ctypes.wintypes import WORD, UINT, ULONG

# Constants from the Windows API
INPUT_KEYBOARD = 1
KEYEVENTF_EXTENDEDKEY = 0x0001
KEYEVENTF_KEYUP = 0x0002
VK_SPACE = 0x20

class KEYBDINPUT(ctypes.Structure):
    _fields_ = [("wVk", WORD),
                ("wScan", WORD),
                ("dwFlags", ULONG),
                ("time", ULONG),
                ("dwExtraInfo", ctypes.POINTER(ctypes.c_ulong))]

class INPUT(ctypes.Structure):
    _fields_ = [("type", UINT),
                ("ki", KEYBDINPUT),
                ("pad", ctypes.c_ubyte * 8)]

def press_key(key_code):
    input_struct = INPUT(type=INPUT_KEYBOARD,
                         ki=KEYBDINPUT(wVk=key_code, wScan=0, dwFlags=0, time=0, dwExtraInfo=None))
    ctypes.windll.u
#

my internets slow af

#

ser32.SendInput(1, ctypes.byref(input_struct), ctypes.sizeof(input_struct))

def release_key(key_code):
input_struct = INPUT(type=INPUT_USB,
ki=KEYBDINPUT(wVk=key_code, wScan=0, dwFlags=KEYEVENTF_KEYUP, time=0, dwExtraInfo=None))
ctypes.windll.user32.SendInput(1, ctypes.byref(input_struct), ctypes.sizeof(input_td))

Press and release space

press_key(VK_SPACE)
release_key(VK_SPACE)


**Before you proceed with attempting such input simulation:**
1. **Understand the risks**: Modifying a game’s input in this way is often against its terms of service and you could be banned for doing so if detected.
2. **Know your environment**: This example is intended for a Windows environment and won’t work on other operating systems.
3. **Safety**: Only use such methods with games that allow it or in a situation where you are not violating any terms or laws.

Always use these methods responsibly, and understand that they are presented here for educational purposes.
#

uhhh

crisp lance
#

trust me, its for educational purposes

crisp meteor
#

that is alot of code for pressing akey

crisp lance
#

fr

crisp meteor
#

@crisp meteor _0bytes's Question:

simplest script for pressing a key

For pressing a key using a simple Python script, you can rely on the keyboard library, which can send virtual keypresses and is relatively easy to use compared to direct Windows API manipulation. First, install the library using pip if you haven't already:

pip install keyboard

Then you can write a simple script that presses a key:

import keyboard

# Simulate the "space" key press
keyboard.send('space')

Ensure you have the necessary permissions to execute this script, and try running it with administrative rights if it needs to interact with a program that also requires admin rights. Use this responsibly and be aware of the game's policy on automation to avoid any violations.

#

@flap try this install keyboard first:
@crisp lance

import keyboard
import pyautogui
import pytesseract
from PIL import ImageGrab
import random
import time
time.sleep(3)
# Configure pytesseract path to your installation
pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'  # Windows example
# pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'  # Linux example
# pytesseract.pytesseract.tesseract_cmd = '/usr/local/bin/tesseract'  # macOS example

TARGET_TEXT = "MoNeTe Prime"  # Replace with the text you're looking for
CHECK_INTERVAL = 2  # Seconds between each screen check
SEARCH_DURATION = 3600  # The maximum duration to search (in seconds)

def is_text_present(screen):
    """Check if the target text is present in the given screen image."""
    text = pytesseract.image_to_string(screen)
    return TARGET_TEXT in text

def move_randomly():
    """Move randomly using the arrow keys."""
    move_keys = ['up', 'down', 'left', 'right']
    keyboard.send(random.choice(move_keys))

def search_for_text(timeout=SEARCH_DURATION):
    """Search for the text on the screen, moving randomly until the text is found or timeout."""
    start_time = time.time()
    while True:
        # Grab the screen
        screen = ImageGrab.grab()

        # Check for the text on the screen
        if is_text_present(screen):
            print("Text found!")
            break

        # Move randomly
        for i in range(200):
            move_randomly()

        # Break if the timeout is reached
        if time.time() - start_time > timeout:
            print("Text not found within the timeout duration.")
            break

        # Wait a bit before trying again
        time.sleep(CHECK_INTERVAL)

# Start the search process
search_for_text()
crisp lance
#

did

crisp meteor
#

did what

#

in 2ms

crisp lance
#

ye, i did it as soon as the ai said it

#

im evolving 💀

crisp meteor
#

did you keyboard.send

crisp lance
#

yes

#

doent work

crisp meteor
#

nice

#

now you gotta figure out

#

how to

#

make it work

#

bye bye

crisp lance
#

😭

crisp meteor
#

react with ✅

crisp lance
#

NAH

#

@crisp meteor im smart as fuck

#

well no, im stupid af, but u2 this time

#

Your pgrogramm is pressing the wrong keys

crisp meteor
#

@crisp lance, you just advanced to Super Active!! 🎉🎉🎉

crisp meteor
crisp lance
#

Oh... nvm... they work too to scroll on the map

#

Ye ok nah. Im back to 0

crisp meteor
#

@crisp lance aparex's Question:

The Game im programming a bot for isnt registering keybord.send or pyautogui.press

If the game you're programming a bot for isn't registering key presses from keyboard.send() (assuming you're referring to the Python keyboard library) or pyautogui.press(), it could be due to several reasons. Here are some potential issues and solutions to look into:

  1. Game Protection: Many modern games have mechanisms to prevent automated tools. These may not respond to simulated keystrokes from software.

  2. Administrator Privileges: Try running your script as an administrator, since some games require elevated privileges to recognize simulated inputs.

  3. DirectInput/XInput: The game may use DirectInput/XInput which these libraries cannot emulate. You might need a more sophisticated tool that can emulate these inputs.

  4. Timing Issues: The bot might be sending keypresses too quickly or at an inappropriate time. Ensure you have appropriate delays.

  5. Focus: Ensure that the game window is active and in focus when the script is running. Otherwise, the keypresses will not be sent to the correct window.

  6. Compatibility: Your Python libraries might be out of date or incompatible with your Python version. Try updating the libraries and Python itself.

  7. Incorrect Key Codes: Make sure you're using the correct key codes for the game's control scheme.

  8. Game running in Fullscreen: Some games in fullscreen mode may not accept simulated inputs. Try running the game in windowed or borderless windowed mode.

  9. Code Issues: Double-check if there's a problem with your code logic that's preventing the key presses from being executed correctly.

If none of these solutions work, it might be necessary to use other approaches, such as:

  • DirectX input simulation with tools like SendInput in a custom C++ script.
  • Using an alternative Python library designed for game botting.
  • Modifying game files or
#

memory (note that this is against most Terms of Service and can result in bans).

Always remember to adhere to the game's terms of service when creating bots, as automating interactions with the game can be considered cheating and may result in bans or other punitive actions.

#

@crisp lance aparex's Question:

what would be a better liberary to press keys I could try?

If keyboard and pyautogui are not working for your purposes, there are a few alternative libraries and methods you could try for simulating keyboard input in Python:

  1. pynput:
    This library can control and monitor input devices. The keyboard module within pynput allows you to send keyboard events. It might be detected differently by games compared to pyautogui.

    from pynput.keyboard import Key, Controller
    
    keyboard = Controller()
    
    keyboard.press(Key.space)
    keyboard.release(Key.space)
    
  2. Direct System Calls:
    For more low-level control, you could use a library that can make system calls to the underlying operating system's input methods (e.g., SendInput for Windows). This typically requires using a library that can interface with C++ API calls or similar.

    • For Windows, you could use the ctypes library to call SendInput directly.
    • For Linux, you might end up using the xdotool or similar utilities via subprocess calls.
  3. DirectKeys:
    This is a simple Python script that provides functionality to send keystrokes with SendInput on Windows, and it’s often used for game bots.

  4. AutoIt (with Python binding PyAutoIt):
    AutoIt is a scripting language that is great for automating the Windows GUI. It can send keystrokes and is known to work with a variety of applications, including games.

  5. Hardware Emulation Board:
    If software approaches are completely blocked by the game, some developers resort to using hardware emulation via microcontrollers like Arduino with HID (Human Interface Device) capabilities to simulate actual button presses.

  6. Combining Libraries:
    Sometimes a combination of libraries (such as pynput to hold keys and pyautogui for mouse movement) works better than a single library.

Remember to handle timing and delays carefully as games a

#

lso often check for abnormal behavior consistent with bots (like inhumanly fast or perfectly regular input).

Lastly, the use of these libraries and the creation of bots can violate the terms of service of many games, so it's important to ensure compliance with the legal guidelines and terms set forth by the game developers.

crisp lance
#

Nvm, sry for the ping

crisp meteor
#

You need to be a member to upload an image

crisp lance
#

Bruh

crisp meteor
#

@crisp lance aparex's Question:

The keyboard.press(Key.up) command isnt working. "Unresolved reference "Key" "

The "Unresolved reference" error indicates that Python doesn't recognize the Key reference in your code. This usually happens when the necessary module or class hasn't been imported properly.

In the case of pynput, the Key class resides within the keyboard module of the pynput package. To fix the error, make sure to import Key from pynput.keyboard at the beginning of your Python script.

Here’s an example of how to import the Key class correctly and use it with pynput:

from pynput.keyboard import Key, Controller

keyboard = Controller()

# Press and release an arrow key
keyboard.press(Key.up)
keyboard.release(Key.up)

Ensure that you have pynput installed in your Python environment. You can install it using pip, if you haven't already:

pip install pynput

Now, when you run the script, Python should recognize the Key reference. Remember to also run your script with the appropriate permissions and in the right context, so that key presses are directed to the intended window, especially if you're trying to interact with a game.

#

@crisp lance aparex's Question:

Traceback (most recent call last): File "C:\Users\jumij\PycharmProjects\bot\main.py", line 60, in <module> search_for_text() File "C:\Users\jumij\PycharmProjects\bot\main.py", line 49, in search_for_text move_randomly() File "C:\Users\jumij\PycharmProjects\bot\main.py", line 30, in move_randomly keyboard.press(Key.down) File "C:\Users\jumij\PycharmProjects\bot\venv\Lib\site-packages\keyboard\__init__.py", line 396, in press send(hotkey, True, False) File "C:\Users\jumij\PycharmProjects\bot\venv\Lib\site-packages\keyboard\__init__.py", line 379, in send parsed = parse_hotkey(hotkey) ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jumij\PycharmProjects\bot\venv\Lib\site-packages\keyboard\__init__.py", line 343, in parse_hotkey if _is_number(hotkey) or len(hotkey) == 1: ^^^^^^^^^^^ TypeError: object of type 'Key' has no len()

The error you're encountering occurs because the keyboard module from the keyboard library you've imported does not recognize the Key object as you might be using it in a way that is incompatible with that specific library. Your traceback suggests that you're using the keyboard library, not pynput.

The Key class is part of the pynput library, not the keyboard library. The error is because keyboard.press() from the keyboard library is receiving a Key object which is not expected by it.

Here's how you could resolve this issue:

If you intended to use the pynput library:

First, make sure you're importing from pynput, and you're using its Controller:

from pynput.keyboard import Key, Controller
keyboard = Controller()

keyboard.press(Key.down)  # This uses the pynput library's way of pressing keys.
keyboard.release(Key.down)

If you're trying to use the keyboard library, you should avoid using pynput's Key class. Here’s an example using just the keyboard library:

import keybo
#

ard

keyboard.press('down') # Use the string notation for keys.
keyboard.release('down')


In summary:
- For the `pynput` library, use `Key`.
- For the `keyboard` library, use strings to specify keys.

Make sure you only import and use one of these libraries for a particular block of code to avoid confusion.

And finally, confirm which library you are actually intending to use, and be consistent with your imports and function calls.
#

@crisp lance aparex's Question:

The pynput method doesnt work either

If the pynput method isn't working in your game environment, it's usually because of one of these reasons:

  1. Game Input Handling: Games often use direct hardware access for input operations. Libraries like pynput simulate keypresses at a higher level, which many games are designed to ignore in order to prevent simple botting.

  2. Administrative Privileges: Try to run your bot script with administrative privileges. On Windows, you can run your command prompt or IDE as an administrator.

  3. Compatibility Issues: Some games, especially those that run with elevated privileges or in a secure environment, may not accept synthetic events from libraries like pynput.

  4. Background vs. Foreground: Ensure the game is in the foreground and is the active window when pynput is sending keypresses.

  5. Anti-cheat Systems: Games with anti-cheat systems may actively block simulated inputs from common libraries.

Since pynput didn't work, and you're seeing compatibility issues, you might have to look into more complex solutions. These can include:

  • Utilizing a library that interacts more directly with low-level system inputs (like ctypes with SendInput in Windows).
  • Using a virtual machine where the game's ability to detect automation tools might be limited.
  • Using a hardware-based solution like an Arduino microcontroller to emulate actual key presses.
  • Looking into the game's modding community for insights on how to programmatically interact with the game, while keeping in mind the legal and ethical implications.

However, do note that attempting further to interact programmatically with a game that has mechanisms to prevent automation might violate its terms of service. Always ensure you're compliant with the game's rules to avoid account suspension or banning.

#

@crisp lance aparex's Question:

You got anything else in python that may work? Another, better, way to simulate inputs?

When typical libraries like pyautogui or pynput don't work, usually due to game anti-bot measures or other software blocking simulated inputs, you need to use more advanced methods for simulating keystrokes. Here are a couple of alternatives that involve using Python, but keep in mind that these methods may still not work if the game has robust measures against automation:

  1. DirectInput via ctypes:
    You can use the Windows API to send inputs directly, which can sometimes bypass the restrictions. Here's a barebones example using ctypes to simulate a key press:

    import ctypes
    from ctypes import wintypes
    
    SendInput = ctypes.windll.user32.SendInput
    
    # C struct redefinitions
    PUL = ctypes.POINTER(ctypes.c_ulong)
    class KeyBdInput(ctypes.Structure):
        _fields_ = [("wVk", wintypes.WORD),
                    ("wScan", wintypes.WORD),
                    ("dwFlags", wintypes.DWORD),
                    ("time", wintypes.DWORD),
                    ("dwExtraInfo", PUL)]
    
    class HardwareInput(ctypes.Structure):
        _fields_ = [("uMsg", wintypes.DWORD),
                    ("wParamL", wintypes.WORD),
                    ("wParamH", wintypes.WORD)]
    
    class MouseInput(ctypes.Structure):
        _fields_ = [("dx", wintypes.LONG),
                    ("dy", wintypes.LONG),
                    ("mouseData", wintypes.DWORD),
                    ("dwFlags", wintypes.DWORD),
                    ("time",wintypes.DWORD),
                    ("dwExtraInfo", PUL)]
    
    class Input_I(ctypes.Union):
        _fields_ = [("ki", KeyBdInput),
                    ("mi", MouseInput),
                    ("hi", HardwareSafeArray)]
    
    class Input(ctypes.Structure):
        _fields_ = [("type", wintypes.DWORD),
                    ("ii", Input_I)]
    
    # Actual Functions
    def PressKey(hexKeyCode):
        ex
#

tra = 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))


You would call `PressKey(0x<keycode>)` to press a key and `ReleaseClassKey(0x<keycode>)` to release a key, where `<keycode>` is the hexadecimal code of the key.

2. **Direct Input with a C++ Extension**: 
You could write a C++ extension for Python that makes use of `SendInput` or other direct input methods offered by the Win32 API, then call it from your Python code. 

3. **IronPython with Windows Forms**: 
IronPython is an implementation of Python running on the .NET Framework, and it can use the `System.Windows.Forms.SendKeys` to send keystrokes. This method might work when standard Python libraries don't, but it depends on your game's input handling.

4. **AutoHotkey Interfacing**:
Write an AutoHotkey script to simulate the inputs, and then call the AutoHotkey script from Python when you need to send a key press.

5. **Use Python to interact with a Device Driver**:
You could theoretically write a custom device driver that sends input to the computer that is indistinguishable from actual hardware input. Interacting with such a driver would be complex and require a solid understanding of how device drivers work.

Remember, these methods may or may not work depending on the game's level of input detection, and some of them may require elevated permissions that are not advisable to use. 

Lastly, remember that using these methods in games, particularly in multiplayer scenarios, may violate terms of service and could r
#

esult in bans or other consequences. Always check the game's policies regarding automation before proceeding.

#

@crisp lance aparex's Question:

import pyautogui import pytesseract from PIL import ImageGrab import random import time import keyboard from pynput.keyboard import Key, Controller time.sleep(3) keyboard = Controller() pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe' # Windows example TARGET_TEXT = "MoNeTe Prime" # Replace with the text you're looking for CHECK_INTERVAL = 2 # Seconds between each screen check SEARCH_DURATION = 3600 # The maximum duration to search (in seconds) def is_text_present(screen): """Check if the target text is present in the given screen image.""" text = pytesseract.image_to_string(screen) return TARGET_TEXT in text def move_randomly(): """Move randomly using the arrow keys.""" move_keys = ['up', 'down', 'left', 'right'] x = random.randint(0,3) if x == 0: keyboard.press(Key.up) if x == 1: keyboard.press(Key.down) if x == 2: keyboard.press(Key.right) if x == 3: keyboard.press(Key.left) def search_for_text(timeout=SEARCH_DURATION): """Search for the text on the screen, moving randomly until the text is found or timeout.""" start_time = time.time() while True: # Grab the screen screen = ImageGrab.grab() # Check for the text on the screen if is_text_present(screen): print("Text found!") break # Move randomly for i in range(200): move_randomly() # Break if the timeout is reached if time.time() - start_time > timeout: print("Text not found within the timeout duration.") break # Wait a bit before trying again time.sleep(CHECK_INTERVAL) # Start the search process search_for_text() put that method into here

I see that your code is trying to scan the screen for certain text using pytesseract and moving the cursor randomly using arrow keys if th

#

e text is not found. There are several issues with the code you posted, mainly with the keyboard and pynput.keyboard import conflict and how the move_randomly function is set up.

Here is a corrected version of your script with fixes:

import pytesseract
from PIL import ImageGrab
import random
import time
from pynput.keyboard import Key, Controller

time.sleep(3)
keyboard_controller = Controller()
pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'  # Windows example

TARGET_TEXT = "MoNeTe Prime"  # Replace with the text you're looking for
CHECK_INTERVAL = 2  # Seconds between each screen check
SEARCH_DURATION = 3600  # The maximum duration to search (in seconds)

def is_text_present(screen):
    """Check if the target text is present in the given screen image."""
    text = pytesseract.image_to_string(screen)
    return TARGET_TEXT in text

def move_randomly():
    """Move randomly using the arrow keys."""
    directions = [Key.up, Key.down, Key.left, Key.right]
    random_direction = random.choice(directions)
    keyboard_controller.press(random_direction)
    time.sleep(0.1)  # Hold the key for a short while
    keyboard_controller.release(random_direction)

def search_for_text(timeout=SEARCH_DURATION):
    """Search for the text on the screen, moving randomly until the text is found or timeout."""
    start_time = time.time()
    while True:
        # Grab the screen
        screen = ImageGrab.grab()
        # Check for the text on the screen
        if is_text_present(screen):
            print("Text found!")
            break
        # Move randomly
        move_randomly()
        # Break if the timeout is reached
        if time.time() - start_time > timeout:
            print("Text not found within the time limit.")
            break
           
        # Wait a bit before trying again
        time.sleep(CHECK_INTERVAL)

# Start the search process
search_for_text()

Here's what's ch

#

anged:

  1. Renamed the keyboard Controller instance to keyboard_controller to avoid conflicting with the keyboard import (which you may remove if not needed elsewhere).
  2. Used random.choice to select a random key from the directions list in move_randomly.
  3. Added a short time.sleep(0.1) to hold the direction key before releasing it, as some applications may not register keys that are pressed and released instantaneously.
  4. Removed the keyboard package import as we're already using the Controller from pynput.keyboard.

Please ensure that you have the correct permissions to execute key press simulation and that this activity is within the terms of service of the software you are using it with.

#

@crisp lance aparex's Question:

ye, but I meant to work this ctypes thing into the code

Understood. Let's integrate the ctypes method for simulating key presses into your existing code. Below, I provide a function that uses ctypes to simulate the pressing and releasing of directional keys and integrate it into the random movement functionality of your script.

Here's an example of how you might do that:

import pytesseract
from PIL import ImageGrab
import random
import time
import ctypes
from ctypes import wintypes

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'  # Windows example

TARGET_TEXT = "MoNeTe Prime"  # Replace with the text you're looking for
CHECK_INTERVAL = 2  # Seconds between each screen check
SEARCH_DURATION = 3600  # The maximum duration to search (in seconds)

# Key codes for arrow keys
VK_CODE = {
    'up': 0x26,
    'down': 0x28,
    'left': 0x25,
    'right': 0x27
}

# Structs and functions to simulate key presses
SendInput = ctypes.windll.user32.SendInput

# C struct redefinitions
class KEYBDINPUT(ctypes.Structure):
    _fields_ = [("wVk", wintypes.WORD),
                ("wScan", wintypes.WORD),
                ("dwFlags", wintypes.DWORD),
                ("time", wintypes.DWORD),
                ("dwExtraInfo", wintypes.POINTER(wintypes.DWORD))]
    
class INPUT(ctypes.Structure):
    _fields_ = [("type", wintypes.DWORD),
                ("ki", KEYBDINPUT),
                ("padding", wintypes.BYTE * 8)]

# Function to simulate key presses
def PressKey(hexKeyCode):
    extra = ctypes.c_ulong(0)
    ii_ = INPUT(type=1,  # INPUT_KEYBOARD
                ki=KEYBDINPUT(wVk=hexKeyCode,
                              wScan=0,
                              dwFlags=0,
                              time=0,
                              dwExtraInfo=ctypes.pointer(extra)))
    x = ctypes.windll.user32.SendInput(1, ctypes.pointer(ii_), ctypes.sizeof(ii_))

def Rel
#

easeKey(hexKeyCode):
extra = ctypes.c_ulong(0)
ii_ = INPUT(type=1, # INPUT_KEYBOARD
ki=KEYBDINPUT(wVk=hexKeyCode,
wScan=0,
dwFlags=0x0002, # KEYEVENTF_KEYUP
time=0,
dwExtraInfo=ctypes.pointer(extra)))
x = ctypes.windll.user32.SendInput(1, ctypes.pointer(ii_), ctypes.sizeof(ii_))

def move_randomly():
move_keys = ['up', 'down', 'left', 'right']
key = random.choice(move_keys)
PressKey(VK_CODE[key])
time.sleep(0.1)
ReleaseKey(VK_CODE[key])

def is_text_present(screen):
text = pytesseract.image_to_string(screen)
return TARGET_TEXT in text

def search_for_text(timeout=SEARCH_DURATION):
start_time = time.time()
while True:
screen = ImageGrab.grab()
if is_text_present(screen):
print("Text found!")
break
move_randomly()
if time.time() - start_time > timeout:
print("Text not found within the timeout duration.")
break
time.sleep(CHECK_INTERVAL)

time.sleep(3) # Wait for 3 seconds before the script starts
search_for_text()


This updated code uses the `ctypes` library to directly make system calls to simulate key presses, potentially allowing your script to work with games that would not otherwise recognize Python keyboard events. However, note that even this approach can be circumvented by certain anti-bot mechanisms within games.

Always ensure that automating interactions with games is permitted by the game's terms of service to avoid potentially adverse actions against your account or access.
crisp lance
#

now make it, so I can copy it, in this special format thing

crisp meteor
#

@crisp lance aparex's Question:

now make it, so I can copy it, in this special format thing

Certainly! Below is the updated ctypes integration within your game bot script to simulate key presses using the special triple backticks for easy copy-pasting:

import pytesseract
from PIL import ImageGrab
import random
import time
import ctypes
from ctypes import wintypes

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'

TARGET_TEXT = "MoNeTe Prime"
CHECK_INTERVAL = 2
SEARCH_DURATION = 3600

VK_CODE = {
    'up': 0x26,
    'down': 0x28,
    'left': 0x25,
    'right': 0x27
}

SendInput = ctypes.windll.user32.SendInput

class KEYBDINPUT(ctypes.Structure):
    _fields_ = [("wVk", wintypes.WORD),
                ("wScan", wintypes.WORD),
                ("dwFlags", wintypes.DWORD),
                ("time", wintypes.DWORD),
                ("dwExtraInfo", wintypes.POINTER(wintypes.DWORD))]
    
class INPUT(ctypes.Structure):
    _fields_ = [("type", wintypes.DWORD),
                ("ki", KEYBDINPUT),
                ("padding", wintypes.BYTE * 8)]

def PressKey(hexKeyCode):
    extra = ctypes.c_ulong(0)
    ii_ = INPUT(type=1,
                ki=KEYBDINPUT(wVk=hexKeyCode,
                              wScan=0,
                              dwFlags=0,
                              time=0,
                              dwExtraInfo=ctypes.pointer(extra)))
    ctypes.windll.user32.SendInput(1, ctypes.pointer(ii_), ctypes.sizeof(ii_))

def ReleaseKey(hexKeyCode):
    extra = ctypes.c_ulong(0)
    ii_ = INPUT(type=1,
                ki=KEYBDINPUT(wVk=hexKeyCode,
                              wScan=0,
                              dwFlags=0x0002,
                              time=0,
                              dwExtraInfo=ctypes.pointer(extra)))
    ctypes.windll.user32.SendInput(1, ctypes.pointer(ii_), ctypes.sizeof(ii_))

def move_randomly():
    move_keys = ['up', 'down', 'left', 'right']
crisp lance
#

Nah wtf

#

I want this square thingy

crisp meteor
#

key = random.choice(move_keys)
PressKey(VK_CODE[key])
time.sleep(0.1)
ReleaseKey(VK_CODE[key])

def is_text_present(screen):
text = pytesseract.image_to_string(screen)
return TARGET_TEXT in text

def search_for_text(timeout=SEARCH_DURATION):
start_time = time.time()
while True:
screen = ImageGrab.grab()
if is_text_present(screen):
print("Text found!")
break
move_randomly()
if time.time() - start_time > timeout:
print("Text not found within the timeout duration.")
break
time.sleep(CHECK_INTERVAL)

time.sleep(3) # Wait for 3 seconds before the script starts
search_for_text()


Copy the entire code block by clicking and dragging your cursor from the first backtick to the last, or by clicking the copy button that appears when you hover your cursor over the code block (if available, depending on your browsing platform). Then paste it into your Python script file.
#

An error occurred while processing your request.

#

Continuing...

#

@crisp lance aparex's Question:

ctypes doesnt work either. What else we got?

If you've tried ctypes and other conventional input simulation libraries in Python and they're not working, there are some other methods you might consider, though they tend to be more complex and involved:

  1. Intercepting Low-Level Input Events:

    • Create a driver or use an existing one that can inject inputs directly into the input stream. This is highly complex, requires driver development knowledge, and isn't typically done with Python.
  2. Using Specialized Input Libraries:

    • Some libraries are specifically designed for game automation and may work where others fail. These libraries are often language-specific and may not be available in Python.
  3. Virtual Machine (VM) or Hardware Emulation:

    • Run the game within a VM where you can have more control over the input stack.
    • Use a hardware emulator like Arduino or Teensy to simulate key presses as if they're coming from an actual hardware device.
  4. Scripting with AutoHotkey or AutoIt:

    • AutoHotkey and AutoIt are powerful scripting environments for automating the Windows GUI. They are often more successful at interacting with applications that resist other forms of input simulation. You can call scripts made in these languages from Python.
  5. Image Recognition and External Tools:

    • Instead of trying to simulate keystrokes programmatically, you can use image recognition tools to visually identify UI elements and direct a physical device, like a robotic arm or a special mouse/keyboard controller, to interact with the game.

Each of these alternatives comes with a steep learning curve or involves significant complexity. They also have various legal and ethical considerations, especially regarding compliance with software terms of service and/or the Computer Fraud and Abuse Act.

In all cases, it's important to remember that these approaches may be against the terms of service for t

#

he game or platform you're working with. Always review and adhere to those terms to avoid potentially serious consequences, including but not could result in account bans or legal action.

crisp lance
#

Nah, this shit too fk complicated, I just give up

#

Thanks for helping tho @crisp meteor 😘

crisp meteor
crisp meteor
#

it is

crisp lance
#

Nah, fuck it

#

Ill go buy an ardoino tmr

#

and if that doesnt work, ill keep myself safe fr

#

Wanna help me with it? 🤣

crisp meteor
#

free messages

crisp lance
#

fr

#

Got time rn? 👀

#

I think I have an ardoino lying around somewhere

crisp meteor
#

@crisp lance aparex's Question:

K. Got my arduino. What do I do?

  1. Install the Software: Download and install the Arduino IDE from the official Arduino website.

  2. Set Up the IDE: Open the Arduino IDE, go to Tools > Board, and select the model of your Arduino board. Also, select the correct COM port (seen as 'Serial Port' on older versions of the IDE).

  3. Connect Your Arduino: Use a USB cable to connect the Arduino to your computer.

  4. Test the Board: Open the 'Blink' example sketch (File > Examples > 01.Basics > Blink). Upload it to your Arduino by clicking the upload button (right arrow icon). The on-board LED should start to blink.

  5. Experiment and Learn: Start modifying the Blink sketch to change the blink rate, or explore other examples to learn how to interact with different sensors and components.

  6. Build a Project: Once you're comfortable, you can start building your own project, coding it in the Arduino IDE and connecting the hardware on the Arduino board.

#

@crisp lance aparex's Question:

Where do I install the softwere to? Where is the arduino on my computer?

You can install the Arduino IDE software on your computer's main storage drive. Here are the general steps to follow for various operating systems:

For Windows:

  1. Download the Windows Installer from the Arduino website.
  2. Run the downloaded .exe file and proceed with the installation. You can usually install it to the default location, which is typically C:\Program Files (x86)\Arduino.
  3. Once installed, you'll be able to launch the Arduino IDE from the Start menu or a desktop shortcut if you created one during installation.

For macOS:

  1. Download the macOS version from the Arduino website.
  2. Open the downloaded .zip file, which will expand to create the Arduino application.
  3. Drag the Arduino application to the Applications folder.
  4. Launch the Arduino IDE from the Applications folder or through Spotlight.

For Linux:

  1. Download the appropriate version for your Linux distribution from the Arduino website.
  2. Extract the downloaded archive to a desired folder, for example, in your home directory or in /opt for global access.
  3. Run the install.sh script if available, or you might have to run the Arduino executable from inside the extracted folder.

After installing the software, you won't 'see' the Arduino board as you would a USB drive; it's not a storage device. Instead, the Arduino board communicates with your computer through a USB connection as a serial device.

To interact with the Arduino board, you must select the correct COM port:

  1. Connect the Arduino to your computer using a USB cable.
  2. Open the Arduino IDE.
  3. Go to Tools > Port and choose the port that lists an Arduino board. Typically, it will be the one that appeared after you plugged in your Arduino.

On Windows, COM ports are named as "COM3", "COM4", etc. On macOS, they will start with "/dev/cu.usbmodem" or "/dev/cu.usbserial", followed by a stri

#

ng of characters. On Linux, they'll be named "/dev/ttyUSB0", "/dev/ttyACM0", or similar.

From this point, you can start to upload sketches and interact with the Arduino.

crisp meteor
#

@crisp lance aparex's Question:

Got my ardoino set up. Give me the code for the arduino and for the python file

Sure, below are the basic code snippets you would need to get started with sending data from an Arduino to a Python script on your computer using the serial interface.

Arduino Sketch:

void setup() {
  // Start serial communication at a baud rate of 9600:
  Serial.begin(9600);
}

void loop() {
  // Send a value to the serial port:
  Serial.println("Hello from Arduino!");
  
  // Wait for a second:
  delay(1000);
}

This Arduino sketch initializes the serial communication at a baud rate of 9600 bits per second in the setup() function and then sends the string "Hello from Arduino!" every second in the loop() function.

Python Script:

Before you run the Python script, ensure you have the pyserial package installed. You can install it using pip:

pip install pyserial

Here's a basic Python script that reads the incoming data from the serial port and prints it to the console:

import serial
import time

# Replace 'COM3' with the serial port your Arduino is connected to.
# On Unix-like systems, it will be something like '/dev/ttyACM0' or '/dev/ttyUSB0'.
ser = serial.Serial('COM3', 9600, timeout=1)
time.sleep(2) # Wait for the connection to initialize

while True:
    if ser.in_waiting:
        line = ser.readline().decode('utf-8').rstrip()
        print(line)

This script imports the serial module, sets up a serial connection (you have to replace 'COM3' with the actual COM port to which your Arduino is connected), and then enters a loop where it reads a line from the serial port and prints it.

Keep in mind that communication requires that both the Arduino and the Python script use the same baud rate (in this case, 9600). Also, remember to upload the Arduino sketch to the board before running the Python script.

#

@crisp lance aparex's Question:

I mean the location bot script we had above to locate people in the game... remember?

I apologize for any confusion. However, as an AI with no persistent memory or ability to track previous interactions, I don't have previous conversations to recall. If you have a specific script related to a location bot for a game that uses an Arduino and Python, we would have to reconstruct it from scratch or you would need to provide more details.

If we are talking about a simple script where an Arduino sends data (like a player's location) to a Python script, we can extend the examples from before. Below, I'll provide a basic framework where the Arduino might collect some hypothetical location data (represented by random values) and send it through the serial port, and a Python script will read this data.

Arduino Sketch (assuming the location data is just random values for demonstration):

#include <ArduinoJson.h>

void setup() {
  Serial.begin(9600); // initialize serial communication
}

void loop() {
  StaticJsonDocument<200> doc; // create a JSON document to store the location data

  // Fill the document with hypothetical location data
  doc["player"] = "Player1";
  doc["x"] = random(0, 100); // random x-coordinate
  doc["y"] = random(0, 100); // random y-coordinate
  doc["z"] = random(0, 100); // random z-coordinate

  // Serialize JSON to send over serial
  serializeJson(doc, Serial);
  Serial.println();

  delay(1000); // wait for a second
}

Make sure the ArduinoJson library is included in your Arduino IDE before compiling. If it is not installed, you can find it in the Libraries Manager under the Sketch Menu.

Python Script to read the JSON data sent from the Arduino:

import serial
import json

# Set up the serial connection (adjust the COM port to match your system)
ser = serial.Serial('COM3', 9600)
print("Waiting for data...")

while True:
    try:
        # Read a line and decode it t
#

o a string
data_line = ser.readline().decode('utf-8').strip()
if data_line: # If the line is not empty
# Parse the JSON data
location_data = json.loads(data_line)
print(location_data)
except json.JSONDecodeError: # Catch and ignore JSON errors
pass
except KeyboardInterrupt: # Exit the loop when Ctrl+C is pressed
break

ser.close() # Close the serial connection


Before running the Python script, ensure you have adjusted the COM port string to match your configuration, as the Arduino might be on a different port on your system.

Remember that this is a very basic example to demonstrate the communication between Arduino and Python. The 'location' data is random and not linked to an actual game. If you need to work with real game data, you would have to modify the code to interface with your game and acquire actual location data.
#

@crisp lance aparex's Question:

import pyautogui import pytesseract from PIL import ImageGrab import random import time import keyboard from pynput.keyboard import Key, Controller time.sleep(3) keyboard = Controller() pytesseract.pytesseract.tesseract_cmd = r'C:\Users\jumij\AppData\Local\Programs\Tesseract-OCR\tesseract.exe' # Windows example TARGET_TEXT = "MoNeTe Prime" # Replace with the text you're looking for CHECK_INTERVAL = 2 # Seconds between each screen check SEARCH_DURATION = 3600 # The maximum duration to search (in seconds) def is_text_present(screen): """Check if the target text is present in the given screen image.""" text = pytesseract.image_to_string(screen) return TARGET_TEXT in text def move_randomly(): """Move randomly using the arrow keys.""" move_keys = ['up', 'down', 'left', 'right'] x = random.randint(0,3) if x == 0: keyboard.press(Key.up) if x == 1: keyboard.press(Key.down) if x == 2: keyboard.press(Key.right) if x == 3: keyboard.press(Key.left) def search_for_text(timeout=SEARCH_DURATION): """Search for the text on the screen, moving randomly until the text is found or timeout.""" start_time = time.time() while True: # Grab the screen screen = ImageGrab.grab() # Check for the text on the screen if is_text_present(screen): print("Text found!") break # Move randomly for i in range(200): move_randomly() # Break if the timeout is reached if time.time() - start_time > timeout: print("Text not found within the timeout duration.") break # Wait a bit before trying again time.sleep(CHECK_INTERVAL) # Start the search process search_for_text() this script we had. The game didnt register the inputs, you told me it would work with an arguino

I see, you're looking to use an Arduino to simulate keyboard inputs bec

#

ause direct simulated inputs from Python's pyautogui or similar libraries aren't recognized by some games due to security measures that prevent software-based automation.

To do this, you will need to connect the Arduino to your computer and program it to act as a keyboard that sends key presses. For this, an Arduino model with the capability of emulating a USB Human Interface Device (HID), like the Arduino Leonardo or Arduino Micro, is required. The regular Arduino Uno does not support this natively but can be programmed with additional firmware like Hoodloader.

Arduino Code:

Below is a simple Arduino script that receives serial commands from a Python script on your computer and then simulates keyboard presses, using a model such as the Leonardo or Micro.

#include "Keyboard.h"

void setup() {
  Serial.begin(9600);
  // Keyboard emulation is only supported on boards with native USB
  // capabilities like the Leonardo and Micro.
  Keyboard.begin();
}

void loop() {
  if (Serial.available() > 0) {
    int incomingByte = Serial.read();
    // 'U', 'D', 'L', 'R' are the commands sent from Python for Up, Down, Left, Right
    if (incomingByte == 'U') {
      Keyboard.press(KEY_UP_ARROW);
      delay(100); // Holding the key for 100 ms
      Keyboard.release(KEY_UP_ARROW);
    } else if (incomingButton == 'D') {
      Keyboard.press(KEY_DOWN_ARROW);
      delay(100); // Holding the key for 100 ms
      Keyboard.release(KEY_DOWN_ARROW);
    } else if (incomingByte == 'L') {
      Keyboard.press(KEY_LEFT_ARROW);
      delay(100); // Holding the key for 100 ms
      Keyboard.release(KEY_LEFT_ARROW);
    } else if (incomingByte == 'R') {
      Keyboard.press(KEY_RIGHT_ARROW);
      delay(100); // Holding the key for 100 ms
      Keyboard.release(KEY_RIGHT_ARROW);
    }
  }
}

Python Script:

Your Python script will need a slight modification to send commands to the Arduino over the serial port.

# ... (the rest of your imports and setup code)
#

import serial

Set the COM port connection (adjust the port to match your system)

arduino = serial.Serial('COM3', 9600)
time.sleep(2) # Wait for the connection to initialize

... (relevant parts of your script)

def move_randomly():
"""Send commands to move randomly using Arduino as a keyboard."""
move_commands = ['U', 'D', 'L', 'R']
command = random.choice(move_commands)
arduino.write(command.encode())

... (the rest of your search_for_text function and script)

Don't forget to close the serial connection at the end of your script.

arduino.close()


Please ensure:
1. You select the correct COM port which the Arduino is connected to.
2. The baud rates in Python and Arduino scripts match.
3. Use an Arduino board that can emulate a keyboard (or one that can be programmed to do so).

Remember to test this in an environment where unintended key presses will not cause problems, as this script will attempt to move in a game without stopping until it finds the text or the timeout is reached.
#

@crisp lance aparex's Question:

keybord, sowie fast alles "was not declared in this scope"

The error message "was not declared in this scope" indicates that the code is attempting to use a variable, function, or other identifier that has not been defined or is not in scope.

To resolve the issue with the Keyboard library for Arduino, follow these steps:

  1. Check that you are using an Arduino board that supports the Keyboard library, such as the Arduino Leonardo, Micro, Due or Pro Micro, since not all Arduino boards support keyboard emulation.

  2. Verify that your Arduino IDE has the Keyboard library installed. Normally, it comes pre-installed with the Arduino IDE when using compatible boards. If it's missing, you might be using a board that does not support this library.

  3. Ensure your board is correctly selected in the Arduino IDE by going to Tools > Board and selecting the board you're using.

  4. For the keyboard portion of the script, you should correct the variable name incomingButton to incomingByte as mentioned previously, and also correct the usage of KEY_UP_ARROW. The correct usage is KEY_UP_ARROW without KEY_ prefix.

Here's the corrected code snippet:

#include "Keyboard.h"

void setup() {
  Serial.begin(9600);
  Keyboard.begin();
}

void loop() {
  if (Serial.available() > 0) {
    char incomingByte = Serial.read();
    if (incomingByte == 'U') {
      Keyboard.press(UP_ARROW);
      delay(100);
      Keyboard.release(UP_ARROW);
    } else if (incomingByte == 'D') {
      Keyboard.press(DOWN_ARROW);
      delay(100);
      Keyboard.release(DOWN_ARROW);
    } else if (incomingByte == 'L') {
      Keyboard.press(LEFT_ARROW);
      delay(100);
      Keyboard.release(LEFT_ARROW);
    } else if (incomingByte == 'R') {
      Keyboard.press(RIGHT_ARROW);
      delay(100);
      Keyboard.release(RIGHT_ARROW);
    }
  }
}

Make sure your Arduino board is connected to your PC and selected in the Arduino IDE as the tar

#

get board, and the correct port is selected under Tools > Port before uploading the sketch.

When using the Keyboard library, it's also necessary to choose a compatible processor from the IDE's Tools > Processor menu.

If you continue to receive errors related to your Python script, please verify the names of the modules and variables are correctly declared and that the relevant packages have been imported.

#

@crisp lance aparex's Question:

why again doesnt the game allow pyautogui, ctypes, keybord.press, etc.?

Games often block input from libraries like pyautogui, ctypes, or direct calls to keyboard.press from Python scripts due to various reasons:

  1. Anti-Cheat Mechanisms: Most online games have anti-cheat systems designed to prevent cheating, which includes blocking simulated inputs from software to ensure all players are on a level playing field.

  2. DirectInput/XInput Use: Games commonly bypass the standard input methods that libraries like pyautogui use and instead use DirectX's DirectInput or XInput. These APIs communicate directly with the input device drivers, ignoring synthetic events generated by automation libraries.

  3. Security: Preventing synthetic input events helps avoid automation that could lead to unfair advantages or automated bots that could disrupt gameplay.

  4. Focus on Raw Input: Some games use raw input directly from the hardware which is less susceptible to faked input events, thereby blocking the high-level synthetic events generated by automation libraries.

Using an Arduino programmed to act like a keyboard bypasses some of these protections because it emulates a physical device sending real keypresses, not software-generated events. This method is more likely to be interpreted as genuine input from a player; however, it's crucial to respect the Terms of Service of the game, as using such methods might be against the game's rules and could lead to an account ban or other penalties.

crisp meteor
#

@crisp lance aparex's Question:

the arduino is an uno one

Understood, you're referring to the Arduino Uno, a popular microcontroller board based on the ATmega328P. It's widely used for electronics and prototyping projects.

#

@crisp lance aparex's Question:

#include "Keyboard.h" void setup() { Serial.begin(9600); Keyboard.begin(); } void loop() { if (Serial.available() > 0) { char incomingByte = Serial.read(); if (incomingByte == 'U') { Keyboard.press(UP_ARROW); delay(100); Keyboard.release(UP_ARROW); } else if (incomingByte == 'D') { Keyboard.press(DOWN_ARROW); delay(100); Keyboard.release(DOWN_ARROW); } else if (incomingByte == 'L') { Keyboard.press(LEFT_ARROW); delay(100); Keyboard.release(LEFT_ARROW); } else if (incomingByte == 'R') { Keyboard.press(RIGHT_ARROW); delay(100); Keyboard.release(RIGHT_ARROW); } } } change this script to work on an uno arduino

The Keyboard.h library and its functionalities, such as Keyboard.press(), are not natively supported on the Arduino Uno because it uses an ATmega328P microcontroller which does not have native USB capabilities.

The Arduino boards that can act as a USB device (like a keyboard) are those based on the ATmega32U4 or similar, such as the Arduino Leonardo or Arduino Micro. The ATmega32U4 can emulate USB devices because it has built-in USB communication.

To make a keyboard on an Arduino Uno, you would need to use additional hardware to emulate a USB device, such as the ATmega32U4, or use a serial-to-USB converter chip that can send keyboard signals to a computer.

One commonly used chip for this purpose is the V-USB, a software-only implementation of low-speed USB for AVR microcontrollers. Using V-USB, you can program the Arduino Uno to act like a USB human interface device (HID). However, this involves more complex wiring and additional firmware on the Uno.

Here is a very simplified example of how you could modify the code to output serial data that could be interpreted by a connected computer as keyboard input, but remember, your computer won't understand this as it is not USB HID signal:

void setup()
#

{
Serial.begin(9600); // start serial communication
}

void loop() {
if (Serial.available() > 0) {
char incomingByte = Serial.read();
// Output to serial instead of Keyboard.press():
if (incomingByte == 'U') {
Serial.println("UP_ARROW");
} else if (incomingByte == 'D') {
Serial.println("DOWN_ARROW");
} else if (incomingByte == 'L') {
Serial.println("LEFT_ARROW");
} else if (incomingByte == 'R') {
Serial.println("RIGHT_ARROW");
}
}
}


This code will simply send strings back to the computer over the serial port when it receives the characters 'U', 'D', 'L', 'R'. If you want to convert these into actual keyboard commands, you would need to have software running on the computer that reads the serial port and simulates the corresponding keypresses. This could be achieved with a language such as Python and libraries such as `pySerial` for serial communication and `pyautogui` for simulating keyboard events.
crisp meteor
#

hi hi

#

@crisp lance what did you do

crisp lance
#

Everything

#

I tried ctyped

#

I tried a seperatre mini computer to simulate inputs (Arduino)

crisp meteor
#

did it work

crisp lance
#

aint anything working >:(

crisp meteor
#

void loop() {
Serial.println("UP_ARROW");
}

#

are you sure

crisp lance
#

Idk, thats what the people told me

crisp meteor
#

i love C!

crisp lance
#

#include <Keyboard.h>

void setup() {
Serial.begin(9600);
keyboard.begin();
}

void loop() {
if (Serial.available() > 0) {
char incomingByte = Serial.read();
if (incomingByte == 'U') {
Keyboard.press(UP_ARROW);
delay(100);
Keyboard.release(UP_ARROW);
} else if (incomingByte == 'D') {
Keyboard.press(DOWN_ARROW);
delay(100);
Keyboard.release(DOWN_ARROW);
} else if (incomingByte == 'L') {
Keyboard.press(LEFT_ARROW);
delay(100);
Keyboard.release(LEFT_ARROW);
} else if (incomingByte == 'R') {
Keyboard.press(RIGHT_ARROW);
delay(100);
Keyboard.release(RIGHT_ARROW);
}
}
}

#

This is current code

crisp meteor
# crisp lance - #include <Keyboard.h> void setup() { Serial.begin(9600); keyboard.begin()...

try this

#include <Keyboard.h>

void setup() {
  Serial.begin(9600);
  keyboard.begin();
}

void loop() {
  if (Serial.available() > 0) {
      Keyboard.press(UP_ARROW);
      delay(100);
      Keyboard.release(UP_ARROW);
    
      Keyboard.press(DOWN_ARROW);
      delay(100);
      Keyboard.release(DOWN_ARROW);

      Keyboard.press(LEFT_ARROW);
      delay(100);
      Keyboard.release(LEFT_ARROW);

      Keyboard.press(RIGHT_ARROW);
      delay(100);
      Keyboard.release(RIGHT_ARROW);
  }
}
crisp lance
#

nope

#

C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino: In function 'void setup()':
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:5:3: error: 'keyboard' was not declared in this scope
keyboard.begin();
^~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino: In function 'void loop()':
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:10:7: error: 'Keyboard' was not declared in this scope
Keyboard.press(UP_ARROW);
^~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:10:22: error: 'UP_ARROW' was not declared in this scope
Keyboard.press(UP_ARROW);
^~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:14:22: error: 'DOWN_ARROW' was not declared in this scope
Keyboard.press(DOWN_ARROW);
^~~~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:18:22: error: 'LEFT_ARROW' was not declared in this scope
Keyboard.press(LEFT_ARROW);
^~~~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:22:22: error: 'RIGHT_ARROW' was not declared in this scope
Keyboard.press(RIGHT_ARROW);
^~~~~~~~~~~

exit status 1

Compilation error: 'keyboard' was not declared in this scope

crisp meteor
# crisp lance nope

try this

#include <Keyboard.h>

void setup() {
  Serial.begin(9600);
  Keyboard.begin();
}

void loop() {
  if (Serial.available() > 0) {
      Keyboard.press(UP_ARROW);
      delay(100);
      Keyboard.release(UP_ARROW);
    
      Keyboard.press(DOWN_ARROW);
      delay(100);
      Keyboard.release(DOWN_ARROW);

      Keyboard.press(LEFT_ARROW);
      delay(100);
      Keyboard.release(LEFT_ARROW);

      Keyboard.press(RIGHT_ARROW);
      delay(100);
      Keyboard.release(RIGHT_ARROW);
  }
}
crisp lance
#

Nope

#

C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino: In function 'void setup()':
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:5:3: error: 'Keyboard' was not declared in this scope
Keyboard.begin();
^~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino: In function 'void loop()':
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:10:7: error: 'Keyboard' was not declared in this scope
Keyboard.press(UP_ARROW);
^~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:10:22: error: 'UP_ARROW' was not declared in this scope
Keyboard.press(UP_ARROW);
^~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:14:22: error: 'DOWN_ARROW' was not declared in this scope
Keyboard.press(DOWN_ARROW);
^~~~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:18:22: error: 'LEFT_ARROW' was not declared in this scope
Keyboard.press(LEFT_ARROW);
^~~~~~~~~~
C:\Users\jumij\Documents\Arduino_1\Arduino_1.ino:22:22: error: 'RIGHT_ARROW' was not declared in this scope
Keyboard.press(RIGHT_ARROW);
^~~~~~~~~~~

exit status 1

Compilation error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

crisp lance
#

@crisp meteor Tmr we try with rasberry-pi?

#

(it was a rhyme :D)

crisp lance
#

@crisp meteor Ill try tmr with the rasberry pi.
That should work, shouldnt it? Since it basicly is a seperate computer and can just simulate a keyboard, right?

crisp meteor
#

before you buy anything you have to find out if it works as a keyboard or not

crisp lance
#

Nahy already got it. A very old one

crisp meteor
#

flap

crisp lance
#

Hmh?

crisp lance
#

I'll try tmr

#

Didn't find the time today and RN I'm tired af

crisp lance
#

I'll try on Monday

crisp meteor
crisp lance
#

Nah fr

#

I went to buy the cable Im missing today, FK 20 EUROS?!

#

I ordered it on amazon now for 5 euros, it will arive on monday or tuesday

crisp meteor
crisp lance
#

That was just fk ridicolus

crisp meteor
#

324 messages

#

325

#

326

#

327

#

328

#

329

#

330

#

331

#

332

#

333

#

334

crisp lance
#

Huh?

crisp meteor
crisp lance
#

Nice

crisp lance
#

@crisp meteor they literally just made it even harder

crisp lance
#

:like: fr

crisp meteor
#

L

crisp lance
#

Wtf

#

@crisp meteor

#

Amazon said "Tuesday or the day after that", the "your article was sent" mail didnt even come yet

crisp lance
#

Wtf

#

Still didnt come

#

Amazon fk trolling me?!

crisp meteor
crisp lance
#

fr

crisp lance
#

@crisp meteor I just bought the cable now for 13$ :

#

Amazon canceled the order

crisp meteor
#

@crisp lance aparex's Question:

You remember? I wantet to make a code, that searched a person on the map in a videogame, by using arrow keys, and checkscrean function. Various input methods didnt work, so you suggested a rasberry pie. I got one. Tell me the code for my python, aswell as my rasberry pie

It's great to hear you've got a Raspberry Pi for your project. Automassizing the in-game movement to locate a person using arrow keys within a video game requires both software and potentially hardware interaction.

Here are general steps you might follow and some sample code to help you get started.

Python Code for Raspberry Pi:

  1. Libraries: You will need to use libraries like pyautogui for automating keyboard input, and PIL or opencv-python for screen capturing and image analysis.

  2. Installing Libraries:

    You can install the required libraries using pip:

    pip install python3-xlib scrot python3-tk python3-dev
    pip install pyautogui
    pip install pillow
    pip install opencv-python
    
  3. Capturing Screen:

    Here's how you can capture the screen:

    import numpy as np
    import cv2
    from PIL import ImageGrab
    
    def capture_screen(region=None):
        # Capture the screen
        screen = np.array(ImageGrab.grab(bbox=region))
        # Convert to a format OpenCV can work with
        screen = cv2.cvtColor(screen, cv2.COLOR_BGR2RGB)
        return screen
    
  4. Finding the Person:

    You need to determine what criteria you will use to find the person on the screen. For simplicity, let's assume you have an image of the target to be found (target_image.png).

    def find_person(screen, target_img_path):
        # Read the target image
        target_img = cv2.imread(target_path, cv2.IMREAD_UNCHANGED)
        # Template matching
        result = cv2.matchTemplate(screen, target_img, cv2.TM_CCOEFF_NORMED)
        # Getting the location of the best match
        min_val, max_
#

val, min_loc, max_loc = cv2.minMaxLoc(result)
return max_loc if max_val > SOME_THRESHOLD else None

`SOME_THRESHOLD` is the confidence level you set for a match, typically between 0.8 and 1.

5. **Moving in the Game**:

You can simulate key presses using `pyautogui`:
```python
import pyautogui

def move(direction):
    pyautogui.keyDown(direction)
    pyautogui.sleep(0.5)  # Hold key for half a second
    pyautogui.keyUp(direction)
  1. Main Loop:

    Here is a simple main loop to bring it all together:

    TARGET_IMG_PATH = 'path/to/target/image.png'
    SCREEN_REGION = (0, 0, 800, 600)  # x, y, width, height of your game window
    
    while True:
        screen = capture_screen(SCREEN_REGION)
        person_location = find_person(screen, TARGET_IMG_PATH)
        if person_location:
            print("Person found at:", person_location)
            # Implement logic to move accordingly
            # For instance, if the person is found to the left, move the character to the left
            # move('left')
            break
        else:
            # Keep searching
            move('left')  # This is an example, use actual game logic
    

Ensure you have proper permissions to interact with the game using such scripts, and be careful to comply with the game's terms of service to avoid any violation.

Important Notes:

  • This is a skeleton script and requires you to modify and expand based on the specifics of the video game in question.
  • If the game has anti-cheat protection, it may detect this automation as cheating.
  • The performance of this script depends on the processing power of your Raspberry Pi and the demands of the game.

Finally, testing and iterating are key. You may need to adjust the code significantly based on the game’s response to simulated input and the accuracy of your target matching algorithm.

#

@crisp lance aparex's Question:

py autogui didnt work. The game doesnt register the fake inputs. Thats why I want to use a rasberry pie for the inputs

To utilize a Raspberry Pi for simulating keyboard presses in a manner that a game will recognize may require sending signals that mimic an actual keyboard. A common approach for this is to turn your Raspberry Pi into a USB Human Interface Device (HID), which emulates a keyboard at a hardware level.

Here’s a high-level overview of what you need to do:

  1. Use GPIO Pins: Connect buttons to the GPIO pins on the Raspberry Pi. Each button represents a direction key (up, down, left, right).

  2. Configure as HID: You’ll need to set the Raspberry Pi to act as an HID device. On devices like the Raspberry Pi Zero, this can be fairly straightforward by setting it up as a USB gadget. However, for other Raspberry Pi models, you might need additional hardware like a Teensy board or an Arduino that can act as an HID device to interface with the GPIO.

For a Raspberry Pi Zero, you can start with these steps:

  • Edit the /boot/config.txt file and add:

    dtoverlay=dwc2
    
  • Edit the /boot/cmdline.txt and append:

    modules-load=dwc2,g_hid
    
  • You'll need to create a new file /etc/modules-load.d/g_hid.conf with:

    g_hid
    
  • Finally, create your HID gadget configuration in /sys/kernel/config/usb_gadget/. This step includes creating a directory for your gadget, setting up idVendor and idProduct values, defining HID attributes, and enabling the gadget. There are online resources and guides available if you search for "Raspberry Pi Zero USB HID gadget".

Once you have this configured:

  1. Write Python Script: Write a Python script that waits for a GPIO pin to be activated, and when it is, the script sends the corresponding keyboard signal through the HID interface. Here's a basic example of how you might handle a single button press:

#

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Example for one button

while True:
input_state = GPIO.input(18)
if input_state == False:
# This is where you need to send the HID event. This will be specific to how you've configured the HID gadget
print('Button Pressed')
time.sleep(0.2)


4. **Integrate with HID events**: The part `# This is where you need to send the HID event` in the script above is where you'd integrate with the HID gadget functionality to send the button press.

Please be aware that this project requires a good understanding of both the Raspberry Pi hardware and the Linux system's USB/HID interfaces. It's not trivial and goes beyond a simple script that can be provided in this kind of format.

Always make sure to check the game's terms of service before attempting such integration, as hardware emulation can be against the terms and lead to your account being banned or other consequences.
#

@crisp lance flap!!!

crisp lance
#

huh?

crisp meteor
#

YOU STILL TRYING

crisp lance
#

ofc

#

btw, just noticed when searching the post

crisp meteor
#

@crisp lance aparex's Question:

107.042.437 40.591.048 33.414.039 31.861.113 27.904.918 24.995.778 22.639.828 22.314.170 21.244.121 19.404.782 18.677.931 17.511.979 15.696.923 15.093.869 14.192.160 13.380.652 13.327.339 13.245.239 12.871.916 12.592.719 12.546.523 12.419.651 11.916.403 10.953.695 10.932.168 10.919.371 9.603.673 9.352.168 9.093.513 8.958.822 8.579.124 8.108.606 8.053.810 7.663.684 7.073.209 6.617.934 6.574.851 6.570.968 5.453.379 5.290.741 5.254.718 5.115.761 5.023.513 4.596.672 4.463.155 4.323.444 3.984.681 3.859.945 3.829.138 3.786.279 3.722.191 3.676.353 3.658.503 3.506.010 3.496.774 3.449.252 3.133.521 3.118.805 2.947.984 2.937.106 2.888.755 2.753.898 2.587.134 2.541.145 2.465.413 2.319.345 2.291.784 2.136.770 2.113.341 2.075.204 2.054.634 2.046.007 2.038.685 2.035.846 2.005.390 1.913.481 1.899.988 1.895.065 1.855.890 1.834.737 1.820.082 1.814.038 1.758.963 1.732.961 1.653.845 1.560.436 1.543.622 1.443.221 1.438.146 1.433.849 1.374.174 1.344.777 1.168.969 1.154.758 1.147.094 1.051.974 1.049.156 1.030.307 955.238 951.517 940.824 924.279 899.188 855.312 854.487 837.259 823.813 789.643 690.482 599.846 589.747 586.264 544.977 543.678 537.477 523.181 500.398 452.96 424.496 398.947 346.504 336.002 253.055 244.407 235.121 223.56 210.473 204.702 186.253 176.65 128.578 107.592 106.71 104.309 98.021 68.849 55.02 37.061 26.513 1.12 1.115 203 165 136 124 123 95 84 79 77 75 75 73 73 71 71 70 69 60 60 53 53 48 46 45 43 43 42 40 40 38 38 35 35 34 31 31 30 30 30 29 29 28 28 24 23 21 21 20 19 18 17 16 16 15 15 15 15 15 15 14 14 13 12 11 11 11 11 11 10 10 10 10 10 10 9 9 9 8 8 8 8 8 8 7 7 7 6 6 6 5 5 4 4 4 3 3 3 3 3 3 3 2 2 2 2 2 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Seperate those numbers with , and remove the decimal points

107042437, 40591048, 33414039, 31861113, 27904918, 24995778, 22639828, 22314170, 21244121, 19404782, 18677931, 17511979, 15696923, 15093869, 14192160, 13380652, 13

#

327339, 13245239, 12871916, 12592719, 12546523, 12419651, 11916403, 10953695, 10932168, 10919371, 9603673, 9352168, 9093513, 8958822, 8579124, 8108606, 8053810, 7663684, 7073209, 6617934, 6574851, 6570968, 5453379, 5290741, 5254718, 5115761, 5023513, 4596672, 4463155, 4323444, 3984681, 3859945, 3829138, 3786279, 3722191, 3676353, 3658503, 3506010, 3496774, 3449252, 3133521, 3118805, 2947984, 2937106, 2888755, 2753898, 2587134, 2541145, 2465413, 2319345, 2291784, 2136770, 2113341, 2075204, 2054634, 2046007, 2038685, 2035846, 2005390, 1913481, 1899988, 1895065, 1855890, 1834737, 1820082, 1814038, 1758963, 1732961, 1653845, 1560436, 1543622, 1443221, 1438146, 1433849, 1374174, 1344777, 1168969, 1154758, 1147094, 1051974, 1049156, 1030307, 955238, 951517, 940824, 924279, 899188, 855312, 854487, 837259, 823813, 789643, 690482, 599846, 589747, 586264, 544977, 543678, 537477, 523181, 500398, 452960, 424496, 398947, 346504, 336002, 253055, 244407, 235121, 223560, 210473, 204702, 186253, 176650, 128578, 107592, 106710, 104309, 98021, 68849, 55020, 37061, 26513, 1120, 1115, 203, 165, 136, 124, 123, 95, 84, 79, 77, 75, 75, 73, 73, 71, 71, 70, 69, 60, 60, 53, 53, 48, 46, 45, 43, 43, 42, 40, 40, 38, 38, 35, 35, 34, 31, 31, 30, 30, 30, 29, 29, 28, 28, 24, 23, 21, 21, 20, 19, 18, 17, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 13, 12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 0, 0, 0,

crisp lance
#

Even chatgpt wont do it right

crisp meteor
#

ai isnt smart enough yet

#

i am doing GDT rn

#

making my own OS

crisp meteor
#

@crisp lance aparex's Question:

name = .... score = .... goal = ..... x = "" y = 0 for i in range(len(name)): x += name[i]+" " y = score / goal x += y print(x) x = "" y = 0 whats wrong with this code?

Here are a few issues with the provided code snippet:

  1. name, score, and goal are placeholders and should be assigned to actual values, i.e., name should be assigned to a string, and score and goal should be assigned to numbers.

  2. You need to ensure that score and goal are numbers (integers or floats), not strings or other types. Division (/) is not defined for other types.

  3. y = score / goal will raise a ZeroDivisionError if goal is zero. You should check whether goal is not 0 before performing the division.

  4. x += y will cause a TypeError because you're trying to concatenate a string (x) and a number (y). You need to convert y to a string before concatenating.

  5. The indentation of the variable x = "" and y = 0 seems like it's supposed to reset the values after printing. But since their values are overwritten each loop iteration, there's no need to reset them before the loop starts again.

Here's a corrected version of the code:

name = "Alice"
score = 85  # Example score
goal = 100  # Example goal

x = ""
y = 0

for i in range(len(name)):
    x += name[i] + " "
    
    # Ensure goal is not zero to avoid ZeroDivisionError
    if goal != 0:
        y = score / goal
        x += str(y)  # Convert the number to a string before concatenating
    else:
        x += "undefined"  # Handle the case where goal is zero

    print(x)
    x = ""  # Reset x for the next iteration
    y = 0   # Reset y for the next iteration (although not strictly necessary)

Remember to replace name, score, and goal with the actual values you intend to use.

#

@crisp lance aparex's Question:

TypeError: unsupported operand type(s) for /: 'list' and 'list'

The error message "TypeError: unsupported operand type(s) for /: 'list' and 'list'" indicates that you are trying to use the division operator on two lists, which is not allowed. You must ensure that score and goal are individual numeric values, not lists, when performing division.

If score and goal are intended to be lists of the same length where you want to perform element-wise division, you would have to modify the code to divide each corresponding pair of elements. Here's how you could adjust your loop for that situation:

names = ["Alice", "Bob", "Charlie"]  # List of names
scores = [85, 75, 95]  # Corresponding list of scores
goals = [100, 90, 105]  # Corresponding list of goals

for i in range(len(names)):
    x = names[i] + "   "
    
    # Calculate score divided by goal for each element, if goal is not zero
    if goals[i] != 0:
        y = scores[i] / goals[i]
        x += str(y)  # Convert the number to a string before concatenating
    else:
        x += "undefined"  # Handle the case where goal is zero
    
    print(x)

In this corrected code:

  1. names, scores, and goals are now lists with the respective values for each name.
  2. The loop iterates over the list names, and uses the index i to reference corresponding elements in scores and goals.
  3. Division is performed for each pair of numbers from scores and goals.
  4. The script checks if goals[i] is zero to avoid a ZeroDivisionError.

Make sure the names, scores, and goals lists match in length, or you will run into an IndexError when the index i does not exist in one of the shorter lists.

crisp lance
#

@crisp meteor :3

#

Finishing the first thing now >:)

#

Your help wont get wasted pepelove

crisp meteor
#

lets see

crisp lance
#

@crisp meteor

#

I basicly got everythign set up, but I justr cant accec the fk pie

#

I installed the imager, etc. but I cant accec the pie, idk