FuPeiJiang / VD.ahk

Windows Virtual Desktop, AutoHotkey, Windows 11 support, Windows Server 2022, switch desktop, move window(wintitle) to current desktop; createDesktop, PinWindow, getCount, getDesktopNumOfWindow -> mute all windows in Virtual Desktop
MIT License
360 stars 48 forks source link

VD.ahk crashes, doesn't run. #9

Open 4nur4g opened 2 years ago

4nur4g commented 2 years ago

VD.ahk on launch crashes/closes immediately. However, "VD examples.ahk" runs/works fine. Am I doing anything wrong?

FuPeiJiang commented 2 years ago

if "VD examples.ahk" works fine, then you got it VD.ahk was not meant to be ran, it was meant to be #Included by other scripts

because I can't, I need you to tell me what should the README.md have included ? so that when you saw it, you wouldn't have had this confusion

Spoiler warning, click here to see more After you thought about it
would adding something like this work? : > VD.ahk will crash/close immediately, run "VD examples.ahk" I just realized, you could have been misled by "no dependencies" were you misled by "no dependencies" ?
My Attempt at Explaining
> why are there 2 files VD.ahk and VD examples.ahk ? say you have a project "app manager.ahk" that needs Virtual Desktop Capabilities, you #Include VD.ahk into "app manager.ahk", then you have Virtual Desktop Capabilities (in code, this means `VD` methods) "VD examples.ahk" is an example of such project: it #Includes VD.ahk, then it is able to call `VD` methods like when you press Numpad2, it will call `VD.goToDesktopNum(2) ` https://github.com/FuPeiJiang/VD.ahk/blob/077160a49bfa029b120787a0f0756af02a004786/VD%20examples.ahk#L74 you can say that VD.ahk is a class, or a library, or functions, that said, VD.ahk and VD examples.ahk CAN be merged into 1 file, but this would cause problems for people who want to use this script in their other scripts read: https://github.com/pmb6tz/windows-desktop-switcher/pull/47
> why does VD.ahk close immediately ? well, the program finished everything it had to do, so it exited VD.ahk has no hotkeys, no code to run, it was done doing everything it had to do, so it exited whilst "VD examples.ahk" does stuff : when you press a hotkey, it will do stuff
4nur4g commented 2 years ago

Thanks for the detailed explanation. Here's what went through my mind when I downloaded your script for personal use:

Seeing the file's name, "VD examples.ahk" gave an impression as if it's a demo file. The message box on launch further validated my assumption. It had detailed actions that one could do with the script.

Such instructions are generally put inside the "Read me" file. And then, the script just works after launch. One need not be greeted with documentation every time the script is launched.

I thought "VD examples.ahk" is the demo file and "VD.ahk" is the main script for the reasons mentioned above. Or in other words, I assumed: "VD.ahk" = "VD examples.ahk" - (Message box having a brief documentation)

I get that we can remove the message box by manually editing the concerned part of the script. However, users generally want the script to work without modifications.

Words of caution: I'm not a software engineer. I'm an ordinary man who thinks using common sense. Perhaps's it's the reason I misunderstood a seemingly obvious part.

Thanks again! With Appreciation Anurag