Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buggy SetURL in UIA_Browser #43

Open
enaaab460 opened this issue Sep 19, 2024 · 9 comments
Open

Buggy SetURL in UIA_Browser #43

enaaab460 opened this issue Sep 19, 2024 · 9 comments

Comments

@enaaab460
Copy link

enaaab460 commented Sep 19, 2024

After V1, Seturl method adds a space and l (as in " l") at the end of the url using Chrome.
for example
UIA_Chrome("A").Navigate("www.yahoo.com")
would instead search for "www.yahoo.com l"
To fix it on my end, I reverted it to the past behavior , which is focus url edit box and send enter

Lines 798-799

@Descolada
Copy link
Owner

The spacebar has always been added to prevent an accidental auto-complete with some other URL that was autosuggested. Why the "l" is added I'm not too sure. Can you try whether replacing line 799 with ControlSend "{LCtrl up}{LAlt up}{LShift up}{RCtrl up}{RAlt up}{RShift up}{Ctrl down}{Ctrl down}l{Ctrl up}{Enter}", , "ahk_id" this.BrowserId changes anything?

Otherwise, have you changed your default SetKeyDelay values?

@enaaab460
Copy link
Author

Otherwise, have you changed your default SetKeyDelay values?

Yes
I have SetKeyDelay(-1, -1)
When I commented it out, it worked
That said,

this.URLEditElement.SetFocus()
ControlSend "{Enter}", , this.BrowserId

in Lines 798-799 works without having to comment out setkeydelay

ControlSend "{LCtrl up}{LAlt up}{LShift up}{RCtrl up}{RAlt up}{RShift up}{Ctrl down}{Ctrl down}l{Ctrl up}{Enter}", , "ahk_id" this.BrowserId

Still doesn't work
image

@Descolada
Copy link
Owner

I've pushed an update to try and fix this issue. Please see if the latest UIA_Browser works for you.

@enaaab460
Copy link
Author

I've pushed an update to try and fix this issue. Please see if the latest UIA_Browser works for you.

It works now
Thanks!

@aaronm32
Copy link

I am still having this issue in the latest version v2-1.0.2. SetKeyDelay is the default (unchanged). When using chrome and running seturl("https://www.hulu.com/watch/bf5b0d1a-b99b-492b-9748-86ff5a0669dc") it adds an extra " l" at the end of the url. It doesn't happen with every url, just certain values occasionally.

@Descolada
Copy link
Owner

UIA_Browser.SetUrl uses UIA_Browser.ControlSend to send the keystrokes, and SetKeyDelay doesn't affect it. Try manually changing the values of SetKeyDelay -1, 1 line in that method, for example SetKeyDelay 0,1 or SetKeyDelay 1,1. I tried to find a compromise between speed and reliability but obviously I failed :)

@Descolada Descolada reopened this Dec 11, 2024
@aaronm32
Copy link

It's something strange with UIA_Browser.SetUrl using this.URLEditElement.ValuePattern.SetValue(newUrl " ") causing the extra 'l' in the value. If I comment that line out, it then runs this.URLEditElement.LegacyIAccessiblePattern and that one works.

@Descolada
Copy link
Owner

What I believe is happening is that sometimes the Ctrl+L has failed (because of too short delay between keys) causing to navigate to for example google.com l. Then, once SetURL pastes google.com and focuses the addressbar with Ctrl+L, Chrome helpfully autocompletes it to google.com l and then Enter is sent to navigate, thus navigating to an incorrect URL. One solution is to manually paste that URL and delete the incorrect autocomplete entry manually by clicking the X next to the autosuggestion. Another option would be to modify the ControlSend to send {Ctrl down}l{Ctrl up}{BS}{Enter}, because then either the autocomplete gets deleted, or the extra space at the end gets deleted, either way is fine.

@aaronm32
Copy link

aaronm32 commented Dec 11, 2024

Yes, clearing the browser history fixed it. I played around to see if there is a universal special char that will go to the address bar and it's F6. In Chrome and Firefox a single F6 works and in MS Edge it takes F6+F6. So what seems to work universally is send {F6}{Enter}{F6}{Enter} and that way no characters will inadvertently get added to the url and no modifiers with delay problems.

Edit: I tested and in theory that should work, but because the address bar may already be selected it actually needs 3 rounds of F6+Enter: {F6}{Enter}{F6}{Enter}{F6}{Enter}

Edit2: So Some browsers will focus to the toolbars with F6 if focus is already in the address bar. Hitting F10+F10 switches between settings and address bar consistently on MS Edge and Chrome, but not Firefox. After more testing this no modifiers combo seems to work the best universally: {F10}{F10}{Enter}{F6}{Enter}{F6}{Enter}

Edit3: One final note that if right click menu is up, even ctrl+l won't work. So add an esc at the beginning. This is it: {Esc}{F10}{F10}{Enter}{F6}{Enter}{F6}{Enter}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants