Morph21 / MercuryTrade-Community-Fork

An overlay application for Path of Exile(Tracking, Trading, Chat, etc)
MIT License
140 stars 24 forks source link

Hotkeys Not Clearing Previous String Data #113

Closed Lokkedian closed 2 years ago

Lokkedian commented 2 years ago

At some point after use, MT fails to clear the previous command from the string it uses for constructing the chat messages. I get sequences like this (from my Client log - DateTime and other stuff at the beginning removed): This example is from clicking the Whisper link in poe trade for 3 people. @To Bulturatorex: Hi, I would like to buy your Sacred Orb listed for 14 chaos in Archnemesis (stash tab "Curr"; position: left 77, top 1) @To Bulturatorex@Andokainn: Hi, I would like to buy your Sacred Orb listed for 15 chaos in Archnemesis (stash tab "S1"; position: left 12, top 8) : The specified character does not exist. @To Bulturatorex@Andokainn@DObRyak_KoK: Hi, I would like to buy your Sacred Orb listed for 16 chaos in Archnemesis (stash tab "3"; position: left 12, top 10) : The specified character does not exist.

This example is from using the hotkeys on a trade: @From Borzalic_Archtr: Hi, I would like to buy your The Poet's Pen Carved Wand listed for 8 chaos in Archnemesis (stash tab "$"; position: left 4, top 3) @To Borzalic_Archtr: one minute @To Borzalic_Archtr/invite: Borzalic_Archtr

The "one minute" hotkey worked, but then clicking the Invite hotkey did not clear the "@Borzalic_archtr" before adding the "/invite Borzalic_Archtr"

This happened with the current version + previous version (I only just started using this fork).

Lokkedian commented 2 years ago

The above issue is not because of internal strings not clearing. I noticed that if I have a previous whisper with someone, when I press Enter to open chat, it automatically has the @ of the last person I'd whispered. If I leave this and press a hotkey, the above issue occurs. If I backspace all the crap out of the chat input area and press enter to close chat, then the buttons work. Hopefully this makes sense.

kevindevm commented 2 years ago

this could easy be fixed by opening the chat with ctrl+shift+enter so will always start with only one character "%" so MT can send backspace and always erase all or can open the chat normally and send ctrl+a then pasting

Lokkedian commented 2 years ago

I don't know how this Fork inputs the strings into PoE, but if you manually open chat with ENTER, then paste (Ctrl-V), it will paste the string correctly, every time. I am not sure how this is managing to concatenate the clipboard contents into a garbled mess unless the fork is opening chat, pressing backspace and then pasting. I feel like just opening the chat and pasting is the answer.

Lokkedian commented 2 years ago

I looked VERY briefly at it (not through an IDE - no idea what's calling and when), and this is the general flow of pasting a message into PoE Chat:

private void executeMessage(String message) {
        this.gameToFront();
        StringSelection selection = new StringSelection(message);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(selection, null);
        MercuryStoreCore.blockHotkeySubject.onNext(true);
        robot.keyRelease(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);

        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_A);

        robot.keyPress(KeyEvent.VK_BACK_SPACE);
        robot.keyRelease(KeyEvent.VK_BACK_SPACE);

        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
        MercuryStoreCore.blockHotkeySubject.onNext(false);
    }

This means that it is doing this: Enter -> Ctrl-A -> Delete -> Ctrl-V -> Enter

So basically what you're suggesting. Either this function I grabbed is not what's being called, or something else is preventing this sequence from executing properly.

Lokkedian commented 2 years ago

I think I got it! CTRL-A no longer selects all in the chat bar. It does nothing. I have no idea how to compile a java app. Can someone replace this in all cases:

        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_A);

with this:

        robot.keyPress(KeyEvent.VK_SHIFT);
        robot.keyPress(KeyEvent.VK_HOME);
        robot.keyRelease(KeyEvent.VK_SHIFT);
        robot.keyRelease(KeyEvent.VK_HOME);
kevindevm commented 2 years ago

I have no idea how to compile a java app

me neither i would love to see some instructions to compile an run

Morph21 commented 2 years ago

@Lokkedian I looked into this issue and honestly I couldn't reproduce your problem. Script which is used to send messages is exactly the same for hotkeys and normal buttons so I don't know how this error happens.

@kevindevm here is an detailed instruction about building running java appliaction https://github.com/Morph21/MercuryTrade-Community-Fork/wiki/How-to-compile-and-run-MercuryTrade