mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-30 22:13:54 +00:00
update clipboard code and add test code
This commit is contained in:
parent
7eeb418c3a
commit
f05b2858f4
@ -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 New Issue
Block a user