Not sure of what code you are using etc, so gonna make generic assumptions. Lots of latitude here
Assign your buttons a relay command and if its only for a specific toon, make sure you specify that in the command.
ie.
relay all command
or
relay toonsessionname command
command can either be a script, regular command, atom or event. (see the wiki)
1)
for simplicity you can send a keystroke using the press command such as alt+1 thru alt+9 to cast the appropriate spell, or any other key sequence you have bound to a ingame command. you can also set the mouse to click certian spots.
2)
or you can run a quick script to do a series of commands etc.
3)
if you want to communicate with the scripts interactively you need to use a event or atom
4)
alternatively have button echo some output to the games chat for detection via addtrigger events in your script(s)
it is then upto the script(s) running to take the appropriate action.
you may want to take a look at the ismods site for a example that was given there. search keyword is hotbars if i recall correctly.