File tree 6 files changed +312
-11
lines changed
6 files changed +312
-11
lines changed Original file line number Diff line number Diff line change
1
+ package CallGo
2
+
3
+ import (
4
+ KeyTool "GoRobotScript/GokeyLog/Tool"
5
+ "github.com/go-vgo/robotgo"
6
+ "github.com/yuin/gopher-lua"
7
+ )
8
+
9
+ func Loader (L * lua.LState ) int {
10
+ // register functions to the table
11
+ mod := L .SetFuncs (L .NewTable (), exports )
12
+ // register other stuff
13
+ L .SetField (mod , "name" , lua .LString ("value" ))
14
+
15
+ // returns the module
16
+ L .Push (mod )
17
+ return 1
18
+ }
19
+
20
+ // 定义一个map类型的变量exports,其中key为string类型,value为lua.LGFunction类型
21
+ var exports = map [string ]lua.LGFunction {
22
+ "myfunc" : myfunc , // 将myfunc函数注册到exports中
23
+ "keyLog" : keyLog , // 将keyLog函数注册到exports中
24
+ "showalert" : showalert ,
25
+ }
26
+
27
+ func keyLog (L * lua.LState ) int {
28
+ KeyTool .KeyLog ()
29
+ return 0
30
+ }
31
+
32
+ // 定义showalert函数,该函数接收两个参数,分别为title和msg
33
+ // title和msg均为string类型
34
+ // 函数返回值为int类型
35
+ func showalert (L * lua.LState ) int {
36
+ // 将第一个参数转换为string类型
37
+ title := L .ToString (1 )
38
+ // 将第二个参数转换为string类型
39
+ msg := L .ToString (2 )
40
+ // 调用robotgo.ShowAlert函数,弹出一个提示框,返回值为bool类型
41
+ abool := robotgo .ShowAlert (title , msg )
42
+ // 将返回值转换为lua.LBool类型,并压入栈中
43
+ L .Push (lua .LBool (abool ))
44
+ // 将弹出的Alert窗口置顶
45
+ robotgo .ActiveName (title )
46
+ // 返回参数个数1
47
+ return 1
48
+ }
49
+
50
+ func myfunc (L * lua.LState ) int {
51
+ return 0
52
+ }
Original file line number Diff line number Diff line change 1
- package CallGo
1
+ package SuKey
2
2
3
3
import (
4
- KeyTool "GoRobotScript/GokeyLog/Tool "
4
+ "github.com/go-vgo/robotgo "
5
5
"github.com/yuin/gopher-lua"
6
6
)
7
7
@@ -16,16 +16,14 @@ func Loader(L *lua.LState) int {
16
16
return 1
17
17
}
18
18
19
+ // 定义一个map类型的变量exports,其中key为string类型,value为lua.LGFunction类型
19
20
var exports = map [string ]lua.LGFunction {
20
- "myfunc" : myfunc ,
21
- "keyLog" : keyLog ,
22
- }
21
+ "TypeStr" : typeStr , // 将myfunc函数注册到exports中
23
22
24
- func keyLog (L * lua.LState ) int {
25
- KeyTool .KeyLog ()
26
- return 0
27
23
}
28
24
29
- func myfunc (L * lua.LState ) int {
25
+ func typeStr (L * lua.LState ) int {
26
+ str := L .ToString (1 )
27
+ robotgo .TypeStr (str )
30
28
return 0
31
29
}
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- CallGo "GoRobotScript/GokeyLua/Tool"
4
+ CallGo "GoRobotScript/GokeyLua/Tool/CallGo"
5
+ SuKey "GoRobotScript/GokeyLua/Tool/SuKey"
5
6
"flag"
6
7
"fmt"
7
8
lua "github.com/yuin/gopher-lua"
@@ -14,9 +15,11 @@ func ReadscriptUsage() {
14
15
15
16
}
16
17
func main () {
18
+
17
19
L := lua .NewState ()
18
20
defer L .Close ()
19
21
L .PreloadModule ("CallGo" , CallGo .Loader )
22
+ L .PreloadModule ("SuKey" , SuKey .Loader )
20
23
scriptpath := flag .String ("script" , "path" , "Script Path" )
21
24
//scriptpatht := *scriptpath
22
25
Simkeyrun := "main"
Original file line number Diff line number Diff line change 1
1
print (" Hello World!" )
2
2
local m = require (" CallGo" )
3
+ local key = require (" SuKey" )
4
+ key .TypeStr (" 0000000" )
3
5
m .myfunc ()
4
6
print (m .name )
5
- m . keyLog ( )
7
+ print ( m . showalert ( " AreU " , " Quit " ) )
6
8
function max (num1 , num2 )
7
9
8
10
if (num1 > num2 ) then
You can’t perform that action at this time.
0 commit comments