Comments (14)
Yes. everything goes well. Thanks again.
from windows-desktop-switcher.
Use proces name as pop notification for pin or unpin seem more clear than window tile.
_GetCurrentWindowProcess() {
WinGet, ProcessName, ProcessName, A
; MsgBox, %ProcessName%
return ProcessName
}
from windows-desktop-switcher.
Hi, glad you've found it useful!
Solution
Yes, I have added this functionality to my private version of the script, all you need is to add these lines and you'll be able to use Capslock + h for example, to pin the window on all desktops
global IsPinnedWindowProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "IsPinnedWindow", "Ptr")
global PinWindowProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "PinWindow", "Ptr")
global UnPinWindowProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "UnPinWindow", "Ptr")
global IsPinnedAppProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "IsPinnedApp", "Ptr")
global PinAppProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "PinApp", "Ptr")
global UnPinAppProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "UnPinApp", "Ptr")
capslock & g::OnTogglePinOnTopPress()
capslock & h::OnTogglePinAppPress()
capslock & j::OnTogglePinWindowPress()
_GetCurrentWindowID() {
WinGet, activeHwnd, ID, A
return activeHwnd
}
_GetCurrentWindowTitle() {
WinGetTitle, activeHwnd, A
return activeHwnd
}
OnTogglePinOnTopPress() {
_notif(_TruncateString(_GetCurrentWindowTitle(), 100), "Toggled 'Pin On Top'")
Winset, Alwaysontop, , A
}
OnTogglePinWindowPress() {
windowID := _GetCurrentWindowID()
windowTitle := _GetCurrentWindowTitle()
if (_GetIsWindowPinned(windowID)) {
_UnpinWindow(windowID)
_ShowTooltipForUnpinnedWindow(windowTitle)
}
else {
_PinWindow(windowID)
_ShowTooltipForPinnedWindow(windowTitle)
}
}
OnTogglePinAppPress() {
windowID := _GetCurrentWindowID()
windowTitle := _GetCurrentWindowTitle()
if (_GetIsAppPinned(windowID)) {
_UnpinApp(windowID)
_ShowTooltipForUnpinnedApp(windowTitle)
}
else {
_PinApp(windowID)
_ShowTooltipForPinnedApp(windowTitle)
}
}
_PinWindow(windowID:="") {
_CallWindowProc(PinWindowProc, windowID)
}
_UnpinWindow(windowID:="") {
_CallWindowProc(UnpinWindowProc, windowID)
}
_GetIsWindowPinned(windowID:="") {
return _CallWindowProc(IsPinnedWindowProc, windowID)
}
_PinApp(windowID:="") {
_CallWindowProc(PinAppProc, windowID)
}
_UnpinApp(windowID:="") {
_CallWindowProc(UnpinAppProc, windowID)
}
_GetIsAppPinned(windowID:="") {
return _CallWindowProc(IsPinnedAppProc, windowID)
}
_CallWindowProc(proc, window:="") {
if (window == "") {
window := _GetCurrentWindowID()
}
return DllCall(proc, UInt, window)
}
_notif(txt, title:="") {
HideTrayTip()
TrayTip, %title%, %txt%, 1
}
HideTrayTip() {
TrayTip ; Attempt to hide it the normal way.
if SubStr(A_OSVersion,1,3) = "10." {
Menu Tray, NoIcon
Sleep 200 ; It may be necessary to adjust this sleep.
Menu Tray, Icon
}
}
_ShowTooltipForPinnedWindow(windowTitle) {
_notif(_TruncateString(windowTitle, 100), "Pinned Window")
}
_ShowTooltipForUnpinnedWindow(windowTitle) {
_notif(_TruncateString(windowTitle, 100), "Unpinned Window")
}
_ShowTooltipForPinnedApp(windowTitle) {
_notif(_TruncateString(windowTitle, 100), "Pinned App")
}
_ShowTooltipForUnpinnedApp(windowTitle) {
_notif(_TruncateString(windowTitle, 100), "Unpinned App")
}
_TruncateString(string:="", n:=10) {
return (StrLen(string) > n ? SubStr(string, 1, n-3) . "..." : string)
}
from windows-desktop-switcher.
Well done!
I have test it,but met the error:
Error: Call to nonexistent function
Specifically:_GetCurrentWindowID()
……
……
from windows-desktop-switcher.
Thanks!
I added the missing function to the previous comment.
I also removed this line windowTitle := _GetCurrentWindowTitle()
from windows-desktop-switcher.
Error: Call to nonexistent function _CallWindowProc
Add this
_CallWindowProc(proc, window:="") {
if (window == "") {
window := _GetCurrentWindowID()
}
return DllCall(proc, UInt, window)
}
from windows-desktop-switcher.
Yeach. Popup notification can make the status more clean. It is really a good idea !
Very happy for your sharing ,if you does not matter
from windows-desktop-switcher.
Added it:)
from windows-desktop-switcher.
_GetCurrentWindowTitle() {
WinGetTitle, activeHwnd, A
return activeHwnd
}
from windows-desktop-switcher.
_GetCurrentWindowTitle() {
WinGetTitle, activeHwnd, A
return activeHwnd
}
You're right)
Does everything work now ?
from windows-desktop-switcher.
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)
}
}
from windows-desktop-switcher.
@Elijas
This is awesome, but I some of them doesn't seem to work.
The OnTogglePinOnTopPress function works fine, but neitherOnTogglePinAppPress nor OnTogglePinWindowPress seem to work for me.
Does anyone else have issues with the two functions as well? And does someone know a resolution? I would really love to be able to use those two lasts functions.
from windows-desktop-switcher.
@Elijas
This is awesome, but I some of them doesn't seem to work.
The OnTogglePinOnTopPress function works fine, but neitherOnTogglePinAppPress nor OnTogglePinWindowPress seem to work for me.Does anyone else have issues with the two functions as well? And does someone know a resolution? I would really love to be able to use those two lasts functions.
Agree with you, only togglePin works for me, the other 2 don't work, and would love the functionality...
from windows-desktop-switcher.
@Elijas This is awesome, but I some of them doesn't seem to work. The OnTogglePinOnTopPress function works fine, but neitherOnTogglePinAppPress nor OnTogglePinWindowPress seem to work for me.
Does anyone else have issues with the two functions as well? And does someone know a resolution? I would really love to be able to use those two lasts functions.
I know it's an old issue, but I got it to work when I moved the six "global" statements up to the "DLL" section where the other "global" statements are.
from windows-desktop-switcher.
Related Issues (20)
- Switching desktops no longer works on new Windows 11 update. Build 22631.3007 HOT 17
- Moving app windows to another desktop still does not work in Windows 11 HOT 14
- Switching a desktop doesn't work on full screen applications.
- Cycling over all desktops while going to target one HOT 3
- (Move to desktop) script only run if we compile to exe file HOT 6
- Windows + Tab stopped opening task view when using this project. How can I fix this?
- Fail to switch to any desktop HOT 5
- AutoHotkey Version 2 breaks compatibility HOT 6
- Can it get the name (not index) of a virtual desktop?
- Functionalities are extremely laggy? HOT 1
- No session required on Windows 11
- Also activating "Esc" button when switching window
- feature request
- latest version of AutoHotkey (2.0.2) is not compatible? HOT 2
- No longer working with the new windows 11 update. Build 22621.2283 HOT 5
- Disable showing the desktop number HOT 2
- Focus on the last foreground window in the VD when switching to it HOT 2
- set timer switch between desktops
- Move (only) current window to the destination desktop without switching
- Hide taskbar "shows" when switching desktops && ALT key focus when Change desktops HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from windows-desktop-switcher.