You can do it in your OnSelChanged event handler, but you need to set the list box Event Invoke property to Asynchronous in order to call the (command) function. Instead of calling (command), I would (setvar "CLAYER" txt), then it should work either synchronous or asynchronous.