had a problem where the clipboard fuction, who works fine in a gambas execute file but did not work in a gambas script.
Solved this by using xclip and xsel.
The little program is to upper/lower a letter and add or delete a "." from sentence. I call the script with a shortcut keysetting from within the program.
Needed to use xclip an xsel as one copied correct but could not retrieve again from the clipboard, so used both, one for copy and the other for retrieving.
I do not now if a missed a function or setting regarding the clipboard function in the gambas script but this works for me on any texteditor or program.
This here is limited to one letter, change the code for a whole sentence or text you want to be inserted.
You can also call with new coding the script with parameters.
I am shure there are Gambassers who can write much smaller and better code than this, i am a amateur Gambasser, so let the community know if it can be improved.
Hope this helps to adapt and solve clipboard copying with scripts.
Greetings Dinge
Code: Select all
#!/usr/bin/gbs3
Public Sub Main()
Dim oldletter as string
Dim oldselect as string
Dim newletter as string
shell "xsel -cb" wait
shell "xdotool key Shift+Right" wait to oldselect
if len(trim(oldselect)) > 0 then
oldletter = oldselect
oldselect=""
else
shell "xsel -cb" wait
shell "xdotool key Shift+Left" wait to oldselect
if len(trim(oldselect)) = "." then
oldletter = oldselect
else
oldletter = " "
endif
oldselect= ""
endif
shell "xclip -out -sel" to oldletter
shell "xsel -cb" wait
select case trim(oldletter)
case "."
shell "xdotool key Backspace" wait
shell "xdotool type " & "'" & "" & "'" wait
case " "
newletter = "."
shell "xdotool key Delete" wait
shell "xdotool type " & newletter & chr(32) wait
shell "xdotool key Left" wait
case else
newletter = upper(oldletter)
if newletter = oldletter then
newletter = lower(oldletter)
endif
newletter = "'" & newletter & "'"
shell "xdotool key Backspace" wait
shell "xdotool type " & newletter & chr(32) wait
shell "xdotool key Left" wait
end select
Print "OLD: "; oldletter ; " NEW: "; newletter
End