Jump to content


Photo

[bbTCL] Drives Menu


  • Please log in to reply
1 reply to this topic

#1 sitalk

sitalk

    Advanced Member

  • Members
  • PipPipPip
  • 69 posts

Posted 08 April 2015 - 10:34 PM

(Refer to http://blackbox4wind...lackbox/?p=2941 for installing and using bbTCL in bbZero x64)

 

[color=#b22222;]NOTE: These scripts use the Twapi library under bbTCL[/color]

 

Two new TCL scripts I'm working on these days involving volumes.

@tcl-bb eval ListDrives
It's a simple script that updates and opens a menu containing the list of drives in the system (I can't find how to list also MTP volumes).
It does something similar to

[path] (My Computer) {DRIVES}

but, for example, you can filter out empty drives, or which types of disks you want to show and how to show them.
 
In my case I want only fixed hard drives and optical discs followed by a separator and then removable drives, here it is:

proc ListDrives {} {    # Use with:    # @tcl-bb eval ListDrives    LoadDrives    tcl-bb::broam "@BBCore.ShowMenu menus/drives.rc"}proc LoadDrives {} {    set f [open "C:bbZeromenusdrives.rc" w]    set offset 0    set removables 0    puts -nonewline $f "[begin] (Drives)n"    foreach drive [twapi::find_logical_drives -type "fixed cdrom"] {        try {            array set diskinfo [twapi::get_volume_info $drive -label -type]            puts -nonewline $f "[exec] ($drive <$diskinfo(-label)>) {$drive}n"        } on error {} {            continue        }    }    foreach drive [twapi::find_logical_drives -type removable] {        try {            array set diskinfo [twapi::get_volume_info $drive -label]            if {$removables == 0} {                puts -nonewline $f "[separator]n"                set removables 1            }            puts -nonewline $f "[exec] ($drive <$diskinfo(-label)>) {$drive}n"        } on error {} {            continue        }    }    puts -nonewline $f "[end]"    set offset [tell $f]    close $f}

 
@tcl-bb eval ListEjectDevices
Similarly to the first script a menu containing the system's disks is updated and opened, but this time clicking on the menu items will safely remove removable disks end eject optical discs! :)

proc ListEjectDevices {} {    # Use with:    #@tcl-bb eval ListEjectDevices    LoadEjectDevices    tcl-bb::broam "@BBCore.ShowMenu menus/drives.rc"}proc LoadEjectDevices {} {    set f [open "C:bbZeromenusdrives.rc" w]    set offset 0    puts -nonewline $f "[begin] (Eject)n"    foreach drive [twapi::find_logical_drives -type "removable cdrom"] {        try {            array set diskinfo [twapi::get_volume_info $drive -label]            puts -nonewline $f "[exec] ($drive <$diskinfo(-label)>) {@tcl-bb eval twapi::eject_media $drive}n"        } on error {} {            continue        }    }    puts -nonewline $f "[end]"    set offset [tell $f]    close $f}

I use these two scripts on my Windrose (link) assigning the first one to the left click and the second one to the right click on one of the buttons:

@BBInterface Control SetAgent N_Button LeftMouseUp Bro@m "@tcl-bb eval ListDrives"@BBInterface Control SetAgent N_Button RightMouseUp Bro@m "@tcl-bb eval ListEjectDevices"

  • pitkon and Paz like this

#2 pitkon

pitkon

    Administrator

  • Head Administrator
  • 1,333 posts
  • LocationAthens & Nafplio, Greece

Posted 09 April 2015 - 07:47 AM

Excellent! Keep them coming! :D






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users