最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Erorr calling a module that uses pygetwindow_pygetwindow_win.py - Stack Overflow

programmeradmin0浏览0评论

(I'm kind of new, did some stuff but still a noob) I believe my problem is at pygetwindow_pygetwindow_win.py

I'll try my best explain the program and issue, I have multiple "modules/files" doing stuff etc., From this "Bigmodule" I'm Loading a pkl file, and then I have this loop where I call another module I've imported "get_window_click_map_randomizer", this module: get_window_click_map_randomizer, which uses some other modules, but I've tested it works fine, the problem is on this Bigmodule part of the code:

def interpretar_acciones(archivo, window_title):
    try:
        archivo = f"secuencias/{archivo}.pkl"
        with open(archivo, 'rb') as file:
            acciones = pickle.load(file)
    except FileNotFoundError:
        print("EXCEPT interpretar_acciones El archivo no existe.")
        return []
    for accion in acciones:
        print(f"FOR {accion}:")
        x, y, tipo_accion = accion
        if tipo_accion == 'AutomoveHandler':
            print("tipo_accion == 'AutomoveHandler'")
            get_window_click_map_randomizer(x, y, window_title,5)
        else:
            print(f"Acción desconocida {tipo_accion} en coordenadas ({x640}, {y375})")

And then I get this ERROR:

FOR (0.469, 0.8, 'AutomoveHandler'): #this is the print inside the FOR
tipo_accion == 'AutomoveHandler' #this is the print inside the IF
Traceback (most recent call last):
  File "C:\Users\pablomir4\Desktop\lessfoldersmoremodules\basic\CreateNLoadSecuencias.py", line 154, in <module>
    interpretar_acciones(archivo, window_title)
  File "C:\Users\pablomir4\Desktop\lessfoldersmoremodules\basic\CreateNLoadSecuencias.py", line 63, in interpretar_acciones
    get_window_click_map_randomizer(x, y, window_title,5)
  File "C:\Users\pablomir4\Desktop\lessfoldersmoremodules\basic\ClickAtMir.py", line 35, in get_window_click_map_randomizer
    bring_window_to_front(window_title)
  File "C:\Users\pablomir4\Desktop\lessfoldersmoremodules\basic\MirWindowHandler.py", line 28, in bring_window_to_front
    window.activate() # Bring the window to the front
  File "C:\Users\pablomir4\AppData\Local\Programs\Python\Python313\Lib\site-packages\pygetwindow_pygetwindow_win.py", line 246, in activate
    _raiseWithLastError()
  File "C:\Users\pablomir4\AppData\Local\Programs\Python\Python313\Lib\site-packages\pygetwindow_pygetwindow_win.py", line 99, in _raiseWithLastError
    raise PyGetWindowException('Error code from Windows: %s - %s' % (errorCode, _formatMessage(errorCode)))
pygetwindow.PyGetWindowException: Error code from Windows: 0 - La operación se completó correctamente.

(last line says "La operación se completó correctamente." which translates to "The operation was completed successfully." yet it didn't) I've noticed that the icon in the taskbar starts blinking, but it's supposed to bring the window to the front and click (it never happened when testing it from the module itself) That's the problem, what do I do?

Post Data: I did something that somehow makes it "work better" but still I think it's a bad solution At the start of the Bigmodule I'm doing a call of the imported module function with a random input like this : get_window_click_map_randomizer(0, 0, window_title,0) and then It works "better" but sometimes still fails, and I'm having this "unwanted" function call

TL;DR: I tried to load a pkl file with (x,y,action) info, Then call a module that I've programed that clicks at a specific window and place. get_window_click_map_randomizer(x,y,window,duration), when I call this module inside a for loop with each line of the pkl file lines it throws an error, BUT If I use the module at least 1 time before entering the for loop to iterate, it doesn't give me error and works inside the for loop, I don't want to call the function before the for loop, it's an unwanted action and making a undesired "fake" click

发布评论

评论列表(0)

  1. 暂无评论