KSnapshot can be scripted using its D-Bus interface.
There are two ways to use the D-Bus interface: Qt™'s GUI qdbusviewer and the command line qdbus.
Examples:
%qdbus will display all services available.%qdbusorg.kde.ksnapshot-`pidof -s ksnapshot`will display the D-Bus interface for KSnapshot.%qdbusorg.kde.ksnapshot-`pidof -s ksnapshot` /KSnapshotwill display methods for controlling KSnapshot.
For more information, please visit D-Bus tutorial.