my_wins 1.1.6 → 1.2.2

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 +46 -8
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -22,8 +22,8 @@ function makeWinsArray(settings, ) {
22
22
 
23
23
  const wy_step = Math.round( screenHeight*1.0/wy_total);
24
24
  const wx_step = Math.round(screenWidth*1.0/wx_total);
25
- for(let wx = 0; wx<wx_total;wx++ ) {
26
- for(let wy = 0; wy<wy_total;wy++ ) {
25
+ for(let wy = 0; wy<wy_total;wy++ ) {
26
+ for(let wx = 0; wx<wx_total;wx++ ) {
27
27
  const nx = (x||0)+wx_step*wx;
28
28
  const ny = (y||0)+wy_step*wy;
29
29
  winsArray.push({x:nx,y:ny, width:wx_step-1, height:wy_step-1});
@@ -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
 
132
+ const myWins = {};
131
133
  let winIndex = 0;
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,53 @@ 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.winIndex = winIndex;
148
+ w.view = winsArray[winIndex];
149
+ win.workwindow.setView(w.view);
150
+
151
+ w.activate = async ()=>{
152
+ win.workwindow.setForeground();
153
+ await awaitDelay(200);
154
+ }
155
+
156
+ w.print = async (cmd) => {
157
+ await w.activate();
158
+ win.keyboard.printText(cmd);
159
+ await awaitDelay(200);
160
+ }
146
161
 
147
- win.keyboard.printText(cmd);
148
- if(!no_run)
162
+ w.pressEnter = async () => {
163
+ await w.activate();
149
164
  win.keyboard.sendKey(13);
150
- await awaitDelay(300);
165
+ await awaitDelay(200);
166
+ }
167
+
168
+ await w.print(cmd);
169
+ // await awaitDelay(200);
170
+ // if(!no_run) {
171
+ // if(delay) {
172
+ // await awaitDelay(delay);
173
+ // }
174
+ // w.pressEnter();
175
+ // }
176
+ // await awaitDelay(300);
151
177
  }
152
178
  winIndex++;
153
179
  }
154
180
 
181
+ for(let k in settings.wins) {
182
+ const w = settings.wins[k];
183
+ const {name, title, app, cmd, no_run, delay} = w;
184
+ if(!no_run) {
185
+ if(delay) {
186
+ await awaitDelay(delay);
187
+ }
188
+ await w.pressEnter();
189
+ }
190
+ }
191
+
192
+
155
193
  await awaitDelay(700);
156
194
  console.log(`my_wins finished successfully!`);
157
195
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my_wins",
3
- "version": "1.1.6",
3
+ "version": "1.2.2",
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",