#๐Ÿ”’ Trying to get this python script to generate 11-digit codes, then paste them.

69 messages ยท Page 1 of 1 (latest)

earnest yacht
#

I used chat GPT to generate this following script:

import random
import string
import pyperclip
import pyautogui
import time

def generate_random_code(length):
characters = string.ascii_letters + string.digits
return ''.join(random.choice(characters) for _ in range(length))

def main():
num_codes = int(input("Enter the number of codes to generate: "))
code_length = 11

# Generate random codes
generated_codes = []
for _ in range(num_codes):
    code = ''.join(random.choices(string.ascii_uppercase + string.digits, k=code_length))
    generated_codes.append(code)

# Join the codes with newline characters for easier pasting
codes_to_paste = '\n'.join(generated_codes)

# Copy the codes to the clipboard
pyperclip.copy(codes_to_paste)

# Simulate keyboard input to switch to the application where you want to paste the codes
# Replace the application_name with the name of your application
# You may need to adjust the sleep time according to your system's speed
application_name = "Your Application Name"
time.sleep(1)  # Wait for 1 second before switching
pyautogui.click(pyautogui.locateCenterOnScreen(application_name + '.png'))
time.sleep(1)  # Wait for 1 second after switching

# Simulate keyboard input to paste the codes into the text box
pyautogui.hotkey('ctrl', 'v')

if name == "main":
main()

Keep in mind i have no idea how any of this works, i know a bit of HTML and CSS and that's it, i want the code to generate 11-digit codes then paste them into a separate application.

eager lotusBOT
#

@earnest yacht

Python help channel opened

Remember to:

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

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

unique spade
#

The problem with using ChatGPT to generate code is that you don't know how to fix something if it gives you broken code (which it usually does).

#

Do you have any interest in learning Python?

earnest yacht
#

honestly no, but if there's no other solution then i might as well

unique spade
#

!res here are some great resources (free and paid)

eager lotusBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

unique spade
#

You can always hire somebody at fiverr or some other site.

earnest yacht
#

i'm thinking that might be the best option

unique spade
#

A lot of people here aren't going to want to debug GPT-generated code that might not even work in the first place.

earnest yacht
#

are there any options to pay someone here?

unique spade
#

No we don't do that.

earnest yacht
#

right i see so stricly help based

unique spade
#

!rule 9

eager lotusBOT
#

9. Do not offer or ask for paid work of any kind.

earnest yacht
#

does the code pasted above look right from your persepctive?

unique spade
#

I don't know, I haven't really looked at it.

earnest yacht
#

that's fair, do you think it's likely someone will be willing to help?

#

or not really

#

i know its asking for a lot

#

so i'm doubtful

unique spade
#

Maybe, everybody's different. You can stick around and wait but these posts will close after an hour of inactivity.

crisp sequoia
#

if you want any shot at somone helping you should also format the code so it's readable

#

!code

eager lotusBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

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

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

For long code samples, you can use our pastebin.

earnest yacht
#

okay let me try

marsh temple
#
print("This is how you use the code format")

@earnest yacht

mild violet
mild violet
#

the backtick is left of the z on my keyboard, or copy this one -> `

earnest yacht
#

alright let me try

marsh temple
mild violet
# eager lotus

You can also copy from here and paste the code where the print() is

mild violet
marsh temple
mild violet
earnest yacht
#

when i put any text in "print (" ")" it stops working

mild violet
#

```py
copy this and put code here
```

earnest yacht
#
import random
import string
import pyperclip
import pyautogui
import time

def generate_random_code(length):
    characters = string.ascii_letters + string.digits
    return ''.join(random.choice(characters) for _ in range(length))

def main():
    num_codes = int(input("Enter the number of codes to generate: "))
    code_length = 11

    # Generate random codes
    generated_codes = []
    for _ in range(num_codes):
        code = ''.join(random.choices(string.ascii_uppercase + string.digits, k=code_length))
        generated_codes.append(code)

    # Join the codes with newline characters for easier pasting
    codes_to_paste = '\n'.join(generated_codes)

    # Copy the codes to the clipboard
    pyperclip.copy(codes_to_paste)

    # Simulate keyboard input to switch to the application where you want to paste the codes
    # Replace the application_name with the name of your application
    # You may need to adjust the sleep time according to your system's speed
    application_name = "Your Application Name"
    time.sleep(1)  # Wait for 1 second before switching
    pyautogui.click(pyautogui.locateCenterOnScreen(application_name + '.png'))
    time.sleep(1)  # Wait for 1 second after switching

    # Simulate keyboard input to paste the codes into the text box
    pyautogui.hotkey('ctrl', 'v')

if __name__ == "__main__":
    main()
#

like this?

mild violet
#

Yooooo ๐Ÿผ

#

Perfect

earnest yacht
#

man that was hard, my python journey is gonna be hard

#

so i know i have to install these two applications; pyperclip, pyautogui

#

as of now i have windows visual studio open to compile it, that's what i'd use to compile right?

#

sorry im like super new to all of this hahaha

mild violet
#

I;'d say more like run the code.

marsh temple
earnest yacht
#

right, is that cuz it's a script, not necessarily an application

marsh temple
#

Normally like typing a command in the terminal python yourscriptname.py

mild violet
#

Also, What is this supposed to do?
Test some codes from somewhere?
Like something you're not supposed to be doing?

marsh temple
earnest yacht
#

it's just to generate random codes for unlocking items in a game

unique spade
#

You know that sort of thing is usually against terms of service?

#

Which game?

mild violet
#

Yeah, so those items you're supposed to earn with currency or whatever right?

#

So that's where my help ends and you shouldn't ask for help with this here. ๐Ÿ™‚

earnest yacht
#

there's no paid currency in the game, it's just collection based

earnest yacht
#

but thank you for the help up until now

#

i greatly appreciate it

mild violet
#

If you need help with anything else feel free to open another thread and I'll be happy to assist ๐Ÿ™‚

earnest yacht
#

I understand, thank you, do you by any chance have any useful resources i can use further learn python?

unique spade
earnest yacht
#

thank you, i'll close the thread

eager lotusBOT
#
Python help channel closed

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

#

๐Ÿ”’ Trying to get this python script to generate 11-digit codes, then paste them.