TO THE EXPERIENCED: How does this look?

High Alchemy Rough Draft Advanced.kmmacros (50 KB)

Created this for some stupid game, but that's beside the point. I started keyboard maestro last week and have been catching on, but still lack plenty of knowledge obviously. Out of my newly gained knowledge, I'd say the most important concept was the familiarization of global variables/subtasks. Anyways, Here's the script:

Script features:
Initialization:
*Activate or deactivate the script with a hotkey.
*The script calculates a random duration of time to be logged in: within a 2.5 to 5-hour range and keeps track of your logged-in duration.
*ALL click positions are randomly selected from the range of coordinates specified on the entire location of the target

Main Loop:
*The script selects a random coordinate within the click area of the specified coordinate range *Pauses for a brief moment between 1.5 to 2 seconds before each action
*Randomly determines a time within 15 to 45 minutes for subtle mouse movement changes within the click area
*Generates varied time intervals between each click:
Most common: 1.5 to 2 seconds (95% chance).
Least common: 15 to 60 seconds (0.25% chance).

Logout Sequence:
*Once the random calculation for the logout time is reached, it clicks the logout buttons and then calculates a random duration to wait before logging back in (between 20 minutes and 2 hours)

Login Sequence; After the pause duration determined after logging out:
*Clicks the login button
*Waits for 15 to 30 seconds.
*Clicks the welcome message and the whole cycle repeats until the script is ended via hotkey

What I'd like to know from the veteran Keyboard Maestro users here:

  1. How does it look?
  2. What would you do differently?

That's far too intricate for anyone to judge without having the game and the actual macro.

It's always a good idea to post the actual macro to the forum rather than just screenshots. Perhaps if you do that and there happens to be another player on here, you might get some insight.

Most importantly, if it works, without noticeable downsides, then you did a good job!

Edits above: I wasn't paying proper attention.

1 Like

Gotcha! Sorry, I'm new to this forum - Did I not post the macro? The screenshot and macro download are at the top. Let me know if there's something I'm missing.

Thanks for the reply

1 Like

My bad. I missed the actual macro. :man_facepalming:t2:

1 Like

One thing I can say is that you should be using local rather than global for any variables not needed outside of this macro. This keeps your variable list lean, which is good practice in general, as numerous large variable values stored globally can start to hinder performance.

Info on variable types here:

https://wiki.keyboardmaestro.com/manual/Variables

2 Likes

This ↑

Plus, in my experience (take it with a grain of salt), using local variables results in faster macro execution as opposed to using global variables.

2 Likes

Got it. If my memory is correct, setting a variable locally would involve typing Local__ before the name. I’ll go look it up now and come back to edit this comment for any future researchers.

Edit:
In short, you don’t need the underscores and the “L” should be lower case. Read the legend’s comment below for the right direction.

1 Like

Also, I’ve been trying to get this script to display certain calculation variables in the form of EST.

Example: It calculates the amount of time to be logged in, but it’s in Unix. I’m trying to get it to show it’s calculation in hours/minutes, as well as the start time of the script (NOW() = StartTime) to allow me to see the amount of time I have left.

If either of you know a command that could get me started or know a direction I can head to find out, I’d greatly appreciate that.

Technically you don’t need the double underscore, a local variable just needs to start with local, so for example: localVariable. The double underscore (example: local__Variable) just hides anything behind the underscores in user prompts.

So for instance, in the Prompt for User Input action, if you include a double underscore in variable, the only thing that the prompt will show is whatever comes after the underscores.

Example: AOE__Unit, the AOE__ will not display in the prompt as seen in the screenshots.

Action Screenshots (click to expand/collapse)


4 Likes

Here are some examples to show how that can be done. Keyboard Maestro has a native feature to convert from unix to human readable, but unless I’m mistaken, it doesn’t have a native feature to convert from human readable to unix. So I use a shell script to do that. Note that in the shell script your flags (everything in the quotation marks after -jf, in the example %H:%M) must match the format of the KM variable.

Download Macro(s): Unix and human readable time conversions.kmmacros (4.1 KB)

Macro-Image

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 13.6
  • Keyboard Maestro v10.2
2 Likes

You’re a beast. I’ll update when I try this in about 20 minutes.

1 Like

Dude you're awesome. This is an issue I gave up on initially; now I have 3 different continuous notifications that pop up as Mac alerts. Thanks!

Hi, @BenchPressMacro. It looks like you have a very good grasp of the actions you have used. As @noisneil mentioned, without the app it's inefficient (at best) to comment on the overall logic.

I have a few personal preferences that I'd like to share:

  1. I agree with the advice from @noisneil and @cdthomer regarding local variables. I use a local_ prefix unless the variable is used in a Prompt For User Input dialog or Execute a Subroutine (parameter). In those cases, I use local__. I like to be able to distinguish the two at a glance.

  2. With logic actions, I like to set the action colors. My preference is to alternate between yellow and green with nested logic actions. My other color conventions are:

  3. When one condition is not used in a logic action, I insert an Intentionally Blank Comment action.

Below is your macro with those suggestions (minus the change to local variables). I placed all of your actions in a Group and then collapsed the group, otherwise the image created during the native upload function is too large. (Note that the image size could also be reduced by collapsing logic actions; but I opted to use one enclosing group because I wanted to preserve the original presentation of your macro within the group.)


High Alchemy Rough Draft Advanced (@_jims suggestions) Macro (v10.2)

High Alchemy Rough Draft Advanced (@_jims suggestions).kmmacros (63 KB)


Finally, here are a few links I routinely share with new users:

3 Likes

Thanks man! Didn't expect such helpful responses, I appreciate it.

1 Like

What does this script accomplish in the game? Is it like automated farming of materials or experience points? I like the idea of automating tedious and repetitive stuff in games and have tried this myself with varying success, so you got me curious!

Yes it is. A lot of people hate on it, but I don’t have the patience to sit there for hours clicking a million times lol. Ive come a long way since this post.

The script randomizes everything (pauses/breaks, clicking locations, etc.), reports stats like xp/actions per hour, and even has a built in error contingency setup. If it messes up in any way (lags and misplaces an item, logs me out, etc.) it will go through a serious of troubleshooting steps and correct the issue itself.

Im at the point where I could leave it on 24/7 and never touch it if I want to.

1 Like

Thought it might be worth pointing out the Try/Catch action, in case it might help you simplify contingencies when things go awry.

action:Try or Catch [Keyboard Maestro Wiki].

Thought it might be worth pointing out the Try/Catch action, in case it might help you simplify contingencies when things go awry.
action:Try or Catch [Keyboard Maestro Wiki].

Awesome thanks I'll definitely go check it out. I ended up detecting changes in the application (E.g., a certain process coming to a halt) via pixel conditions. I could NOT, for the life of me, getting Found Image on Screen to work. I tried absolutely everything I could find online: permissions, screen resolution, fuzziness, the list goes on. I even tried going the OCR route but found it to be a little too inconsistent.

I have a long list of If/then/otherwise and while/until functions along with multiple "execute a macro" actions throughout a massive script. It definitely gets tough when I'm trying to implement something big but it's a good time for sure.