Coder Social home page Coder Social logo

windows-desktop-switcher's People

Contributors

crossan007 avatar elijas avatar gorbunovav avatar grmblfrz avatar h0r1z0n avatar j0natran avatar kannymayo avatar othervnousiainen avatar pbozzay avatar perlence avatar pmb6tz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-desktop-switcher's Issues

Add shortcut to make window available on all desktops

This is very useful for me ,thanks author!

I use strokens plus work with this ahk script,which can make mouse move to control the virtual desktop switch. left right top button of mouse move to switch four virtual desktops. which is really wonderful.

but ,I have a new idea that pin a application on the top of any virtual desktop nomatter I switch it.
whether can make it ?

Add ability to create a number of empty desktops on launch

I don't like to create desktops on demand, so I would like the script to create 9 empty desktops when it's launched.

I've achieved this with the following code:

createInitialDesktops()
{
    global DesktopCount, CurrentDesktop, NumInitialDesktops

    OutputDebug, Creating %NumInitialDesktops% initial desktops

    Current := CurrentDesktop

    Loop, % NumInitialDesktops - DesktopCount
    {
        createVirtualDesktop()
    }

    OutputDebug, Switching back to desktop %Current%
    _switchDesktopToTarget(Current)
}

The problem with this solution is that NumInitialDesktops must be hard-coded inside the main script, and can't be imported from user_config.ahk. A potential solution could be to introduce a new script user_variables.ahk. (And rename user_config.ahk to user_hotkeys.ahk?)

Disabling the "Ctrl + Alt" combination

Thanks a lot for your great tool that has been a lifesaver so far!

I was using a similar software that is no longer maintained.

Is there any way to disable the "Ctrl + Alt" feature described below?
Using Ctrl + Alt instead of CapsLock also works, without any additional changes necessary (e.g. use + + 1 to switch to the Desktop 1, just as you would use + 1)

It keeps working even when disabling the CapsLock shortcut on the user_config.ahk file !
Many symbols require the "Alt Gr" (@, #, {) on FR keyboards.
Moreover "Ctrl + Alt" is equivalent to "Alt Gr" on such keyboards.
Therefore this default behavior is interfering a lot with my typing!
Is there any way to disable it?

You will see what I mean by referring to the AZERTY layout.

Many thanks!

Suggestion: Move current active window to a desktop?

I often have to open Win + Tab to organize my desktops, although I feel it interrupts my flow, especially when I have to open it for moving just one window.

The easy way to implement this would be to use the dll that is already present by calling this function from it: MoveCurrentWindowToDesktop(number) (source here)

@pmb6tz, would you approve such PR? I'd also suggest these hotkeys with the PR: switching to desktop 1 with Tab + 1, moving active window to desktop 1 with CapsLock + 1

EDIT: I've already implemented this in my own private fork, works flawlessly

Desktop switching doesn't operate on Surface Go

Hello,

I am trying to use this code on my surface go, but it doesn't allow me to shift to another desktop. I have installed the addons as mentioned here.

I was able to get around this issue using AHK codes. A sample is as per below:

`
KeyWait, CapsLock

	Send, {LCtrl down}{LWin down}
	
	Loop 10
	{
		
		Send, {Left}
		Sleep, 100
	
	}
	
	Sleep, 25 
	
	Loop 8 ;Desktop 9
	{
		
		Send, {Right down}{Right up}
		Sleep, 200 
	
	}
	
	Send, {LWin up}{LCtrl up}

`

`LWin` mapping works, but `RWin` mapping does not

When I remap the bottom section with LWin, the hotkeys work properly:

; User config!
; This section binds the key combo to the switch/create/delete actions
LWin & 1::switchDesktopByNumber(1)
LWin & 2::switchDesktopByNumber(2)
LWin & 3::switchDesktopByNumber(3)
LWin & 4::switchDesktopByNumber(4)
LWin & 5::switchDesktopByNumber(5)
LWin & 6::switchDesktopByNumber(6)
LWin & 7::switchDesktopByNumber(7)
LWin & 8::switchDesktopByNumber(8)
LWin & 9::switchDesktopByNumber(9)
LWin & c::createVirtualDesktop()

When I remap the bottom section with RWin, the hotkeys do not work properly:

; User config!
; This section binds the key combo to the switch/create/delete actions
LWin & 1::switchDesktopByNumber(1)
LWin & 2::switchDesktopByNumber(2)
LWin & 3::switchDesktopByNumber(3)
LWin & 4::switchDesktopByNumber(4)
LWin & 5::switchDesktopByNumber(5)
LWin & 6::switchDesktopByNumber(6)
LWin & 7::switchDesktopByNumber(7)
LWin & 8::switchDesktopByNumber(8)
LWin & 9::switchDesktopByNumber(9)
LWin & c::createVirtualDesktop()

I created a test script to verify that LWin and RWin are working properly in other scripts and it behaves as expected:

LWin & 1::Send, testing lwin & 1
RWin & 1::Send, testing rwin & 1

Any ideas or insight?

Switching leaves window out of focus

Hi, I have a question. I am switching between desktops with <!1::switchDesktopByNumber(1) and <!2::switchDesktopByNumber(2) In dekstop 1 I am using a txt editor, in desktop 2 something else. When I switch from desktop 1 to 2 and then back to 1 I can't continue writing till I click on the txt editor. All windows are out of focus when returning to the desktop. This doesen't happen when I slide with 4 fingers on the trackpad to switch between the desktops. Can you help me out please?

Thank you

Pin a window to all desktops

Surfacing a comment from issue #11 which I think should be considered as a feature.

  1. I am now looking for another feature which is already implemented in Windows but I haven't yet figured out how to do it on AutoHotKey:

How do I tell Windows (or the active program) to pin its window or all its app's windows to all desktops?

In another virtual desktop manager, I found an AutoHotKey line that looks something like
PostMessage, % WM_SYSCOMMAND , % desktopnumber, % windowid, , % "ahk_id " windowid
(exact line is line 82 of https://github.com/jpginc/windows10DesktopManager/blob/master/dllWindowMover.ahk )

To the best of my understanding, what this is doing is telling that window that it is now on the other desktop.

I have no idea how to derive this command, and I am also wondering how also to derive a command that would tell the window (or the windows shell, if that is the case) to pin the app (or just the current window) to all Virtual Desktops.


  1. Also, I thought of and (sloppily) implemented another cool feature for a virtual desktop manager, which is to show the icons differently on different desktops. I did this by calling an external program called DesktopOK, which has the ability to save and load arrangements, and can be called from command line.

  1. I think it is somewhat silly that our programs are ahead of Window's basic functionality... I mean, I searched but I couldn't even find an official Windows API or documentation with the command for pinning the windows. So maybe if someone tells the right people at Microsoft we can get these features (or at least I can figure out how to make my own buttons; haha).

The main reason I am even writing these codes is because I want these features myself and they are not implemented yet >_<

Thank you all for sharing and I will look into this.

Originally posted by @ghost in #11 (comment)

Hotkey for placing windows on different desktops

Hey!

I'm usually not using this platform so I don't know if this is the right place for feature request. Sorry if it's not!

Could you implement a hotkey for placing a window on another desktop? Like pressing Ctrl+Alt+ and the window will be transferred to the specified desktop.

That would make your already great tool near perfect. Thanks for making this either way!

Capslock - actually stays locked

Hi!

First off: thanks! Your script is great. But I figure something is still not quite in place as sometimes (but lately more often) capslock actually stays locked after using it.

Is there someway to heal this issue?

Using ALT does not really pose as an alternative as it is not a as convenient hotkey.

I appreciate any help!

Thanks

[minor] Possible future bug fixes

When reading the docs about the dll that is used here, I've noticed that there is one helper function that should probably be in this repo too. But I haven't noticed any bugs myself that would require this, though, so I won't submit a PR just yet.

RestartVirtualDesktopAccessorProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "RestartVirtualDesktopAccessor", "Ptr")

; Restart the virtual desktop accessor when Explorer.exe crashes, or restarts (e.g. when coming from fullscreen game)
explorerRestartMsg := DllCall("user32\RegisterWindowMessage", "Str", "TaskbarCreated")
OnMessage(explorerRestartMsg, "OnExplorerRestart")
OnExplorerRestart(wParam, lParam, msg, hwnd) {
    global RestartVirtualDesktopAccessorProc
    DllCall(RestartVirtualDesktopAccessorProc, UInt, result)
}

There are other useful functions such as a Hook that will execute right after a desktop switch event, even when desktop is not switched with the script. Also there are functions GoToDesktopNumber, GetCurrentDesktopNumber, etc that may or may not work better than the current ones.

Send multiple commands while holding modifier keys.

There is a time to time scenario where I have to move back and forth the virtual desktop to see the contents.
And it really bugged me that I had to keep release & push modifier keys(ctrl, alt, shift etc...) again to send the command.

Put below commands into the user_config.ahk to hold down the modifier keys after command.
(If you are still pressing them, of course)

#HotkeyModifierTimeout -1

This way you can jump desktop back & forth just by pressing 1 & 2 while hold down the modifier key.

By the way, thank you for great script. It really helped me moving back to windows from mac.

more info : https://www.autohotkey.com/docs/commands/_HotkeyModifierTimeout.htm

The script behaves weirdly if you switch left when you are already at the leftmost desktop.

I've noticed that, at the leftmost desktop, if you press the command for moving to the desktop to the left an odd number of times, the next command to shift to the desktop to the right does not do anything (but then the next command to move right works correctly). If you press the command for moving to the desktop to the left an even number of times (when you are at the leftmost desktop), the script works fine. I haven't tried it for the opposite situation (when you are one the right most desktop moving right), but I imagine it is the same case there.

Source code of virtual-desktop-accessor

Hi,
Are you planning to release the source code of virtual-desktop-accessor.dll? I would like to inspect its workings. Also, headers would be helpful.

Thank you.

Add 2D grid navigation

Great job with this project! I don't think any of us could bear using Windows VD if there we couldn't use keyboard shortcuts.

I was wondering... in the past when I was a Mac user, I used an application called TotalSpaces2 on the Mac (https://totalspaces.binaryage.com/). It's a VD manager for the Mac but what I really like about it is that you can set up a your desktops in a 2D grid (22, 33...) and you can use the arrow keys to quickly navigate between them. I liked it much more than the single row in Windows VD. The main benefit being you can more quickly navigate between desktops (less key presses) and you can set your programs up in a simple pattern that's easy to remember and navigate (I find navigation more challenging in the linear system due to the need to cycle left and right repeatedly or to remember the number of all your desktops).

I have very little experience with AHK (and any type of programming) but I was trying to mod another script simply by inputting each and every direction the system would have to navigate if left, right, up or down was pressed on a 3 by 3 grid. I was also trying to set it up so that if left was pressed on desktop 1 in a 3*3 grid then the navigation would wrap around to desktop 3. Similarly hitting up on desktop1 would wrap around to desktop 7. Not sure how hard or easy this would be to implement but if this is a feature you could add then I would be forever grateful (probably some other users would appreciate this feature too). :)

Show current desktop number in the tray bar

Thank you so much for this script. This has been the one thing that has been bothering me with the Windows virtual desktops, and now they are finally workable.

I don't know if you do feature requests, but just in case: Would it be possible to show the number of the current virtual desktop on the system tray icon? That way I always know what desktop I'm on.

Add background image switch

Except for pop notification for pin or unpin operation, switch backgroud with desktop can make switch more clear .

AutoAssociateBackgroundWithDesktop := false
BackgroundPicPaths := ["C:\Users\A\Pictures\VDPic\day.jpg", "C:\Users\A\Pictures\VDPic\snow.jpg", "C:\Users\A\Pictures\VDPic\sex.jpg", "C:\Users\A\Pictures\VDPic\cool.jpg"]


……

changeBackgroundWithDesktopId()
{
    global CurrentDesktop, BackgroundPicPaths, AutoAssociateBackgroundWithDesktop
    filePath := BackgroundPicPaths[CurrentDesktop]
    if (AutoAssociateBackgroundWithDesktop and filePath and FileExist(filePath)) {
        DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, filePath, UInt, 1)
   }
}

_Originally posted by @fanlushuai in https://github.com/pmb6tz/windows-desktop-switcher/issues/55#issuecomment-629744607_

Option to disable Caps Lock regular function

Hey!

First, love the script and everything about it! Thanks for putting time and effort into creating it. Hopefully you will continue to update it as i now have adapted it fully into my everyday use and it's awesome!

I Just have one suggestion, and please forgive me if this is the wrong place to submit this, not really too common with GitHub.

Anyway, the Caps Lock key is perfect for the usage of this script, love it. The only thing is, i never use the "regular" function of the standard Caps Lock key as i only use Shift when needed. So, sometimes when switching desktops i end up with the Caps Lock function turned on resulting in capital letters.

Is there any way to configure Caps Lock to only toggle desktops and not the "regular" function?

Keep up the great work!

(Tried to label this as an suggestion or enhancement but couldn't find out how.)

possible to use right and left arrows?

In autohotkey we usually have the ability to use left and right arrow keys. In the user config I have tried:

^{Right}::switchDesktopToRight()            
^{Left}::switchDesktopToLeft()

but getting error that these keys are not valid.

Suggestion: Add a hotkey to cycle through all desktops.

Thanks for this amazing script, much appreciated.

I would however love to see a feature where you cycle through all the windows with just one hotkey, for example windows key + tab (although that example, specifically, is used for that stupid virtual desktop overview that Microsoft added).

So if you have lets say three virtual desktops, when you are cycling through them with the new hotkey, when reaching the last desktop, if you were to click the cycle button again you would go back to the first desktop.

Thanks again!

Edit: I made my own solution, but I see that you already created a pull request. Although I don't need it now, I think others might find it useful.

Current window not shifting to other virtual desktop

Hi @pmb6tz

This is such a useful script, thank you for building it! I've been working remotely now for a few weeks and this script has been a saviour when only having one screen.

I'm trying to get the MoveCurrentWindowToDesktop(desktopNumber) to work, but haven't had any success.

  • The WinGet, activeHwnd, ID, A command works and pulls the right ID
  • The switchDesktopByNumber(desktopNumber) works and sends me to the right desktop

The program stays on the original desktop. So the issue must be this line:

DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, desktopNumber - 1)

Which looks at:

global MoveWindowToDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "MoveWindowToDesktopNumber", "Ptr")

I haven't done any dll call stuff yet, so unsure where the issue may lay or if I missing something. Please let me know what I should look at to get this working. Thanks.

Regards,

submeg

retain focus on windows

It would be great if there was an option to remember the active window before switching at every desktop, so it would be focused once switched back.
I assume a simple alt+tab won't work, since it produces unexpected behaviour at rapid switching. You would probably need to store some window UUIDs, assuming that's doable.

Focus window after dekstop switch not working

So the WinActivate after switching a desktop is not working for me, on update 1809 and 1903.

As a workaround, I put the line "Send, {ALT DOWN}{TAB}{ALT UP}" just before the line "focusTheForemostWindow(targetDesktop)" (which can be commented out). The line simulates pressing Alt+Tab shortly, which just focusses the top most window.

I don't know what causes the problem, and if anyone else is also having it, but I think it comes down to getForemostWindowIdOnDesktop(n) not returning a windowID.

Reduce animation

First of all, thank you for great piece of work!

However, I am often using 10+ task views (crazy, right?) and switching between them becomes a bit nauseating experience (especially going from 1 to 10). Is there any way to just go "straight" to the desktop without going through all of the other ones?

deleted

EDIT: my bad, misread the docs

SessionInfo is not always 1

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

Hotkeys intercepted by cmd windows

I've noticed that if a command prompt (cmd) window is currently focused, it captures the caps+num sequence, preventing desktop switching entirely. I personally use command windows quite a lot, so I'm adding an item to take a look at this issue.

Create debugger tool

I think it would be great to try and create a debugger tool which would test various parts of this script and/or allow to automatically/manually choose desktop switching methods, hmm. It might help to provide quickfixes or better bug reports for script users.

This could provide clues to help fix all of our currently open issues (#59 #46 #54)

switchDesktopToLastOpened() doesn't always work correctly

I'm using the default key binding: CapsLock & tab::switchDesktopToLastOpened().

Steps to reproduce:

  • Start the script
  • Go to desktop 2 through CapsLock & 2::switchDesktopByNumber(2)
  • Go to desktop 1 through CapsLock & 1::switchDesktopByNumber(1)
  • <I receive a message from a colleague, clicking it automatically switches me to that desktop which is at desktop 2>
  • Execute switchDesktopToLastOpened()
  • Result: nothing happens.

Now it's not hard to see what's happening here, the variable LastOpenedDesktop is only set in _switchDesktopToTarget (LastOpenedDesktop := CurrentDesktop). Because of this, any other way of moving to another desktop will not register into the variable LastOpenedDesktop, thus leaving value 2 in LastOpenedDesktop, even though I'm currently at desktop 2 and 1 was my previous desktop.

tl;dr: this program assumes it is in complete control over switching desktops, leading to broken functionality

I've thought about this for a while, but I haven't been able to come up with a clean solution.

Switching across multiple desktops

My setup has 4 virtual desktops, and I noticed that often times when switching from first to fourth desktop, some windows from second or third or even both appear flashing on fourth desktop. I guess that's because to get to it I have to cycle through each desktop in between.

I've managed to fix that[1] by choosing target desktop on Task View and only then switching to it. It goes like this:

  • Press Win + Tab to open Task View
  • Press Tab to focus desktops
  • Press Right n times, where n is target desktop number - 1
  • Press Enter to open selected desktop

On the downside you can see a bit of Task View opening animation, but the wait is unnoticeable.

If you encountered this problem before and you're OK with the solution, I'd be grateful to create a PR.

[1]Perlence@a8cb3e0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.