Jump to content


Photo

[bbTCL] Getting BBInterface Values (procedure)


  • Please log in to reply
1 reply to this topic

#1 sitalk

sitalk

    Advanced Member

  • Members
  • PipPipPip
  • 69 posts

Posted 03 May 2015 - 02:18 PM

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

 

When we want to manipulate the value of a BBInterface control sometimes we need first to read its current value.

A simple example of this is toggling a property value between true and false, like in the case of toggling the visibility of a control where of course before setting the new value we want to know what is the current value.

 

So this is a simple script for parsing BBInterface.rc and extract control property values:

proc BBInterface_GetValue { control_Name control_Property } {    # save BBInterface configuration first to make sure we have updated values    tcl-bb::broam "@BBInterface Plugin Save"    set fp [open "C:bbZeropluginsbbInterfaceBBInterface.rc" r]    set bbinterface_conf [read $fp]    close $fp    set data [split $bbinterface_conf "n"]    foreach line $data {        regexp {@BBInterface Control SetWindowProperty (.*) (.*) (.*)} $line all control property value        if { $control == $control_Name && $property == $control_Property } {            return $value        }    }    return}

Example

In our example we will create a TCL function to toggle the visibility of a given control and then we will use it as a bro@m in a bbKeys shortcut.

proc ToggleBBInterfaceControl { control_Name } {    # Use with:    # @tcl-bb eval ToggleBBInterfaceControl {ControlName}	set control_isvisible [ BBInterface_GetValue $control_Name "IsVisible" ]	tcl-bb::broam "@BBInterface Control SetWindowProperty $control_Name IsVisible [expr ($control_isvisible == "true"?"false":"true")]"	tcl-bb::broam "@BBInterface Plugin Save"}

In my setup I have a volume slider named "VolumeSlider" so now I can toggle it calling this bro@m:

@tcl-bb eval ToggleBBInterfaceControl {VolumeSlider}

So in bbKeys.rc:

KeyToGrab(V), WithModifier(Win+Ctrl), WithAction(exec @tcl-bb eval ToggleBBInterfaceControl {VolumeSlider})

  • pitkon likes this

#2 pitkon

pitkon

    Administrator

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

Posted 03 May 2015 - 03:51 PM

Excellent...






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users