Hello KM community,
I coded myself a macro that selects a substring of the front browser URL and pastes that into another application.
My problem is that it works very inconsistently. Sometimes the correct string gets pasted but other times it duplicates multiple letters in the string or pastes the result double.
Also I have noticed some interference with the "bring windows to front" action where it triggers application coded hotkeys.
So to understand what I am trying to do I will explain it with pictures here.
When I am on the website (Premarket Movers & News • Benzinga) and click on a hyperlink to a subpage on that website (the tickers displayed in blue in the table: Core Scientific Stock (NASDAQ:CORZ), Quotes and News Summary - Benzinga) I want KM to copy the ending of the URL and paste it into my charting app and then refocus on the browser window. The if:else condition is for either the Tradingview App window on my right or left additional monitor.
The Macro is only available in the Browser hence the trigger.
Following the same macro as for the right window if condition.
Now what I am having trouble with is the inaccuracy of the result of the action as described above.
When the tab is already loaded and I simply switch tabs from another tab everything works fine, you can see the string/ticker it pasted in the watermark or title of the tab (CORZ) in this screenshot.
But when I click on the hyperlink it pastes some combination of the letters in random order and composition. Picture of the Hyperlink and result below.
Like here COCROZRZ instead of CORZ like above.
I tried putting in several delays between the actions of 0.1-1s as I thought it has something to do with the URL not getting loaded completely before the Variable get filled but nothing with success so far.
EDIT:
To test if it is something with the variables not getting filled correctly I built in this check, which shows that even when I click on the hyperlink and it pastes the random string the variables are correct.
The other problem is with strings/tickers that start with a "B".
When the Tradingview window gets focused instead of pasting the ticker (which works by simply typing the the ticker and hitting enter) it triggers an in-app shortcut to open the brokerage tab instead (in app shortcut is shift+B).
Somehow the focus window action is triggering this.
Result of the app shortcut triggering - the rest of the string after the B gets pasted orderly (it should be BNTC) but also only when tab has been preloaded.
This has become a wall of text and pictures, I hope you can follow me and thanks for your help & time in advance.