Save up to 50% off any of our desktop apps in our 2021 spring sale, including
DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!

Title

Message

Confirm

<< DiscussionsReply

Detecting "second" monitor ID

Nicola Farina
22 discussion posts
Hi guys,

I have a bunch of triggers that I need to point to "second" screen I attached, but sometimes this is on left and other times on right. Using a laptop on docking stations and using it with external direct connected screens too, I need my triggers to point to which monitor is not the Windows main one.

With MoveToNext or MoveToPrevious I need to define the exact position, that for me can change.

How can I build a function to detect the ID of which I consider not the main Windows screen at the moment? I always use two screens at maximum, so I could be satifisfied using the first low value of an array (for example).

Thanks.
May 12, 2020  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Is the laptop always monitor ID 1 in your setups?
May 15, 2020  • #2
Nicola Farina
22 discussion posts
No, because when on docking stations, I tipically don't use the laptop monitor (the lid is closed).

Examples:
- laptop only (obvious one-screen setup)
- laptop screen (sometimes on left, sometimes on right) + 1 external screen (Windows main)
- 2 externals (on the left is the Windows main) and no laptop screen (lid closed)

As you can see, the "first second" screen ID is what I looking for (but tell me if I'm wrong).

Many thanks.
May 16, 2020  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ok, interesting. Is the second monitor always a higher ID than the primary?
May 20, 2020  • #4
Nicola Farina
22 discussion posts
Need to check, I'll get back to you in few days.
May 21, 2020  • #5
Nicola Farina
22 discussion posts
Seems not.

Only laptop screen > main ID = 1
Docking with 2 ext screens and no laptop screen (lid closed) > main ID = 1 (left one)
1 ext screen plus laptop screen > main ID = 2 (ext one), laptop on left

Ideally, I need to determine the first screen that is not the main Windows one.

I suppose that can be helpful for some other folks here.

Thanks.
May 29, 2020  • #6
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ok, this would be possible with a Scripted Function. What we could do is write a Scripted Function that moves the Window to the "second" monitor, then runs your Custom Function for the size. If you think that would work, please let me know and I'll send over the Scripted Function.

Thanks!
Jun 1, 2020  • #7
Nicola Farina
22 discussion posts
Sure, thanks!
Jun 2, 2020  • #8
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ok, try this one out! You'll need to import it on the Settings > Functions tab and set the name of your Custom Function at the top of the script. After that, apply the settings, then try adding it to your Trigger rule, hopefully it works for you!
Jun 2, 2020  • #9
Nicola Farina
22 discussion posts
Just to let you know that I'm starting testing today.

Thank you very much for your great support, as usual.

I'll back to you soon for a final feedback.
Jun 19, 2020  • #10
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Sounds great, thanks!
Jun 19, 2020  • #11
Nicola Farina
22 discussion posts
Works great!

Cheers!
Jul 2, 2020  • #12
Nicola Farina
22 discussion posts
Keith I've an issue within this script using your seggested function (that works great). I've no idea why now it doesn't work.

When my second screen is smaller than main one (fullHD instead of 2K), the y positioning is wrong (see attachments).

The second screen (smaller) is using a different Windows scaling setting (120% instead of 100% of the main one), but I've tested with no luck.

Can you please help me?

Thanks!
• Attachment [protected]: DFS help.zip [14,757 bytes]
Dec 7, 2020  • #13
Nicola Farina
22 discussion posts
Uhmmm, it seems that "top position" is refered to the main screen height that is bigger then the destination monitor ones. Could be this?
Dec 7, 2020  • #14
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Correct, all X,Y values are relative to the top-left corner of the primary monitor.

On line 42 where you're calculating y, you should do this:
int y = targetMonitorBounds.Y + topDistance;


Hope that helps!
Dec 9, 2020  • #15
Nicola Farina
22 discussion posts
Works great!

Thanks!
Dec 15, 2020  • #16
Was this helpful?    
<< DiscussionsReply