|
Post by Victor on Jun 9, 2021 17:29:28 GMT
Is there a way to force my macro to HOLD a key for a random amount of seconds? I'm new to coding macros so i'm not really sure how'd that work.
|
|
|
Post by Steve on Jun 11, 2021 5:49:07 GMT
Hi Victor, Yep. Like this: 1 | 2207 | 720 | 0 | Left Click 2 | RUN ACTION | SELECT WINDOW BY NAME | Untitled - Notepad 3 | 471 | 587 | 0 | Keypress a | Key Down 4 | RUN ACTION | WAIT SECONDS | %random_1-5% 5 | 471 | 587 | 0 | Keypress a | Key Release 6 | 471 | 587 | 0 | Keypress b | Key Down 7 | RUN ACTION | WAIT SECONDS | %random_3-7% 8 | 471 | 587 | 0 | Keypress b | Key Release 9 | 471 | 587 | 0 | Keypress c | Key Down 10 | RUN ACTION | WAIT SECONDS | %random_2-6% 11 | 471 | 587 | 0 | Keypress c | Key Release 12 | 2207 | 720 | 50 | Left Click Here we use the RANDOM variable (https://www.turnssoft.com/conditions.html#random_integer_variable) to wait a random amount of time between our key release. This example holds down the 'a' key for a random time between 1 and 5 seconds, 'b' random time between 3 and 7 seconds, and 'c' random time between 2 and 6 seconds.
It looks like this: Here we use the RANDOM variable ( www.turnssoft.com/conditions.html#random_integer_variable) to wait a random amount of time between our key release. This example holds down the 'a' key for a random time between 1 and 5 seconds, 'b' random time between 3 and 7 seconds, and 'c' random time between 2 and 6 seconds. Here is another post with something similar minimousemacro.proboards.com/thread/321/make-macro-random-number-seconds.
Hope this helps.
|
|
|
Post by Victor on Jun 23, 2021 20:35:11 GMT
Hi Victor, Yep. Like this: 1 | 2207 | 720 | 0 | Left Click 2 | RUN ACTION | SELECT WINDOW BY NAME | Untitled - Notepad 3 | 471 | 587 | 0 | Keypress a | Key Down 4 | RUN ACTION | WAIT SECONDS | %random_1-5% 5 | 471 | 587 | 0 | Keypress a | Key Release 6 | 471 | 587 | 0 | Keypress b | Key Down 7 | RUN ACTION | WAIT SECONDS | %random_3-7% 8 | 471 | 587 | 0 | Keypress b | Key Release 9 | 471 | 587 | 0 | Keypress c | Key Down 10 | RUN ACTION | WAIT SECONDS | %random_2-6% 11 | 471 | 587 | 0 | Keypress c | Key Release 12 | 2207 | 720 | 50 | Left Click Here we use the RANDOM variable (https://www.turnssoft.com/conditions.html#random_integer_variable) to wait a random amount of time between our key release. This example holds down the 'a' key for a random time between 1 and 5 seconds, 'b' random time between 3 and 7 seconds, and 'c' random time between 2 and 6 seconds.
It looks like this: Here we use the RANDOM variable ( www.turnssoft.com/conditions.html#random_integer_variable) to wait a random amount of time between our key release. This example holds down the 'a' key for a random time between 1 and 5 seconds, 'b' random time between 3 and 7 seconds, and 'c' random time between 2 and 6 seconds. Here is another post with something similar minimousemacro.proboards.com/thread/321/make-macro-random-number-seconds.
Hope this helps.
Hi Steve, i just stumbled back to this as i tried to do it again, again, it just waits the amount of seconds before releasing the key, but it doesn't hold the key itself. For example, using your code mentioned above: 3 | 471 | 587 | 0 | Keypress a | Key Down 4 | RUN ACTION | WAIT SECONDS | %random_1-5% 5 | 471 | 587 | 0 | Keypress a | Key Release What i would intend it to do is actually hold "a" so it should do this: "aaaaaaaaaaaa" Hope i explained correctly
|
|
|
Post by Victor on Jun 23, 2021 20:40:56 GMT
Some action pressing the key for a random amount of times (like on the waiting seconds option, press the key a random amount of times between 5 and 100 or something like that) would help too now that i think about it
|
|
|
Post by Steve on Jun 24, 2021 7:31:08 GMT
We can do that by using the loop option with %random% on individual lines. Like this: 1 | RUN ACTION | SELECT WINDOW BY NAME | random test.txt - Notepad 2 | 577 | 610 | 100 | Keypress ENTER 3 | 577 | 610 | 100 | Keypress t | loop %random_1-10%::0 4 | 577 | 610 | 100 | Keypress ENTER 5 | 577 | 610 | 100 | Keypress e | loop %random_1-10%::0 6 | 577 | 610 | 100 | Keypress ENTER 7 | 577 | 610 | 100 | Keypress s | loop %random_1-10%::0 8 | 577 | 610 | 100 | Keypress ENTER 9 | 577 | 610 | 100 | Keypress t | loop %random_1-10%::0
|
|
|
Post by zeak on Jun 25, 2021 4:11:08 GMT
Hi Steve, I there a way to get MMM to behave the same as holding down a key. when using MMM key down, it will only press the key once in notepad, unlike if you held down the key it will be pressed multiple times.
|
|
|
Post by Steve on Jun 25, 2021 5:20:11 GMT
Hi Steve, I there a way to get MMM to behave the same as holding down a key. when using MMM key down, it will only press the key once in notepad, unlike if you held down the key it will be pressed multiple times. Yes I've noticed it doesn't behave like that. I need to revisit the function I use to handle the KEY DOWN and KEY RELEASE events. It works ok for holding key modifiers like ctrl but maybe it's a little off for standard keys. I've found it hard to test a good use case for holding single keys down. The keys down and up are handled by keybd_event dwFlag. With a key down event we send a depress event and a key release we send a keyup event: Public Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
If e.ToLower = "key down" Then If ConvertKeytoInt(d) = 9999 Then EventArrayAdd("2|evt|Could not convert the key '" & d & "' to a valid key for the Key Down press. Key Down is expecting a single key|evt|1", "war") strErrorBack = " - Key Down can not accept '" & d & "' as a value" boolRunErrors = True Else keybd_event(ConvertKeytoInt(d), 0, 0, 0) boolKeyDownIsHeld = True strOut = "{" & d & "}" End If ElseIf e.ToLower = "key release" Then If Not ConvertKeytoInt(d) = 9999 Then keybd_event(ConvertKeytoInt(d), 0, 2, 0) boolKeyDownIsHeld = False Else EventArrayAdd("2|evt|Could not convert the key '" & d & "' to a valid key for the Key Release press. Skipping...|evt|1", "war") End If End If
|
|
|
Post by Victor on Jun 25, 2021 20:39:21 GMT
We can do that by using the loop option with %random% on individual lines. Like this: 1 | RUN ACTION | SELECT WINDOW BY NAME | random test.txt - Notepad 2 | 577 | 610 | 100 | Keypress ENTER 3 | 577 | 610 | 100 | Keypress t | loop %random_1-10%::0 4 | 577 | 610 | 100 | Keypress ENTER 5 | 577 | 610 | 100 | Keypress e | loop %random_1-10%::0 6 | 577 | 610 | 100 | Keypress ENTER 7 | 577 | 610 | 100 | Keypress s | loop %random_1-10%::0 8 | 577 | 610 | 100 | Keypress ENTER 9 | 577 | 610 | 100 | Keypress t | loop %random_1-10%::0 Everyday i'm more impressed by coding, thanks Steve.
|
|
|
Post by Blackvolfpl on Jul 10, 2023 14:24:56 GMT
Hi Guys, I wonder if I can program such a macro with this tool
Example; time X1;x2 is time press/time when release
launch with ALT+X shortcut or something in a specific window Name X delay 3 seconds START 0.00 press up nad hold to example 11.40
3.75-3.89 press left (from start 0.00) 4.28-8.28 press right
4.59-8.22 press down
6.25-6.45 press left
8.23-8.70 press left
9.10-9.25 press right
9.61-9.66 press left
|
|