pmb6tz / windows-desktop-switcher

An AutoHotKey script for Windows that lets a user change virtual desktops by pressing CapsLock + <num>.
MIT License
1.23k stars 230 forks source link

SessionInfo is not always 1 #6

Closed Perlence closed 8 years ago

Perlence commented 8 years ago

If you sign out and then sing in again, there won't be reg key at ...\SessionInfo\1\..., it will be ...\SessionInfo\2\....

Perlence commented 8 years ago

I tried to address the issue here https://github.com/Perlence/windows-desktop-switcher/commit/942b8fb3deb2890cebbec8406dbcb5c1e1b38d55, by looping an arbitrary amount of times, reading subsequent SessionInfos from registry, but I'm not sure what will happen when more than one user sign in.

pmb6tz commented 8 years ago

+1 for being proactive :-). I do feel like we should come up with a programmatic way to get the current session id--this solution seems a little risky. A brief search led me to think calling this function using an AHK DllCall like this would potentially do it?

Perlence commented 8 years ago

Thank you for direction, here's my take on this https://github.com/Perlence/windows-desktop-switcher/commit/4aba5908e995c3d270be56f9becf41a3d7de8b0e. Here I exchange Process ID of AHK for Session ID.

pmb6tz commented 8 years ago

@Perlence, if that's sufficiently tested feel free to make a PR for it. Looks pretty good to me!

hawkins commented 8 years ago

@Perlence I might be crazy, but is your fork really working for switching to specific desktops or to next/previous? It doesn't appear to work for me, yet DebugView is only showing my the current process and session IDs. The current pmb6tz version does work fine for me, however.

Perlence commented 8 years ago

@hawkins Maybe it's not clearly named, I meant to switch to previous desktop, i.e. the one where you were before current, not the one that's on the left.

DebugView is only showing my the current process and session IDs

I guess it doesn't advance to parsing REG_DATA, is session ID you see correct?

hawkins commented 8 years ago

@Perlence Oops, our usage of previous is conflicting here. It makes more sense in the context of your work than in the NA/PS bindings from my commits. I'm not sure what to call mine then! Regardless...

is session ID you see correct?

Yes, I see the correct session ID.

I've further discovered, no matter what global DesktopCount is set to, I have to first use CapsLock+C to create a new desktop before any other features will work, despite already having more than 1 virtual desktop in Windows.

Perlence commented 8 years ago

@hawkins Did you try opening Task View Win + Tab after reloading the script? I noticed it gets stuck sometime and this combo releases it. I tested the session-info branch on another PC, and it did work.

Perlence commented 8 years ago

@hawkins I might have found out why the script didn't work in your setup. I noticed that just after a fresh boot, no matter what SessionId is, there's no CurrentVirtualDesktop key in registry. So I applied some safety measures to handle such scenario in https://github.com/Perlence/windows-desktop-switcher/commit/c31105d032354015afc80f7add83794cce88cd1f

hawkins commented 8 years ago

Did you try opening Task View Win + Tab after reloading the script? I noticed it gets stuck sometime and this combo releases it.

I did open task view (by instead clicking the icon beside the start button), but it did not seem to change anything.

I might have found ...

Great! Looking forward to trying this out tonight!

hawkins commented 8 years ago

@Perlence That worked without requiring opening task view or creating a new desktop first!

Are your rebindings (alt 1-4) just for your own sake?

Perlence commented 8 years ago

That worked without requiring opening task view or creating a new desktop first!

Cool, I'm glad it worked :relaxed:

Are your rebindings (alt 1-4) just for your own sake?

Yes, I like it this way.

pmb6tz commented 8 years ago

@hawkins @Perlence I made you guys collaborators. Having some medical issues with my hands right now but don't want to be blocking useful updates. I'll try to be around but in general if one of you could review the other's pull requests that would be an easy way of reaching consensus if that's something you're comfortable with :-).

Perlence commented 8 years ago

@pmb6tz That's sad news. Get well and keep your chin up!

hawkins commented 8 years ago

Sorry to hear that, pal. Hope you're feeling better soon!

Perlence commented 8 years ago

Resolved in 2e0d5d3517f3f783921775b4e9fc0da22d04943e.