Git Product home page Git Product logo

Comments (4)

vlachig avatar vlachig commented on July 27, 2024

it must be possible to trigger the ChangeIcon function with every desktop change without the necessity for adding the code to each of the keyboard shortcut.

You don't need the ChangeIcon function, if you add
++++++++++++++++++++
Menu,TRAY, Icon, Path of the IconFile%desktopNum%.ico
++++++++++++++++++++
at the end of the function goToDesktopNum(desktopNum)
and your icon files are numbered.

from vd.ahk.

anxxx avatar anxxx commented on July 27, 2024

You don't need the ChangeIcon function, if you add ++++++++++++++++++++ Menu,TRAY, Icon, Path of the IconFile%desktopNum%.ico ++++++++++++++++++++ at the end of the function goToDesktopNum(desktopNum) and your icon files are numbered.

Thanks vlachig

That sounds good but I can't get it to work. Could you possibly give me the exact line of code?

I had already tried
++++++++++++++++++++++
^#numpad1::VD.goToDesktopNum(1), TraySetIcon("D:\Data\AutoHotkey2\icons\1.ico")
++++++++++++++++++++++
which worked fine for VD.goToDesktopNum(1) etc.

but didn't work for moving to a relative desktop with the right and left arrow keys e.g.

#!left::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", -1))

I am also not not sure that your suggestion would work for that either as as the desktop number is not specifically specified .

Thanks again

from vd.ahk.

vlachig avatar vlachig commented on July 27, 2024

In the file _VD.ahk search for the function goToDesktopNum(desktopNum) and replace it by this one:

    goToDesktopNum(desktopNum) { ; Lej77 https://github.com/Grabacr07/VirtualDesktop/pull/23#issuecomment-334918711
        firstWindowId:=this._getFirstWindowInVD(desktopNum)
        Gui VD_animation_gui:New, % "-Border -SysMenu +Owner -Caption +HwndVD_animation_gui_hwnd_tmp"
        VD_animation_gui_hwnd:=VD_animation_gui_hwnd_tmp+0
        IVirtualDesktop := this._GetDesktops_Obj().GetAt(desktopNum)
        GetId:=this._vtable(IVirtualDesktop, 4)
        VarSetCapacity(GUID_Desktop, 16)
        DllCall(GetId, "Ptr", IVirtualDesktop, "Ptr", &GUID_Desktop)
        DllCall(this.MoveWindowToDesktop, "Ptr", this.IVirtualDesktopManager, "Ptr", VD_animation_gui_hwnd, "Ptr", &GUID_Desktop)
        DllCall("ShowWindow","Ptr",VD_animation_gui_hwnd,"Int",4) ;after gui on current desktop owned by current process became active window, Show gui on different desktop owned by current process
        this._WinActivate_NewProcess(VD_animation_gui_hwnd)
        loop 20 {
            if (this.getCurrentDesktopNum()==desktopNum) { ; wildest hack ever..
                if (firstWindowId) {
                    DllCall("SetForegroundWindow","Ptr",firstWindowId)
                } else {
                    this._activateDesktopBackground()
                }
                break
            }
            Sleep 25
        }
        Gui VD_animation_gui:Destroy
	Menu,TRAY, Icon, D:\Data\AutoHotkey2\icons\%desktopNum%.ico
    }

from vd.ahk.

vlachig avatar vlachig commented on July 27, 2024

Another solution:

 ; === auto-execute section ===  (top of the script)

; ...
SetTimer Change_TRAY_Icon, 500
; ...

       RETURN   ; === end of auto-execute section ===

; ...

	Change_TRAY_Icon:
Nr := VD.getCurrentDesktopNum()
If (CurrentDesktopNr != Nr)
{	
	Menu,TRAY, Icon, D:\Data\AutoHotkey2\icons\%Nr%.ico
	CurrentDesktopNr := Nr
}
return

from vd.ahk.

Related Issues (20)

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.