jhriverasa / wakfu-farmscript

A simple python script that allows to detect and harvest resources on screen, not intended like a bot but a semi-automated tool that performs some clicks over the correct place c:
MIT License
9 stars 0 forks source link

ERROR: Run Hotkey callback failed #3

Open Skitoris opened 6 months ago

Skitoris commented 6 months ago

Hey, i guess this error happens because of this part of the code?

wakfu-farmscript-main\FarmScriptGUI.py {False, True, 'Key.f1', 'Wheat', 'Farmer', 'Astrub', 'Active'} ERROR: Run Hotkey callback failed Process finished with exit code 0 (when i shutdown the process)

image

jhriverasa commented 6 months ago

Is this common or just happened once? Seems like it couldn't detect which key was pressed and the line "srtKey = srt(key)" throws an error, basically tries to cast to string something that can't be represented as a string. If this is a recurrent problem I'm gonna investigate it further. Also would be very useful to know which conditions led to this problem... AKA: how do I reproduce this bug :)

Skitoris commented 6 months ago

I didn't succeed to farm with the tool...

The settings I set in app are above ... Wheat/Astrub...

Do you need anymore infos?

Skitoris commented 6 months ago

The tool does detect the wheat, click on it, I see the menu to collect popping up. But then, nothing clicks on the icon to collect... If it can help you!

jhriverasa commented 6 months ago

The tool does detect the wheat, click on it, I see the menu to collect popping up. But then, nothing clicks on the icon to collect... If it can help you!

That is a different problem, this one is related to image detection, (wakfu) developers change the images sometimes, just updated the repo, so i recommend you to pull, and tell me if now works. 😄

Skitoris commented 6 months ago

Tried your with your new images.

Wheat: ERROR: Run Hotkey callback failed Tuberbulb: Found seeds and resource ERROR: Run Hotkey callback failed Barley: ERROR: Run Hotkey callback failed

Am i missing something? XD

Skitoris commented 6 months ago

Could it be something about screen resolution or screen format? Are you in 1080p Fullscreen? Fullscreen windowed? Windowed?

Should i take a snip of the ressource and try it myself?

jhriverasa commented 6 months ago

Could it be something about screen resolution or screen format? Are you in 1080p Fullscreen? Fullscreen windowed? Windowed?

Should i take a snip of the ressource and try it myself?

Thats not related to screen resolution, yes you have to use 1920*1080p.

what you can do is replace the function this way.

def runHotkeyCallback(self, key):
    print(key)
    print(type(key))
    srtKey = str(key)
    if srtKey in F_KEYS:  # Only accepts F1,f2,f3.... keys
        self._bindings.get(srtKey)()

and show what you get in console.

Skitoris commented 6 months ago

Unhandled exception in listener callback Traceback (most recent call last): File "l__init__.py", line 228, in inner return f(self, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "_win32.py", line 290, in _process self.on_release(key) File "__init__.py", line 144, in inner if f(*args) is False: ^^^^^^^^ File "\hotkeymgr.py", line 69, in runHotkeyCallback self._bindings.get(srtKey)() File "\routines.py", line 184, in advanced_farming_actions seedsLocation = list(seedsLocation) ^^^^^^^^^^^^^^^^^^^ File "***__init__.py", line 257, in _locateAll_opencv raise ImageNotFoundException('Could not locate the image (highest confidence = %.3f)' % result.max()) pyscreeze.ImageNotFoundException: Could not locate the image (highest confidence = 0.743)

Process finished with exit code 0

Skitoris commented 6 months ago

I need to spamclick the F1 button and it finally detects the wheat. tried with salt and it was great. It is a problem of detection for sure!

jhriverasa commented 6 months ago

Umm but I wonder if you got a log of your keys like this? (this is what happened when I replaced the function) imagen

jhriverasa commented 6 months ago

It is important to know if your environment is actually capturing the key when is pressed, if that is not the case an error like "ERROR: Run Hotkey callback failed" should be shown. Also it's important to notice that "little resources" like wheat are hard to find (you can check the readme file), so sometimes it just WON'T find them on your screen, but even if these resources are not found, the script should not stop its execution, only a message in console "Resource not found" should appear. I've tested by myself collecting some wheat and works great.

jhriverasa commented 6 months ago

Finally, I think is good to discard that the error is generated due to dependencies, so here are the specific versions, that im using:

Name: PyAutoGUI Version: 0.9.53

Name: PySimpleGUI Version: 4.60.4

Name: Pillow Version: 10.1.0

Name: opencv-python Version: 4.7.0.72

Name: pynput Version: 1.7.6

It is possible to check them via pip show Also I just updated the requirements.txt file so you can run: pip install -r requirements.txt

Skitoris commented 6 months ago

Sorry, i was AFK for a couple days!

I pulled your modifications and tried it again.

{False, True, 'Astrub', 'Active', 'Key.f1', 'Wheat', 'Farmer'} ERROR: Run Hotkey callback failed ERROR: Run Hotkey callback failed ERROR: Run Hotkey callback failed {False, True, 'Astrub', 'Finest sea salt', 'Active', 'Miner', 'Key.f1'} ERROR: Run Hotkey callback failed ERROR: Run Hotkey callback failed ERROR: Run Hotkey callback failed

Process finished with exit code 0

Could it be the weather in game? It was raining when I did this test... This must change the aspect of the image and it isn't detected anymore? Thanks for you help tho, I really appreciate it!

Skitoris commented 6 months ago

Hello again!

{'Astrub', False, True, 'Active', 'Key.f1', 'Farmer', 'Wheat'} Found seeds and resource Found seeds and resource ERROR: Run Hotkey callback failed Found seeds and resource ERROR: Run Hotkey callback failed Found seeds and resource ERROR: Run Hotkey callback failed Found seeds and resource Found seeds and resource ERROR: Run Hotkey callback failed Found seeds and resource Found seeds and resource Found seeds and resource Found seeds and resource ERROR: Run Hotkey callback failed Found seeds and resource ERROR: Run Hotkey callback failed Found seeds and resource ERROR: Run Hotkey callback failed

It's getting better ! Less errors! Tool detects resources, most of the time, but fails on clicking the collecting icon...

jhriverasa commented 6 months ago

Well I've investigated but never got that specific error. I'm Unable to reproduce this behavior.