-
Notifications
You must be signed in to change notification settings - Fork 71
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
[VM-Clean-Up] Sort Desktop icons by type #909
Conversation
I tested this and ran into a couple of issues depending on what might have been selected or not in the background before executing the function. Sometimes it didn't work and other times it would open a folder up that was on the desktop. I believe I found an alternative that seems to work though! I changed the key strokes line to be |
(New-Object -ComObject Shell.Application).toggleDesktop(); | ||
Start-Sleep -Milliseconds 100; | ||
$objShell = New-Object -ComObject WScript.Shell; | ||
$objShell.SendKeys("^{ }+{F10}oi"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't seem to always work depending on what might have been in focus before executing. I tried it with a folder having been selected before switching to the powershell terminal and executing the command and also with a folder not selected and ran into varying issues.
I was able to modify the key strokes to this and it seems to work more consistently:
^a {F5}+{F10}oi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emtuls doesn't Control+space (^{ }
) unselect the folder for you? Can you elaborate on the issues and the purposed solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, if there are several folders selected it does run into issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the code, good catch @emtuls!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments explain issue.
d81a19a
to
721e51a
Compare
Introduce `VM-Sort-Desktop-Icons` to sort Desktop icons by type using `WScript.Shell` to replicate the manual steps. This function is called from `VM-Remove-DesktopFiles` (called from `VM-Clean-Up`) to avoid leaving empty spaces after removing Desktop icons. Ensure no file(s) or folder(s) is/are selected in `SendKeys` by selecting all items and unselect them.
721e51a
to
81f4020
Compare
Introduce
VM-Sort-Desktop-Icons
to sort Desktop icons by type usingWScript.Shell
to replicate the manual steps using the keyboard. This function is called fromVM-Remove-DesktopFiles
(called fromVM-Clean-Up
) to avoid leaving empty spaces after removing Desktop icons.I would appreciate if someone could also test this code locally. Note you don't need to install the whole FLARe-VM or even the modified package to test the changes. It is enough to copy the functions
VM-Remove-DesktopFiles
andVM-Remove-DesktopFiles
from the modifiedpackages/common.vm/tools/vm.common/vm.common.psm1
.I am using Windows 10 and I am not sure if this code works in Windows 11 and we should prevent from running it in Windows 11 (or add a version for Windows 11). Note this code has to be run manually (by running
VM-Clean-Up
that the FLARE team is using to automate FLARE-VM builds) and is not part of the installer.Closes #902