Page 1 of 1
Have to close tabs before ejecting devices
Posted: 04 May 2013 06:45
by ojcuts
Every time I'll have to close the corresponding tabs before ejecting portable devices,
Can I eject flash cards or memory sticks smoothly and close the tabs automatically?
Re: Have to close tabs before ejecting devices
Posted: 04 May 2013 09:43
by highend
Use a script...
Code: Select all
// RemoveDrive: http://www.uwe-sieber.de/drivetools_e.html
$driveLetter = inputselect("Select the drive to eject:", get("drives", 2));
$tabCount = tab("get", "c"); // Only for the active pane
while (true) {
$tab = tab("get", "path", $tabCount);
if (substr($tab, 0, 3) == $driveLetter) {
tab("close", 0, $tabCount);
}
$tabCount--;
if ($tabCount == 0) { break; }
}
run """D:\Users\Highend\Downloads\removedrive\x64\RemoveDrive.exe"" $driveLetter", , 2, 0;
a.) Adapt the path for the RemoveDrive.exe to your local system (and bitness!)
b.) It will only check all tabs in the active pane^^
Re: Have to close tabs before ejecting devices
Posted: 08 May 2013 18:12
by klownboy
Hi highend,
I like your script to close an external drive's tab and remove the drive. Many times though I (and maybe some others) just want to simply "clean house" and close all unlocked tabs when removing an external drive. Which is actually far easier to do. I have my C:\ set as the "default tab" so I tend not to have a bunch of unlocked tabs floating around.
The command, #352 closes all "other" unlocked tabs only, not the tab you have currently selected. There's where Don's new "flags" paramenter comes in handy (I was trying to find a use for it). With that, we can now determine if the tab is unlocked and close it. The get "flags" parameter will return null("") if it's unlocked. The script below will also not provide an inputselect box if you only have "one" external drive on line. It will simply close all unlocked tabs and remove the external drive. If there's more than one you choose which one to eject. I also added the -b parameter to provide a little built-in Windows notification that the drive has bee removed. By the way, there are some AHK functions out there which we could use to eject the drive if we wanted to in lieu of using "removedrive.exe". I already had removedrive.exe in my Tools folder anyway.
How's alt-tab doing?
Thanks,
Ken
Code: Select all
// RemoveDrive: http://www.uwe-sieber.de/drivetools_e.html
$driveLetter = get("drives", 2), "|");
$Dr_Cnt = gettoken($driveLetter, "count", "|");
end $Dr_Cnt < "1", "You have no removable drives on-line, aborting!";
if ($Dr_Cnt > "1")
{
status "You have more than one flash or external hard drive on-line!";
$driveLetter = inputselect("Select the Target Drive: <crlf>", "$driveLetter", | ,4, ,350, 250, "Target Drive Selection");
}
#352; //close all "other" unlocked tabs
if (tab("get", "flags") == "") { //close the current selected tab if it's unlocked
tab("close", 1)}
#552;#1040;goto "C:\"; //collapses up the tree and gets you back to C:\
run """D:\Tools\RemoveDrive\RemoveDrive.exe"" $driveLetter -b", , 2, 0;
//status "$driveLetter removed. It's safe to unplug it!"; //if you'd rather not have the Win tray notification (remove -b above)
Re: Have to close tabs before ejecting devices
Posted: 15 May 2013 01:50
by ojcuts
Script's not working fine,
now my way is to open more computer tabs in one tabset,and close the tab(s) that need to eject,then eject it.
Re: Have to close tabs before ejecting devices
Posted: 15 May 2013 04:08
by klownboy
Hi ojcuts,
Sorry the scripts aren't working for you. Highend's script as well as the version I posted work fine for me. What error message do you get? Did you download removedrive.exe from the posted URL and change the path to it in the script's run command?
Thanks,
Ken
Re: Have to close tabs before ejecting devices
Posted: 06 Sep 2014 07:06
by ojcuts
klownboy wrote:Hi ojcuts,
Sorry the scripts aren't working for you. Highend's script as well as the version I posted work fine for me. What error message do you get? Did you download removedrive.exe from the posted URL and change the path to it in the script's run command?
Thanks,
Ken
Sorry answer so late! Thank you very much for your script! How fool am I that I didn't look deep into the lines! Now I have downloaded removedrive.exe and changed the path, and it works fine.