This repository was archived by the owner on Feb 8, 2024. It is now read-only.
File tree 1 file changed +24
-6
lines changed
1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -80,19 +80,37 @@ pub struct KeepActive {
80
80
_imp : sys:: KeepActive ,
81
81
}
82
82
83
- // TODO: gradual movement
84
- // exit gracefully on Ctrl+C
83
+ // TODO: exit gracefully on Ctrl+C
85
84
pub fn simulate_activity ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
86
85
let mut enigo = Enigo :: new ( ) ;
87
86
88
87
loop {
89
- enigo. mouse_move_relative ( 100 , 100 ) ;
90
- thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
91
- enigo. mouse_move_relative ( -100 , -100 ) ;
88
+ // Move right
89
+ for _ in 0 ..10 {
90
+ enigo. mouse_move_relative ( 1 , 0 ) ;
91
+ thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
92
+ }
93
+ // Move down
94
+ for _ in 0 ..10 {
95
+ enigo. mouse_move_relative ( 0 , 1 ) ;
96
+ thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
97
+ }
98
+ // Move left
99
+ for _ in 0 ..10 {
100
+ enigo. mouse_move_relative ( -1 , 0 ) ;
101
+ thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
102
+ }
103
+ // Move up
104
+ for _ in 0 ..10 {
105
+ enigo. mouse_move_relative ( 0 , -1 ) ;
106
+ thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
107
+ }
92
108
109
+ // Simulate a key press to keep activity
93
110
enigo. key_down ( Key :: Shift ) ;
94
111
enigo. key_up ( Key :: Shift ) ;
95
112
96
- thread:: sleep ( Duration :: from_secs ( 2 ) ) ; // TODO: make this configurable
113
+ thread:: sleep ( Duration :: from_secs ( 60 ) ) ; // TODO: Make this configurable
97
114
}
98
115
}
116
+
You can’t perform that action at this time.
0 commit comments