SessionManager - Store and Load Tabs
Posted: 06 Sep 2011 08:24
Update for this older script >> Save Tabs using Script
Now storing the sessions in one ini file instead of single file for each session.
Works for me (because i know how it should work). Please test yourself and report back.
Now storing the sessions in one ini file instead of single file for each session.
Works for me (because i know how it should work). Please test yourself and report back.
Code: Select all
// SessionManager Version 002, 17:05 01.06.2011 ("SessionManager.xys"), http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=6982
// Was yore "Save Tabs using Script (Sessions.xys)", http://www.xyplorer.com/xyfc/viewtopic.php?p=43943#p43943
// v002: converted to store to ini instead of single files
"Store Session/Tabs"
$myINIFile = "<xydata>\User.ini";
$SectionCount = getkey( "Count", "Sessions", $myINIFile);
if ($SectionCount == 20)
{
// Only keep the last 20 session:
//msg "Session store is full, we will delete the oldest.",1;
$iter=1;
while($iter<$SectionCount)
{
$iter++;
if (strlen($iter)==1){$iter = "0$iter";}
$Date = getkey( $iter . "_date", "Sessions", $myINIFile);
$Comm = getkey( $iter . "_comm", "Sessions", $myINIFile);
$Icon = getkey( $iter . "_tabs", "Sessions", $myINIFile);
$iter--;
if (strlen($iter)==1){$iter = "0$iter";}
setkey $Date, $iter . "_Date", "Sessions", $myINIFile;
setkey $Comm, $iter . "_Comm", "Sessions", $myINIFile;
setkey $Icon, $iter . "_Tabs", "Sessions", $myINIFile;
$iter++;
}
//setkey "19", "Count", "Sessions", $myINIFile;
$SectionCount--;
}
$TabCount = tab(,"c");
$Pane = getinfo("Pane");
$Loop = 1;
$Tabs = "";
while ($Loop<=$TabCount) //for each tab do
{
$IFTabNameSet = strlen(tab("get","name",$Loop));
if ($IFTabNameSet < 1)
{
$Tabs = $Tabs . tab("get", "data", $Loop) . "|";
}else{
$Tabs = $Tabs . tab("get", "data", $Loop) . "?" . tab("get", "name", $Loop) . "|";
}
incr $Loop;
}
$Tabs = substr($Tabs, 0, strlen($Tabs)-1);
$SectionCount++;
if (strlen($SectionCount)==1){$SectionCount = "0$SectionCount";}
$Date = "<date yyyy.mm.dd hh:nn> %ComputerName% Pane:$Pane";
$Comme = Input("Add comment", "Enter an comment for this session (optional)",,"s","");
//setkey value, key, section, [INIfile]
setkey $SectionCount, "count", "Sessions", $myINIFile;
setkey $Date, $SectionCount . "_Date", "Sessions", $myINIFile;
setkey $Tabs, $SectionCount . "_Tabs", "Sessions", $myINIFile;
setkey $Comme, $SectionCount . "_Comm", "Sessions", $myINIFile;
// ///////////////////////////////////////////////////////////////////////
// open new tabs from an list of paths (saved tabs):
"Load Session/Tabs"
$myINIFile = "<xydata>\User.ini";
$iter=1;
$SectionCount = getkey( "Count", "Sessions", $myINIFile);
$array="";
while($iter <= $SectionCount)
{
if (strlen($iter)==1){$iter = "0$iter";}
$date = getkey( $iter . "_date", "Sessions", $myINIFile);
$comm = getkey( $iter . "_comm", "Sessions", $myINIFile);
$tabs = getkey( $iter . "_tabs", "Sessions", $myINIFile);
$tabs = replace($tabs, "|", ", ");
$array = $array . "$iter; $date; $comm; $tabs|";
$iter++;
}
$newTABs = inputselect("Select ONE stored session to restore:",$array,,2);
end ($newTABs==""); // [OK] without selection==Quit, [Cancel]==Quit
$newTABs = gettoken($newTABs, 1, ";");
$newTABs = getkey( $newTABs . "_tabs", "Sessions", $myINIFile);
//a little bit clean up first?
$CloseCurrentOpenTabs = confirm("Close current open tabs first?");
if ($CloseCurrentOpenTabs==0) {;}elseif (tab(,"c")>1) {#353;} //close all "other" tabs
$Loop = 1;
While(1)
{
$NewTab = gettoken($newTABs,$Loop,"|");
if ($NewTab==""){break;}
if (strpos($NewTab,"?") == -1)
{
tab("new", $NewTab); //open new tab with next token from array
}else{
tab("new", gettoken($NewTab,1,"?"));
tab("rename", gettoken($NewTab,2,"?"));
}
incr $Loop;
}
if ($CloseCurrentOpenTabs==1){seltab 1;#351;} //close last "old" tab too
// ///////////////////////////////////////////////////////////////////////
-
"Edit this &script : edit"
self $ScriptFile, file;
//OpenWith "<xypath>\Tools\NotePad2\Notepad2.exe", ,$ScriptFile;
OpenWith "Notepad", ,$ScriptFile;