my_wins 1.1.5 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +42 -9
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -9,8 +9,8 @@ const defaultSettings = {
9
9
  width: 500,
10
10
  screenWidth:1920,
11
11
  screenHeight:1080,
12
- wy_total : 12,
13
- wx_total : 3,
12
+ wx_total : 3,
13
+ wy_total : 12,
14
14
  };
15
15
 
16
16
  function makeWinsArray(settings, ) {
@@ -66,6 +66,7 @@ module.exports.run = async ()=>{
66
66
  baz:{no_run:true, cmd:"my command line 2"},
67
67
  webstorm: {app:true, cmd:"C:\\Program Files\\JetBrains\\WebStorm 2019.2\\bin\\webstorm64.exe"},
68
68
  }
69
+ delay:0,
69
70
  }
70
71
 
71
72
  optionally create my_wins_personal.json to override any settings
@@ -128,10 +129,11 @@ module.exports.run = async ()=>{
128
129
  wins = keysender.getAllWindows();
129
130
  let winsArray = makeWinsArray(settings);
130
131
 
131
- let winIndex = 0;
132
+ const myWins = {};
133
+
132
134
  for(let k in settings.wins) {
133
135
  const w = settings.wins[k];
134
- const {name, title, app, cmd, no_run} = w;
136
+ const {name, title, app, cmd, no_run, delay} = w;
135
137
 
136
138
  let win_info_candidates = wins.filter(c => c.title.includes(title));
137
139
  const win_info = win_info_candidates[0];
@@ -141,17 +143,48 @@ module.exports.run = async ()=>{
141
143
  console.warn(`CODE00000000 There are ${win_info_candidates.length} windows with title '${title}'. Only one window expected!`);
142
144
  else {
143
145
  const win = new keysender.Hardware(win_info.handle);
144
- win.workwindow.setView(winsArray[winIndex]);
145
- win.workwindow.setForeground();
146
+ w.win = win;
147
+ w.activate = ()=>{
148
+ win.workwindow.setView(winsArray[winIndex]);
149
+ win.workwindow.setForeground();
150
+ }
151
+ w.print = async (cmd) => {
152
+ await awaitDelay(200);
153
+ w.activate();
154
+ win.keyboard.printText(cmd);
155
+ await awaitDelay(200);
156
+ }
146
157
 
147
- win.keyboard.printText(cmd);
148
- if(!no_run)
158
+ w.pressEnter = async () => {
159
+ w.activate();
149
160
  win.keyboard.sendKey(13);
150
- await awaitDelay(300);
161
+ await awaitDelay(200);
162
+ }
163
+
164
+ await w.print(cmd);
165
+ // await awaitDelay(200);
166
+ // if(!no_run) {
167
+ // if(delay) {
168
+ // await awaitDelay(delay);
169
+ // }
170
+ // w.pressEnter();
171
+ // }
172
+ // await awaitDelay(300);
151
173
  }
152
174
  winIndex++;
153
175
  }
154
176
 
177
+ for(let k in settings.wins) {
178
+ const w = settings.wins[k];
179
+ if(!no_run) {
180
+ if(delay) {
181
+ await awaitDelay(delay);
182
+ }
183
+ await w.pressEnter();
184
+ }
185
+ }
186
+
187
+
155
188
  await awaitDelay(700);
156
189
  console.log(`my_wins finished successfully!`);
157
190
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my_wins",
3
- "version": "1.1.5",
3
+ "version": "1.2.1",
4
4
  "description": "Automates starting and laying out your console windows for tsc, babel, tests, verdaccio, etc...",
5
5
  "keywords": ["automation","cmd","keysender","windows","autostart","autorun"],
6
6
  "main": "./index.js",