-
Notifications
You must be signed in to change notification settings - Fork 93
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
export function to focus window if possible #77
Comments
Yes, I've noticed this too before. But the purpose of this library is generally not to store data, this is the implementation detail of the AHK script you are making. You can write it in a script: store the old focused window and restore it on OnChangeDesktop. |
I see. I can def store the last focused in an array or something such that the indices match the desktop number and a[idx] = window id. But how do I focus the window? Like is there a function i call to focus a window with a window ID? How do I get the window ID in the first place? Sorry very new to ahk and dlls in general, don't know much other than js and py that's why confused. |
I'm sorry, I think this works https://www.autohotkey.com/docs/v2/lib/WinActivate.htm I am just not sure on how to make autohotkey preserve that data now, like how do i write to a file, if I do, can the ahk lang allow me to split the input read as a string to an array on a comma delimeter if i wanna store like that etc.? sorry for bothering can you please provide some level of guidance? I am very new to AHK. |
You don't need to write to a file, you can use an dictionary.
On left side of dictionary you have current desktop number, on right side you have active window handle. I don't have time to test this myself at the moment. But I had this same setup earlier. I'll paste some relevant snippets:
These are from AHK1 days, so you might need to change them. Idea is to store it before you change desktop and restore it from the dictionary OnChangeDesktop |
Btw, the reason my example script doesn't do that at the moment is because it should work without these tricks. But Windows is flaky when changing desktops, sometimes it remembers the focus and sometimes it doesn't. |
hey! thanks for the reply! and sorry for the late reply, got busy somewhere and couldn't even think about this. Could you paste the whole part from your ahk 1 setup? I bet it won't have many changes, Sorry for troubling you again! |
Hey for anyone encountering this issue, I was having a tough time using AHK and navigating the sparse documentation, so I ended up making a simple hotkeydaemon to use this dll here. |
when using the ahk v2 script it doesn't focus the window in front when it has already switched to a workspace, this is incredibly annoying and I was hoping that there could be a function that could be used to focus already stored window ID or something that had the focus last time. Thanks!
The text was updated successfully, but these errors were encountered: