It doesn't work exe.


  • QA Engineer

    We need to get the code down to the exe file. Used a pyinstaller, everything was compromised, but when an exe file was launched, the console would appear on a millisecond and disappear immediately. There's no tex in it, it's empty.
    There are lines of concealing console in the code, trying to comment on them and recompiling them, but the problem remains. Can we get an exe file on another one?
    Actually, I could and I did it with that code, but I don't remember what I used. There was a white background site with detailed instructions. It also called for a separate setup.py. Does anyone remember what the website is?
    I even have the bill of that story, maybe you could find out where it was built?

    UPD:
    When an exe file is launched, the console writes

    Traceback (most recent call last):
      File "main.py", line 5, in <module>
    ModuleNotFoundError: No module named 'telethon'
    [16492] Failed to execute script 'main' due to unhandled exception!
    
    import random
    from time import sleep
    import win32gui
    import win32.lib.win32con as win32con
    from telethon import TelegramClient
    

    def file_to_string_array(filename):
    result = []
    with open(filename) as f:
    for i in f.readlines():
    result.append(i.replace('\n', ''))
    return result

    def split_input(array):
    result = []
    while True:
    try:
    result.append([array[0], array[1], array[2]])
    array.pop(0)
    array.pop(0)
    array.pop(0)
    except IndexError:
    break
    return result

    def first_run_to_false():
    with open('telegram_input.txt') as f:
    lines = f.readlines()
    lines[0] = 'False\n'
    with open('telegram_input.txt', 'w') as f:
    f.writelines(lines)

    async def main():
    await client.send_message(chat, text)
    sleep(2)
    async for message in client.iter_messages(chat):
    if 0 < message.button_count < 11:
    await message.click(random.randint(0, message.button_count - 1))
    break

    if name == 'main':
    data = file_to_string_array('telegram_input.txt')
    first_run = data[0]
    users = split_input(data[1:])
    chat = '@aeawed'
    text = 'Hello'

    for user in users:
        client = TelegramClient(user[2], int(user[0]), user[1])
        with client:
            if first_run == 'False':
                the_program_to_hide = win32gui.GetForegroundWindow()
                win32gui.ShowWindow(the_program_to_hide, win32con.SW_HIDE)
            client.loop.run_until_complete(main())
            # if first_run == 'False':
            #     win32gui.ShowWindow(the_program_to_hide, win32con.SW_SHOW)
    
    if first_run == 'True':
        first_run_to_false()
    



  • The problem is, I've been copying a project file all the time to get a pyinstaller, but apparently, when the folder is being copied, imports are not copied. Helped. pip install telethon In a new folder.
    Also the_program_to_hide = win32gui.GetForegroundWindow() win32gui.ShowWindow(the_program_to_hide, win32con.SW_HIDE) This isn't exactly the right place. The console, first of all, will appear at the very beginning anyway, as these lines are marked with an unclosed salt. Second, these lines are in the cycle. The first time they'll hide the console, and every next time they're active windows that can be closed only through the Dispatch.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2