mirror of
https://github.com/go-vgo/robotgo
synced 2026-05-24 10:19:01 +00:00
update clipboard code and add test code
This commit is contained in:
parent
7eeb418c3a
commit
f05b2858f4
2 changed files with 12 additions and 3 deletions
|
|
@ -700,8 +700,8 @@ func ReadAll() (string, error) {
|
|||
}
|
||||
|
||||
// WriteAll write string to clipboard
|
||||
func WriteAll(text string) {
|
||||
clipboard.WriteAll(text)
|
||||
func WriteAll(text string) error {
|
||||
return clipboard.WriteAll(text)
|
||||
}
|
||||
|
||||
// CharCodeAt char code at utf-8
|
||||
|
|
@ -791,7 +791,7 @@ func PasteStr(str string) string {
|
|||
if runtime.GOOS == "darwin" {
|
||||
return KeyTap("v", "command")
|
||||
}
|
||||
|
||||
|
||||
return KeyTap("v", "control")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,15 @@ func TestKey(t *testing.T) {
|
|||
tt.Empty(t, e)
|
||||
}
|
||||
|
||||
func TestClip(t *testing.T) {
|
||||
err := WriteAll("s")
|
||||
tt.Nil(t, err)
|
||||
|
||||
s, e := ReadAll()
|
||||
tt.Equal(t, "s", s)
|
||||
tt.Nil(t, e)
|
||||
}
|
||||
|
||||
func TestTypeStr(t *testing.T) {
|
||||
c := CharCodeAt("s", 0)
|
||||
tt.Equal(t, 115, c)
|
||||
|
|
|
|||
Loading…
Reference in a new issue