mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +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
|
// WriteAll write string to clipboard
|
||||||
func WriteAll(text string) {
|
func WriteAll(text string) error {
|
||||||
clipboard.WriteAll(text)
|
return clipboard.WriteAll(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CharCodeAt char code at utf-8
|
// CharCodeAt char code at utf-8
|
||||||
@ -791,7 +791,7 @@ func PasteStr(str string) string {
|
|||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
return KeyTap("v", "command")
|
return KeyTap("v", "command")
|
||||||
}
|
}
|
||||||
|
|
||||||
return KeyTap("v", "control")
|
return KeyTap("v", "control")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,15 @@ func TestKey(t *testing.T) {
|
|||||||
tt.Empty(t, e)
|
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) {
|
func TestTypeStr(t *testing.T) {
|
||||||
c := CharCodeAt("s", 0)
|
c := CharCodeAt("s", 0)
|
||||||
tt.Equal(t, 115, c)
|
tt.Equal(t, 115, c)
|
||||||
|
Loading…
Reference in New Issue
Block a user