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

SplitSnapActiveWindow & MS Edge (chromium) #7

Open
digitalAssetStore opened this issue Aug 1, 2020 · 12 comments
Open

SplitSnapActiveWindow & MS Edge (chromium) #7

digitalAssetStore opened this issue Aug 1, 2020 · 12 comments

Comments

@digitalAssetStore
Copy link

digitalAssetStore commented Aug 1, 2020

In MS Edge (chromium) latest version for me the new code is not working

        Send ^l^c
	SetKeyDelay, 100
	Send ^w^n^v{enter}
	SetKeyDelay, -1
	sleep 500
	SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)

It seems the key-point is the delay between ^l and ^c.
For me the following works

    Send ^l
    Send ^c
    Send ^w^n^v{enter}
    sleep 500
    SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)
@glenviewjeff
Copy link
Owner

glenviewjeff commented Aug 1, 2020 via email

@digitalAssetStore
Copy link
Author

Variant1: Not working

    SetKeyDelay, 75
    Send ^l^c^w^n^v{enter}
    SetKeyDelay, -1
    sleep 500
    SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)

Variant2: Not working

	SetKeyDelay, 75
    Send ^l^c
	Send ^w^n^v{enter}
	SetKeyDelay, -1
	sleep 500
    SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)

Variant3: Working

    Send ^l
    Send ^c
    Send ^w^n^v{enter}
    sleep 500
    SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)

@glenviewjeff
Copy link
Owner

glenviewjeff commented Aug 1, 2020

This is certainly a PC/memory/resource issue. I just tested the existing code on Edge on my PC and it worked fine. Try increasing the SetKeyDelay until you get it to work. This is one of the idiosyncrasies in using a tool like AHK, it's often a tradeoff of execution speed vs. moving slowly to accommodate burdened PCs. For example, this guy waits an entire second before pasting the URL.

Ideally I'd be able to monitor what's going on through WinWait, but I'm not confident I could come up with a reliable algorithm to do so. For example, I could watch for a window title change after closing the tab, but that would only work if there weren't tabs with identical titles. This really should be a feature in Chrome, to split off tabs via keyboard control. This kludge doesn't maintain the history of the tab. The Vimium extension apparently offers true keyboard support for splitting off a tab.

@digitalAssetStore
Copy link
Author

Understand and agree.

But I tried "SetKeyDelay, 5000" in first line, still not working.
The result is that the clipboard from last ctrl+c gets pasted to the browser address bar and "^c" is not considered.

The most compact working version is
Send ^l
Send ^c^w^n^v{enter}
sleep 500
SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)

It seems to be that "Send Ctrl+L" takes to much time to be screwed through the cpu/memory/resource/storage...
Or "Send" has some issues, or, or, or...

Pragmatically: If this is the working code for most browsers in the world, I could (would have to) live with it.

@glenviewjeff
Copy link
Owner

There's also this Chrome plugin.

@glenviewjeff
Copy link
Owner

Ugh, what a pain in the butt. I think I have something that should be totally reliable and much faster. No delays from keyboard input or anything, either. Just the natural processing delay from opening a new browser window, etc. I also added a feature to backup and restore the clipboard, which previously was overwritten with the tab's URL. Let me know if this works.

SplitSnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight) {
  oldClipboard = clipboardAll
  clipboard =
  while(clipboard == "") {
    SendInput ^l^c
  }
  SendInput ^w^n
  WinWaitNotActive
  SendInput %clipboard%{enter}
  clipboard = %oldClipboard%
	SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)
}


@digitalAssetStore
Copy link
Author

✔️ WORKS!

PS: Really appreciate your clever solution. Compact, impact-free to clipboard and effective!

@digitalAssetStore
Copy link
Author

One more thing.

Please change first line
FROM
oldClipboard = clipboardAll
TO
oldClipboard := clipboardAll
else you have in the clipboard the word "clipboardAll" afterwards.

@glenviewjeff
Copy link
Owner

Ah, thanks; didn't realize ahk has that goofy distinction of := and =. I am pretty sure I tested it and must have thought that clipboardAll was previously on my clipboard from some edits to the source :)

Incidentally, would you find it useful to maintain focus on the original browser window so that you can rapid fire split off tabs into quadrants? Besides that, one other neat hotkey might be to with one keystroke, move four tabs to respective quadrants. Not sure if I'd ever use this in practice though.

@digitalAssetStore
Copy link
Author

digitalAssetStore commented Aug 3, 2020

Q: Incidentally, would you find it useful to maintain focus on the original browser window so that you can rapid fire split off tabs into quadrants?
A: Absolutely YES (currently the focus is nowhere).

Q: Besides that, one other neat hotkey might be to with one keystroke, move four tabs to respective quadrants. Not sure if I'd ever use this in practice though.
A: See no practical usage. Have first to sort the tabs in order 1,2,3,4. In the time doing so I opened them already with Ctrl+Alt+Win+NumPad AND did control exactly where to but them (e.g. order 2,4,3,1 or 4,2,3,1, etc.).

@glenviewjeff
Copy link
Owner

Try this and let me know what happens. My PC was acting very strangely after I tried it.

  oldClipboard = clipboardAll
  prevWin := WinActive("A")
  clipboard =
  while(clipboard == "") {
    SendInput ^l^c
  }
  SendInput ^w^n
  WinWaitNotActive
  SendPlay %clipboard%{enter}
  clipboard := %oldClipboard%
	SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)
  if prevWin
    WinActivate, ahk_id %prevWin%

@digitalAssetStore
Copy link
Author

  • First line: Please add ":=" as proposed before already (yes ahk assignment syntax is rather crazy)
  • Use SendInput as in previous code not SendPlay (= older version with side effects)
  • As soon as I uncomment 2nd and last line --> Not working
    (Likely opening new webbrowser not finished, but next/last line already triggers. No workaround so far)
    prevClipboard := clipboardAll
    ;// WinGet, prevWinId, ID, A
    clipboard := ""
    while(clipboard == "") {
        SendInput ^l^c
    }
    SendInput ^w^n
    WinWaitNotActive
    SendInput %clipboard%{enter}
    clipboard = %prevClipboard%
    SnapActiveWindow(winPlaceVertical, winPlaceHorizontal, winSizeHeight)
    ;// WinActivate, ahk_id %prevWinId%

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

2 participants