Browse Source

added support for special characters in typing

master
sciion 3 years ago
parent
commit
ab77bc9a48
No account linked to committer's email address

BIN
lib/AgentAPI.jar View File


+ 1
- 1
project/src/me/sciion/agent/utils/parser/KeyParser.java View File

@@ -99,7 +99,7 @@ public class KeyParser {
99 99
 	    e.printStackTrace();
100 100
 	}
101 101
 
102
-	for(Key k: parser.parse("W-r"))
102
+	for(Key k: parser.parse("Hello World"))
103 103
 	    if(k.isPress())
104 104
 		r.keyPress(k.getCode());
105 105
 	    else

+ 40
- 0
project/src/me/sciion/agent/utils/parser/KeyScanner.java View File

@@ -1,5 +1,6 @@
1 1
 package me.sciion.agent.utils.parser;
2 2
 
3
+import java.awt.event.KeyEvent;
3 4
 import java.util.LinkedList;
4 5
 import java.util.Stack;
5 6
 
@@ -47,6 +48,8 @@ public class KeyScanner {
47 48
 	    		state = 1;
48 49
 	    	    else if(c == 'C')
49 50
 	    		state = 1;
51
+	    	    else if(c == '\\')
52
+	    		state = 2;
50 53
 	    	    else
51 54
 	    		return new LiteralToken(c);
52 55
 		break;
@@ -59,6 +62,43 @@ public class KeyScanner {
59 62
 	    		state = 0;
60 63
 	    		return new LiteralToken(c);
61 64
 	    	    }
65
+	    	case 2:
66
+		c = scan();
67
+		if (c == '\\') {
68
+		    state = 0;
69
+		    return new LiteralToken('\\');
70
+		} else if (c == 'n') {
71
+		    state = 0;
72
+		    return new LiteralToken('\n');
73
+		} 
74
+		else if (c == 'r') {
75
+		    state = 0;
76
+		    return new LiteralToken('\r');
77
+		}
78
+		else if (c == '\"') {
79
+		    state = 0;
80
+		    return new LiteralToken('\"');
81
+		}
82
+		else if (c == 't') {
83
+		    state = 0;
84
+		    return new LiteralToken('\t');
85
+		}
86
+		else if (c == 'b') {
87
+		    state = 0;
88
+		    return new LiteralToken('\b');
89
+		}
90
+		else if (c == 'f') {
91
+		    state = 0;
92
+		    return new LiteralToken('\f');
93
+		}
94
+		else if (c == '\'') {
95
+		    state = 0;
96
+		    return new LiteralToken('\'');
97
+		}
98
+		else{
99
+		    state = -1;
100
+		}
101
+	    	break;
62 102
 		default:
63 103
 		    System.out.println("Error in scanner. Current char: " + c);
64 104
 		    return null;

+ 1
- 1
project/src/me/sciion/agent/utils/parser/TokenType.java View File

@@ -2,5 +2,5 @@ package me.sciion.agent.utils.parser;
2 2
 
3 3
 public enum TokenType {
4 4
 
5
-    LITERAL, MODIFIER
5
+    LITERAL, MODIFIER, FUNCTION
6 6
 }

+ 1
- 10
scripts/HelloWorld.py View File

@@ -2,13 +2,4 @@ import sys
2 2
 sys.path.append("lib/AgentAPI.jar")
3 3
 from me.sciion.agent.api import API
4 4
 from me.sciion.agent.utils import Location
5
-
6
-location1 = Location(0,0)
7
-template1 = API.loadTemplate("assets/templates/template-chrome-icon-start-menu.png")
8
-if API.exists(template1):
9
-	location1 = API.locate(template1)
10
-	API.move(location1)
11
-	API.click()
12
-	print(location1)
13
-else:
14
-	print("Template not found")
5
+print API.getVersion()

+ 4
- 0
scripts/SimpleTypingExample.py View File

@@ -0,0 +1,4 @@
1
+import sys
2
+sys.path.append("lib/AgentAPI.jar")
3
+from me.sciion.agent.api import API
4
+API.type("W-rC-a notepad\n")

+ 0
- 17
scripts/StartKeepass.py View File

@@ -1,17 +0,0 @@
1
-import sys
2
-sys.path.append("lib/AgentAPI.jar")
3
-from me.sciion.agent.api import API
4
-template1 = API.loadTemplate("assets/templates/KeepassIcon.png")
5
-if API.exists(template1):
6
-	location1 = API.locate(template1)
7
-	API.move(location1)
8
-	API.click()
9
-	API.click()
10
-	template2 = API.loadTemplate("assets/templates/KeepassIconKeys.png")
11
-	API.waitForTemplate(template2)
12
-	API.move(API.locate(template2))
13
-	template3 = API.loadTemplate("assets/templates/KeepassPWField.png")
14
-	API.waitForTemplate(template3)
15
-	API.move(API.locate(template3))
16
-else:
17
-	print("Template not found")

+ 1
- 1
scripts/TypingExample.py View File

@@ -4,4 +4,4 @@ from me.sciion.agent.api import API
4 4
 API.type("W-rnotepad")
5 5
 API.type("Hello World")
6 6
 API.type("AltS-.")
7
-API.type("S-hello S-world S-7S-7 GUI-Agent")
7
+API.type("S-hello S-world")

Loading…
Cancel
Save