Dual-monitor management
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Dual-monitor management
Sorry if the topic does not belong here.
I have two monitors with different resolutions and it's a little boring whent I have to move XYplorer because the window must be resized to fit my need. In XnViewMP, you can save the disposition of the window (wich monitor and wich size) and call it with a menu (four different dispositions). If you have solutions to solve this - tips, freeware - I will be glad to hear about it.
I have two monitors with different resolutions and it's a little boring whent I have to move XYplorer because the window must be resized to fit my need. In XnViewMP, you can save the disposition of the window (wich monitor and wich size) and call it with a menu (four different dispositions). If you have solutions to solve this - tips, freeware - I will be glad to hear about it.
Windows 10 64 bits
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Dual-monitor management
Autohotkey...
Check on which monitor XY is and resize the window appropriately.
A rather simple solution:
E.g.:
You could also let the ahk script read values from an .ini file to use more than just a fixed position.
Check on which monitor XY is and resize the window appropriately.
A rather simple solution:
E.g.:
Code: Select all
#NoTrayIcon
#SingleInstance force
#Persistent
xyClass := "ThunderRT6FormDC"
SysGet, m, MonitorCount
Loop, %m%
SysGet, mon%A_Index%, Monitor, %A_Index%
leftX := 120
leftY := 10
leftWidth = 1550
leftHeigth = 1000
rightX := mon2Left + 120
rightY := 10
rightWidth = 1550
rightHeigth = 1000
SetTimer, MoveXY, 250
return
MoveXY:
if WinExist("ahk_class" . xyClass)
{
WinGetPos, xPos, , , , ahk_class %xyClass%
if (xPos >= mon2Left) {
WinMove, ahk_class %xyClass%, , rightX, rightY, rightWidth, rightHeigth
} else {
WinMove, ahk_class %xyClass%, , leftX, leftY, leftWidth, leftHeigth
}
}
return
One of my scripts helped you out? Please donate via Paypal
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Re: Dual-monitor management
Thanks. I will look at this. I use AutoIt for some script so I will look if I can manage this this way.
Windows 10 64 bits
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Dual-monitor management
It would be better to enhance the script to let it create / update and read settings to / from an .ini file.
XY could display the necessary content parts and let you choose the one you like...
XY could display the necessary content parts and let you choose the one you like...
One of my scripts helped you out? Please donate via Paypal
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Re: Dual-monitor management
Is there an example of such ini file in help file ? Or on the forum ?highend wrote:It would be better to enhance the script to let it create / update and read settings to / from an .ini file.
XY could display the necessary content parts and let you choose the one you like...
Windows 10 64 bits
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Dual-monitor management
A better way (the former resized all XYplorer windows which is probably not what everybody wants)...
Edit:
Script was updated, look further down to find the current version...
Edit:
Script was updated, look further down to find the current version...
One of my scripts helped you out? Please donate via Paypal
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Dual-monitor management
You either extract it into the same path where you store the script or if you place it in a different path you adjust the variable in the script.
One of my scripts helped you out? Please donate via Paypal
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Dual-monitor management
I've changed a few things...
- The popup menu shows the current values (x, y, width, height) for the "Save" entry
- All entries can be executed by "s" (for "Save") | by their number (1 for the first entry, 2 for second, etc.)
- If the $posLimit variable is changed any superfluous windows positions are removed
All entries are stored INSIDE the script from now on. You can delete the old .ini file...
The .exe file was changed, too. The new version of the script only works with the new .exe!
- The popup menu shows the current values (x, y, width, height) for the "Save" entry
- All entries can be executed by "s" (for "Save") | by their number (1 for the first entry, 2 for second, etc.)
- If the $posLimit variable is changed any superfluous windows positions are removed
All entries are stored INSIDE the script from now on. You can delete the old .ini file...
The .exe file was changed, too. The new version of the script only works with the new .exe!
Code: Select all
$posLimit = 4;
end $posLimit > 9, "Do not set the position limit to a value greater then 9!";
$helperApp = self("path") . "\XYplorer_ManageWindowPosition.exe";
$winPositions = <<<>>>
>>>;
$curPosition = runret("""$helperApp"" /get");
$saveCurPosMenuEntry = "&Save (" . trim(replace($curPosition, "|", " "), "<crlf>") . ")";
$winPositionCount = gettoken(trim($winPositions, "<crlf>"), "count", "<crlf>"); // How many stored positions?
// Purge entries if $posLimit was changed
if ($winPositionCount > $posLimit) {
$i = 1;
$tmpWinPositions = "";
foreach($item, $winPositions, "<crlf>") {
if ($i > $posLimit) {
break;
} else {
$tmpWinPositions = $tmpWinPositions . $item . "<crlf>";
}
$i++;
}
$tmpWinPositions = trim($tmpWinPositions, "<crlf>");
$content = regexreplace(readfile(self("file")), "(\$[w]inPositions = <<<>>>)([\s\S]+?)(>>>;)", "$1<crlf>$tmpWinPositions<crlf>$3");
writefile(self("file"), $content);
$winPositions = $tmpWinPositions;
}
// Display position entries through popup menu
$popupEntries = "";
if ($winPositionCount == 0) {
$popupEntries = "No positions to restore...";
} else {
$i = 1;
foreach($pos, $winPositions, "<crlf>") {
$popupEntries = $popupEntries . "&" . $i++ . " - " . replace($pos, "|", " ") . "|";
}
}
$popup = popupmenu("$saveCurPosMenuEntry|-|$popupEntries", -1, -1);
if (strpos($popup, "save") != -1) { // Save a new entry
$i = 2;
$tmpWinPositions = trim($curPosition, "<crlf>");
if ($winPositionCount >= 1) {
foreach ($item, $winPositions, "<crlf>") {
if ($i <= $posLimit) {
$tmpWinPositions = $tmpWinPositions . "<crlf>" . $item;
}
$i++;
}
}
$content = regexreplace(readfile(self("file")), "(\$[w]inPositions = <<<>>>)([\s\S]+?)(>>>;)", "$1<crlf>$tmpWinPositions<crlf>$3");
writefile(self("file"), $content);
status "Current position saved!", "006400", "ready";
} elseif (strpos($popup, "-") != -1) { // Move window
$newPosition = regexreplace($popup, "^.*?(?=x)|[xywh]:");
run """$helperApp"" /move $newPosition", , 2, 0;
}To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Re: Dual-monitor management
I did find a simple solution for my problem - as the dual monitor is considered as a single monitor by Autoit, the WinMove() function is enough (so two buttons for two exe files with one line of script each). But I would be curious to test your solution - much more complete as I understand.
I'm new to XYplorer scripting and a little lost. I have to copy your script in a xys file, put it in the script directory, copy the exe file in the same directory and create a button with open exe ? Am I right ?
I'm new to XYplorer scripting and a little lost. I have to copy your script in a xys file, put it in the script directory, copy the exe file in the same directory and create a button with open exe ? Am I right ?
Windows 10 64 bits
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Dual-monitor management
And >1 MB filesize? (for two .exes, non upx compressed) xDso two buttons for two exe files with one line of script each
The xy script is much more flexible, needs only a single .exe (which is only 8kb large).
A button with "open exe"? No, the button has to invoke the script, not the .exe file.I have to copy your script in a xys file, put it in the script directory, copy the exe file in the same directory and create a button with open exe
One of my scripts helped you out? Please donate via Paypal
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Re: Dual-monitor management
I tried this after reading the page http://www.xyplorer.com/tour/?page=scripting
I copy the script in a file "dual-monitor.xys" in scripts directory, I copy the exe file in the same directory, I create a button with load "dual-monitor.xys". When I click it, I've got an error.
I copy the script in a file "dual-monitor.xys" in scripts directory, I copy the exe file in the same directory, I create a button with load "dual-monitor.xys". When I click it, I've got an error.
Windows 10 64 bits
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Dual-monitor management
And now we are supposed to guess what error message you got?
One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club