Skip to content

Commit a8b0631

Browse files
committed
Allows to set click and clack on same timer
Also allows to set delay between them and set which triggers first
1 parent b47fa98 commit a8b0631

File tree

7 files changed

+178
-33
lines changed

7 files changed

+178
-33
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ allows you to set:
2929
From main window, you can click on:
3030
- mouse icon, which opens mouse settings
3131
- keyboard icon, which opens special keys
32+
- clock icon, which opens timer settings
3233

3334
From window toolbar, you can click on:
3435
- settings icon, which opens application settings
@@ -49,6 +50,15 @@ allows you to set:
4950

5051
<img src="keyboard-settings.png" alt="Keyboard settings window"/>
5152

53+
### Timer settings
54+
55+
allows you to set:
56+
- whether mouse and keyboard share same timer
57+
- whether mouse clicks first or keyboard clacks first in shared timer mode
58+
- delay between each action in shared timer mode
59+
60+
<img src="timer-settings.png" alt="Timer settings window"/>
61+
5262
### Application settings
5363

5464
allows you to set:

main-window.png

3.02 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clickandclack",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Super simple application for clicking mouse button and clacking key button in defined interval.",
55
"productName": "Click and Clack",
66
"cordovaId": "eu.houby_studio.clickandclack",

src/layouts/MainLayout.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@
106106
</q-layout>
107107
</template>
108108

109+
<style>
110+
body {
111+
overflow: hidden;
112+
}
113+
</style>
114+
109115
<script>
110116
import { sync } from 'vuex-pathify'
111117

src/pages/Index.vue

Lines changed: 158 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<q-page class="flex flex-center">
3-
<!-- Mouse Dialog -->
3+
<!-- Mouse dialog -->
44
<q-dialog
55
v-model="mouseSettings"
66
transition-show="scale"
@@ -20,7 +20,7 @@
2020
toggle-color="primary"
2121
:options="[
2222
{label: 'Left', value: 'left'},
23-
{label: 'Right', value: 'right'},
23+
{label: 'Right', value: 'right'}
2424
]"
2525
/>
2626
</q-card-section>
@@ -32,7 +32,7 @@
3232
toggle-color="primary"
3333
:options="[
3434
{label: 'Yes', value: true},
35-
{label: 'No', value: false},
35+
{label: 'No', value: false}
3636
]"
3737
/>
3838
</q-card-section>
@@ -91,6 +91,95 @@
9191
</q-page-sticky>
9292
</q-card>
9393
</q-dialog>
94+
<!-- Timer dialog -->
95+
<q-dialog
96+
v-model="timerSettings"
97+
transition-show="scale"
98+
transition-hide="scale"
99+
full-width
100+
full-height
101+
>
102+
<q-card class="full-width">
103+
<q-card-section class="q-py-xs">
104+
<div class="text-h6 text-center">Timer settings</div>
105+
</q-card-section>
106+
<q-card-section class="q-py-sm">
107+
<!-- If Yes, mouse and keyboard share same interval; If No, each has separate interval -->
108+
<div class="text-h6 text-center">Click & Clack together</div>
109+
<q-btn-toggle
110+
v-model="clickAndClackTogether"
111+
spread
112+
toggle-color="primary"
113+
:options="[
114+
{ label: 'Yes', value: true },
115+
{ label: 'No', value: false }
116+
]"
117+
/>
118+
</q-card-section>
119+
<q-card-section class="q-py-sm">
120+
<!-- If true, mouse clicks first, then delay, then keyboard; If false, keyboard clacks first, then delay, then mouse -->
121+
<div class="text-h6 text-center">Trigger order</div>
122+
<q-btn-toggle
123+
v-model="clickFirst"
124+
spread
125+
toggle-color="primary"
126+
:disable="!clickAndClackTogether"
127+
:options="[
128+
{ value: true, slot: 'clickthenclack' },
129+
{ value: false, slot: 'clackthenclick' }
130+
]"
131+
>
132+
<template v-slot:clickthenclack>
133+
1.
134+
<q-icon name="mouse" />
135+
2.
136+
<q-icon name="keyboard" />
137+
<q-tooltip :delay="1000">Click then clack</q-tooltip>
138+
</template>
139+
<template v-slot:clackthenclick>
140+
1.
141+
<q-icon name="keyboard" />
142+
2.
143+
<q-icon name="mouse" />
144+
<q-tooltip :delay="1000">Clack then click</q-tooltip>
145+
</template>
146+
</q-btn-toggle>
147+
</q-card-section>
148+
<q-card-section class="q-py-sm">
149+
<!-- Number in seconds, which sets delay between 1st action and 2nd action on each interval cycle -->
150+
<q-input
151+
type="number"
152+
lazy-rules
153+
v-model="delaySeconds"
154+
no-error-icon
155+
label="Delay in seconds"
156+
:disable="!clickAndClackTogether"
157+
:rules="[
158+
val => val !== null && val !== '' || 'Set delay!',
159+
val => val => 0 || 'Must be positive!'
160+
]"
161+
>
162+
<template v-slot:append>
163+
<q-icon name="schedule" />
164+
</template>
165+
</q-input>
166+
</q-card-section>
167+
<q-page-sticky
168+
position="bottom"
169+
:offset="[0, 0]"
170+
>
171+
<q-card-actions>
172+
<q-btn
173+
icon="close"
174+
round
175+
color="primary"
176+
v-close-popup
177+
>
178+
</q-btn>
179+
</q-card-actions>
180+
</q-page-sticky>
181+
</q-card>
182+
</q-dialog>
94183
<!-- Main page -->
95184
<q-card
96185
square
@@ -120,16 +209,22 @@
120209
<template v-slot:prepend>
121210
<q-btn
122211
icon="mouse"
212+
size="small"
123213
round
124214
@click="showMouseSettings"
125215
/>
126216
</template>
127217
<template v-slot:append>
128-
<q-icon name="schedule" />
218+
<q-btn
219+
icon="schedule"
220+
size="small"
221+
round
222+
@click="showTimerSettings"
223+
/>
129224
</template>
130225
</q-input>
131226
<div class="row">
132-
<div class="col-7">
227+
<div :class="clickAndClackTogether ? 'col-12' : 'col-7'">
133228
<!-- Key to press input -->
134229
<q-input
135230
class="q-my-xs"
@@ -146,13 +241,17 @@
146241
<template v-slot:prepend>
147242
<q-btn
148243
icon="keyboard"
244+
size="small"
149245
round
150246
@click="showKeyboardSettings"
151247
/>
152248
</template>
153249
</q-input>
154250
</div>
155-
<div class="col-5">
251+
<div
252+
class="col-5"
253+
v-show="!clickAndClackTogether"
254+
>
156255
<!-- Key timer input -->
157256
<q-input
158257
class="q-my-xs"
@@ -162,14 +261,19 @@
162261
no-error-icon
163262
stack-label
164263
label="Seconds"
165-
:disable="workflowRunning"
264+
:disable="workflowRunning || clickAndClackTogether"
166265
:rules="[
167266
val => val !== null && val !== '' || 'Set interval!',
168267
val => val > 0 || 'Must be positive!'
169268
]"
170269
>
171270
<template v-slot:append>
172-
<q-icon name="schedule" />
271+
<q-btn
272+
icon="schedule"
273+
size="small"
274+
round
275+
@click="showTimerSettings"
276+
/>
173277
</template>
174278
</q-input>
175279
</div>
@@ -180,11 +284,16 @@
180284
<q-btn
181285
@click="buttonPress"
182286
unelevated
183-
label="Alt + C"
287+
:label="workflowRunning ? 'STOP' : 'START'"
184288
color="primary"
185289
size="lg"
186290
class="full-width"
187-
/>
291+
>
292+
<q-tooltip
293+
transition-show="jump-up"
294+
transition-hide="jump-down"
295+
>Press <b>Alt + C</b> to {{ workflowRunning ? 'STOP' : 'START' }}</q-tooltip>
296+
</q-btn>
188297
</q-card-actions>
189298
</q-form>
190299
</q-card>
@@ -205,9 +314,10 @@ export default {
205314
workflowRunning: false, // When button was pressed and either mouse, keyboard or both are running
206315
mouseInterval: {}, // Holds object for time interval on mouse
207316
keyInterval: {}, // Holds object for time interval on keyboard
208-
progress: 0, // Holds progress value
317+
randomNum: 0, // Holds random delay value
209318
mouseSettings: false, // Dialog visibility for mouse settings
210319
keyboardSettings: false, // Dialog visibility for keyboard settings
320+
timerSettings: false, // Dialog visibility for mouse timer settings
211321
specialKeys: ['space', 'enter', 'tab', 'escape', 'control', 'alt', 'shift'] // Special keys which user can define
212322
}
213323
},
@@ -218,10 +328,13 @@ export default {
218328
},
219329
mouseTimer: sync('store/mouseTimer'), // Seconds to press mouse
220330
keyTimer: sync('store/keyTimer'), // Seconds to press key
331+
clickAndClackTogether: sync('store/clickAndClackTogether'), // Timer settings - share same timer for clicking and clacking
332+
clickFirst: sync('store/clickFirst'), // Timer settings - whether order is click>clack or clack>click
333+
delaySeconds: sync('store/delaySeconds'), // Timer settings - Delay between click and clack when timer is shared
221334
key: sync('store/key'), // Key to press
222335
mouseButton: sync('store/mouseButton'), // Left or Right button
223336
doubleClick: sync('store/doubleClick'), // Double click or Single click
224-
randomDelay: sync('store/randomDelay'), // Apply random delay up to 5 seconds
337+
randomDelay: sync('store/randomDelay'), // Apply random delay, up to 5 seconds
225338
clicking: sync('store/clicking'), // Should mouse be clicking
226339
clacking: sync('store/clacking') // Should key be clacking
227340
},
@@ -232,6 +345,9 @@ export default {
232345
showKeyboardSettings () {
233346
this.keyboardSettings = !this.keyboardSettings // Show or hide keyboard settings dialog
234347
},
348+
showTimerSettings () {
349+
this.timerSettings = !this.timerSettings // Show or hide mouse timer settings dialog
350+
},
235351
setCustomKey (keyName) {
236352
this.key = keyName // Set custom key from keyboard dialog
237353
},
@@ -240,51 +356,61 @@ export default {
240356
},
241357
buttonPress () {
242358
// Activated with button press or global shortcut. Toggle between on and off.
243-
// Example: If you set 10 seconds for mouse click, it triggers 10 times each second to update progress. 10. trigger also fires mouse.
244-
// Keyboard trigger has separate timer and does not reflect on progress bar
245359
if (this.workflowRunning) {
246360
// If workflow is already running, stop it
247361
this.workflowRunning = false
248362
this.browserWindow.setProgressBar(-1) // Disables progress on taskbar
249-
this.progress = 0
250363
clearInterval(this.mouseInterval) // Stop cycling intervals for mouse presses
251364
clearInterval(this.keyInterval) // Stop cycling intervals for key presses
252365
} else {
253366
// Start workflow
254367
this.workflowRunning = true
255-
this.browserWindow.setProgressBar(0) // Start progress from 0
256-
// Start mouse interval - Interval triggers 10 times to update progress bar, then fires click event, if clicking is enabled
368+
this.browserWindow.setProgressBar(2) // Starts continuous progress on taskbar
369+
// Start mouse interval - Simply waits certain number of seconds and then clicks, if clicking is enabled
257370
this.mouseInterval = setInterval(() => {
258-
if (this.progress === 10) {
259-
this.progress = 0
260-
this.browserWindow.setProgressBar(0) // Start progress from 0
261-
this.click()
371+
this.randomNum = Math.floor(Math.random() * 5 * 1000) // Delay in miliseconds between 0ms and 5000ms (5s)
372+
// If click and clack together is enabled, both happens in this mouse interval
373+
if (this.clickAndClackTogether) {
374+
if (this.clickFirst) {
375+
// If mouse should click first, trigger it first, then keyboard clack with eventual delay
376+
this.click()
377+
setTimeout(() => { this.clack() }, this.delaySeconds * 1000)
378+
} else {
379+
// If keyboard should clack first, trigger it first, then mouse click with eventual delay
380+
this.clack()
381+
setTimeout(() => { this.click() }, this.delaySeconds * 1000)
382+
}
262383
} else {
263-
this.browserWindow.setProgressBar(this.progress / 10)
264-
this.progress++
384+
// If click and clack together is not enabled, only click
385+
this.click()
265386
}
266-
}, this.mouseTimer * 100)
267-
// Start key interval - Simply waits certain number or seconds and then clacks if clacking is enabled
268-
this.keyInterval = setInterval(() => {
269-
this.clack()
270-
}, this.keyTimer * 1000)
387+
}, this.mouseTimer * 1000)
388+
// Start key interval - Simply waits certain number of seconds and then clacks, if clacking is enabled
389+
// If click and clack together is enabled, keyboard interval is not created
390+
if (!this.clickAndClackTogether) {
391+
this.keyInterval = setInterval(() => {
392+
this.clack()
393+
}, this.keyTimer * 1000)
394+
}
271395
}
272396
},
273397
click () {
398+
// If clicking is disabled in settings, do nothing
274399
if (this.clicking) {
275400
if (this.randomDelay) {
276-
var delay = Math.floor(Math.random() * 5 * 1000) // Delay in miliseconds between 0ms and 5000ms (5s)
277-
setTimeout(robot.mouseClick(this.mouseButton, this.doubleClick), delay) // Clicks with either left or right button and either single click or double click with random delay
401+
// If random delay should be applied, start timeout, otherwise immediately click
402+
setTimeout(robot.mouseClick(this.mouseButton, this.doubleClick), this.randomNum) // Clicks with either left or right button and either single click or double click with random delay
278403
} else {
279404
robot.mouseClick(this.mouseButton, this.doubleClick) // Clicks with either left or right button and either single click or double click without delay
280405
}
281406
}
282407
},
283408
clack () {
409+
// If clacking is disabled in settings, do nothing
284410
if (this.clacking) {
411+
// If random delay should be applied, start timeout, otherwise immediately clack
285412
if (this.randomDelay) {
286-
var delay = Math.floor(Math.random() * 5 * 1000) // Delay in miliseconds between 0ms and 5000ms (5s)
287-
setTimeout(robot.keyTap(this.key), delay) // Presses defined button with random delay
413+
setTimeout(robot.keyTap(this.key), this.randomNum) // Presses defined button with random delay
288414
} else {
289415
robot.keyTap(this.key) // Presses defined button without delay
290416
}

src/store/store/state.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export default function () {
44
keyTimer: 40,
55
key: 'A',
66
mouseButton: 'left',
7+
clickAndClackTogether: false,
8+
clickFirst: true,
9+
delaySeconds: 1,
710
doubleClick: false,
811
alwaysOnTop: false,
912
randomDelay: false,

timer-settings.png

13.6 KB
Loading

0 commit comments

Comments
 (0)