Comments (10)
let me rephrase / did I understand correctly ?
context:
you are in VD2
got:
you are moved to VD1, OneNote is started in VD1
want:
you stay in VD2, OneNote is started in VD2
from vd.ahk.
if OneNote is changing your virtual desktop, I can't prevent it
I can save your current virtual desktop
start OneNote
move back to saved virtual desktop, move OneNote to saved virtual desktop
though it is pretty much impossible since Start is by PID, a PID can have 2 windows,
a PID can just inform the other PID, and quit itself, while the other PID creates another window
how would you know from the PID you started, that this newly created window (on a different existing PID) was the result of it?
you can only check if another window of certain wintitle or processName was created, the newly created one must be it
wait, get WinTitle, get PID, var map1 map[hwnd]bool=get all windows of that PID, Start, get all windows of that PID, newly created windows in this timespan are the ones you caused.
from vd.ahk.
Ha, to clarify, here are two things I had in mind when opening this issue:
- As you said, when launching OneNote specifically, it helps to keep it in the current virtual desktop and switching back to the current desktop if VD-switching happens unexpectedly;
- Further, it may help to start a window in a "hidden" VD, by literally "sending the window to the destination VD". This helps to create an easy-to-use launcher script, that populates all virtual desktops with the programs needed in that destination.
Towards the end of your most recent post, it looks like you found a way to identify the new OneNote window? That's great!
from vd.ahk.
thanks for the use cases 1. and 2., allows me to write functions based on use case, instead of functionality : Launch a program at the current desktop, which I would optimize wrongly, idk, maybe it's even better to have both functionality and use case
@llinfeng
test https://github.com/FuPeiJiang/VD.ahk/tree/run_in_VD
run in VD.ahk, run in VD lock.ahk, VD.Run_lock_VD
name to be (maybe) redecided
I used https://chris.dziemborowicz.com/apps/hourglass/ to test, you should test using OneNote (which I didn't want to install)
from vd.ahk.
@FuPeiJiang I tested the syntax in run in VD.ahk
and it worked well for launching and sending gvim.exe
, for example. Though, could you explain what is the VD.Run_lock_VD
function in run in VD lock.ahk
intended for?
In an effort of trying to make sense from the following line with the "lock" function - is it meant to keep the focus at VD 2, and launch a new window in VD 3? (Or, to flip it, to keep the focus at VD 3, and launch a new window in VD 2?)
VD.Run_lock_VD("""C:\Program Files (x86)\Hourglass\Hourglass.exe""","","","","Hourglass.exe",2,3)
For this "OneNote for Windows 10" app, nope, all windows were opened in the current virtual desktop, with nothing forwarded to the intended destination. Here is the window information for those OneNote windows in case it may help us get dispatched to the intended VD.
---------------------------
Warning
---------------------------
Paperless - OneNote for Windows 10
ahk_class ApplicationFrameWindow
ahk_exe ApplicationFrameHost.exe
hostname AW-R5
NumMonitor: 6, 2.666666
PrimaryMonintor: 1200x1920
---------------------------
OK
---------------------------
from vd.ahk.
it's to launch a new window in VD 2, and set focus at VD 3
window_desktopNum, your_desktopNum
Line 680 in c2a7e4b
for OneNote
Paperless - OneNote for Windows 10
ahk_class ApplicationFrameWindow
ahk_exe ApplicationFrameHost.exe
can you send me full script that didn't work ?
if you did it like this, I don't think it will work
VD.Run_lock_VD("""OneNote.exe""","","Paperless - OneNote for Windows 10","ApplicationFrameWindow","ApplicationFrameHost.exe",2,VD.getCurrentDesktopNum())
from where can I install your version of OneNote ?
from Microsoft Store ? https://apps.microsoft.com/store/detail/onenote/9WZDNCRFHVJL
from vd.ahk.
it's to launch a new window in VD 2, and set focus at VD 3
To make the variable names self-explanatory, how about window_desktopNum -> new_window_desktopNum
and current_desktopNum
? (I assume the intention is to keep the focus "local" while sending windows around. Then, it helps to use a wildcard symbol/number(0) to indicate the current desktop.)
Here is the full script that opened four OneNote windows in the current desktop. These UWP apps are hard to run direclty through Run
command. For now, the only method I know is to first go to shell:AppsFolder
using the Windows Run window, create a desktop shortcut for OenNote, and then, feed the link's path to the Run
command.
Folded script
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
ListLines Off
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetBatchLines -1
#KeyHistory 0
#Include ..\VD.ahk
VD.startShellMessage()
VD.Run("""c:\users\llinfeng\Desktop\OneNote for Windows 10 - Shortcut.lnk""","","","","",1)
VD.Run("""c:\users\llinfeng\Desktop\OneNote for Windows 10 - Shortcut.lnk""","","","","",2)
VD.Run("""c:\users\llinfeng\Desktop\OneNote for Windows 10 - Shortcut.lnk""","","","","",3)
VD.Run("""c:\users\llinfeng\Desktop\OneNote for Windows 10 - Shortcut.lnk""","","","","",4)
return
f3::Exitapp
And, yes, the OneNote app I use most often is the free one from the Microsoft Store as you linked. It does the best job of syncing, where the thing from Office subscription would run into sync issues very frequently for me. Here is another script where I was trying to see if I can dispatch 4 onenote.exe
windows to four virtual desktops. Upon running the script, only one onenote.exe
instance is opened.
Folded script
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
ListLines Off
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetBatchLines -1
#KeyHistory 0
#Include ..\VD.ahk
VD.startShellMessage()
VD.Run("""C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE""","","","","",1)
VD.Run("""C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE""","","","","",2)
VD.Run("""C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE""","","","","",3)
VD.Run("""C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE""","","","","",4)
return
f3::Exitapp
Per its current state, VD.Run()
is doing a great job. I assume it should work for normal windowed applications that are launched by running an executable file. Though, why both versions of OneNote are behaving as such, I don't have a good understanding yet. They do have a few things in common - it is hard to launch, and would fail to sync sometimes. Though, on the good part - they both offer an infinite canvas for scribbling with a digitizer (pen), and they are both helpful for annotating screenshots for snippets of code for ideation purposes.
from vd.ahk.
VD.ahk/other examples/run in VD lock.ahk
Lines 11 to 18 in 7b57051
this is the best I could do..
remember to update branch https://github.com/FuPeiJiang/VD.ahk/tree/run_in_VD before running
from vd.ahk.
Fantastic. The example you give works great. It is very thoughtful that you switch to VD1 and launch the first OneNote window there.
Question: what does VD.startShellMessage()
do? Without it, it looks like all OneNote windows are opened in the active virtual desktop.
from vd.ahk.
@FuPeiJiang Will you merge these back to the main branch? I assume it is class_VD
?
It is a great pleasure to find this repo, and I'm planning to stay up-to-date as much as I can :)
from vd.ahk.
Related Issues (20)
- After pinning with AH2 version, I get an error when switching desktops by number.
- Script sending "Q" to discord | Desktop switch failure. HOT 2
- getDesktopNumOfWindow sometimes returns -1 rather than the correct num HOT 4
- Error HOT 10
- open Application directly on one virtual desktop in background HOT 2
- "Error: (0x80004002) No such interface supported" after updating Windows 11 (Beta insider channel) HOT 13
- sending keypress to specified virtual desktop only.
- Ah2: Desktop Looping & Switching + Other Feature Regression from Commit ee2f54f626914273f00853306c1daaf803f756cb HOT 2
- It doesn't work on Windows 11 Build 22621.2215 (22H2) HOT 2
- A problem with the new Windows update 11 HOT 18
- Virtual desktop Tasksbar icons HOT 4
- renaming desktops HOT 1
- Switching to Relative Desktop fails initially HOT 2
- Current desktop count is always zero
- New Windows Build 23606: VD.getCurrentDesktopNum() always returns 0 HOT 4
- Windows Server 2022 version HOT 3
- It doesn't work on Windows 11 Build 22631.3085 (23H2) HOT 13
- v2_port分支没有 TogglePinApp,PinApp,UnPinApp HOT 2
- WinExist in another virtual desktop HOT 7
- Previous Desktop HOT 9
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 vd.ahk.