|
Post by zeak on Apr 6, 2020 23:49:46 GMT
Hi Steve , So I'm not sure if I am using IDLE action correctly or if you understand why I requested it. so the reason that I asked for this, was so that if I am using my computer then any macros would not run and only when I've stepped away will they start working. now don't get me wrong, the IDLE action that you have put in does this but it's a bit clunky to implement as from what I've found from my testing is that you need to have the action in between every other line of coding that performs an action. What I am hoping for is that instead of this being a line of code in the macro (or also having this and), for it to be instead a option in MMM settings that works during the entire macro running. for instance like a screen saver that turns on when the PC is idle, this could possibly be the same way. you run you macro but you have an option turned on that says the macro is allowed to run when the PC has been IDLE for XX minutes and then like a screen saver when you come back to your PC and start using it, it pauses were it was at (like how the current IDLE action works) waiting and automatically continues when the PC becomes IDLE again. here are some examples of my testing.
STOP Test 1
STOP test 2
CONTINUE Test 1
CONTINUE Test 2
Cheers for hearing me out. Zeak.
|
|
|
Post by Steve on Apr 7, 2020 3:25:57 GMT
Ok so when your not active (when the computer is IDLE) you want your macro's to run.
I think this will work:
* | IDLE_CHECK 1 | IF | IDLE | 2 | IS TRUE | GOTO MACRO LINE | RUN_MACRO | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | IDLE_CHECK * | RUN_MACRO 2 | RUN ACTION | INTEGER::%random_1-5% 3 | RUN ACTION | STRING::Hello from main macro %date% 4 | RUN ACTION | STRING1::%time% 5 | RUN ACTION | MESSAGE PROMPT | %string%::%string1%::%integer% 6 | RUN ACTION | GOTO MACRO LINE | IDLE_CHECK
Line 1 - if the computer is IDLE (no mouse movement or no keyboard keypress) for 2 seconds (of course make this longer) then GOTO the RUN_MACRO function. ELSE if the computer is not idle then go back to IDLE_CHECK.
Line 2-5 - the RUN_MACRO function
Line 6 - optionally return back to IDLE_CHECK
|
|
|
Post by zeak on Apr 7, 2020 21:43:52 GMT
Ok so when your not active (when the computer is IDLE) you want your macro's to run. I think this will work: * | IDLE_CHECK 1 | IF | IDLE | 2 | IS TRUE | GOTO MACRO LINE | RUN_MACRO | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | IDLE_CHECK * | RUN_MACRO 2 | RUN ACTION | INTEGER::%random_1-5% 3 | RUN ACTION | STRING::Hello from main macro %date% 4 | RUN ACTION | STRING1::%time% 5 | RUN ACTION | MESSAGE PROMPT | %string%::%string1%::%integer% 6 | RUN ACTION | GOTO MACRO LINE | IDLE_CHECK Line 1 - if the computer is IDLE (no mouse movement or no keyboard keypress) for 2 seconds (of course make this longer) then GOTO the RUN_MACRO function. ELSE if the computer is not idle then go back to IDLE_CHECK. Line 2-5 - the RUN_MACRO function Line 6 - optionally return back to IDLE_CHECK Yes that is the same as what I did in my example but the problem with that is, what if the PC becomes no longer idle during the actions, I would have to wait for all the actions to finish. or put the IF | IDLE in between every action line. That is why I was asking if it could be a setting and not an IF | IDLE or have both. that way you would not need a macro line to ask the question and the macro can wait/pause prior to any line.
|
|
|
Post by Steve on Apr 7, 2020 22:46:22 GMT
Right i think i understand.
You only want to run a macro when PC is idle. You also want the macro to stop running when the PC is NOT idle.
Ok - the problem here is how we measure IDLE in MMM. Its like this:
- IDLE is called from an IF IDLE condition and works by creating a separate thread that utilizes the same internal functions that pressing the 'macro record' button does. It looks for calls made by the the user to the mouse or keyboard (these calls are physically made by the person - like a hand moving on a mouse and clicking a keyboard). If if detects a call by the user, the result is NOT IDLE.
- Unfortunately IDLE can't be when the screen saver is triggered. For this to work, I think you mentioned this in a previous post, we would need to catch the hook for the screen saver. I don't know how to do this in code and I assume it could require the app to run as administrator to pick up the system calls. So this is out, unless you have the code for this tested and ready?
- Mini mouse macro can't make calls to the OS after the screen saver has launched. MMM needs an active desktop for it to work because it relies on calls to part of the framework that are only 'alive' when the screen is active. This is why jobs scheduled within task manager for MMM only work when people are logged in the screen is up.
Effectively you need a something like the IF IDLE condition running in the background constantly on a separate macro. When this detects an IDLE event it tells your main macro to continue. When it detects a NON IDLE event it tells your main macro to pause. This might actually work....
I'll give it a quick go and get back to you.
|
|
|
Post by Steve on Apr 8, 2020 0:49:01 GMT
Ok so i've got it working using two MMM instances. The fist instance (MASTER) checks for IDLE and drives the second instance. The second instance (SLAVE) takes start/pause instructions from the first. I use the inbuilt macro terminal (https://www.turnssoft.com/terminal.html) with MMM automating it, to send play/pause to the second macro. Its a little complicate and requires binding a connection using tcp sockets on the localhost to use a communication channel between the two running macro's. The building and binding a socket is done using the mmm terminal and the 'connect set' commands. Like in the attached pic below. These are the instuctions: On the slave 1. Open the terminal 2. type: connect set localip 127.0.0.1 connect set remoteip 127.0.0.1 connect set localport 41414 connect set remoteport 41415 connect start On the Master 1. Open the terminal 2. type: connect set localip 127.0.0.1 connect set remoteip 127.0.0.1 connect set localport 41415 connect set remoteport 41414 connect set send hello from master From the slave terminal you should see the text 'hello from master'. this indicates a successful connection. Close the slave terminal - leave the master terminal open. We need the master terminal window for the 'SELECT WINDOW BY NAME' condition on the master.mmmacro play. Start the slave.mmmacro play and then pause it. Then start the master.mmmacro play. When idle is detected - it will start the slave play. When idle is NOT detected - it will pause the slave play. MASTER.mmmacro* | VARIABLES 1 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::FALSE 2 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN2%::FALSE * | . * | #################### * | IDLE_CHECK * | #################### 3 | IF | IDLE | 2 | IS TRUE | GOTO MACRO LINE | RUN_MACRO | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | PAUSE_MACRO * | . * | #################### * | RUN_MACRO * | #################### 4 | IF | BOOLEAN VARIABLE | %BOOLEAN% | IS TRUE | GOTO MACRO LINE | IDLE_CHECK 5 | RUN ACTION | SELECT WINDOW BY NAME | Terminal - BETA 6 | X | X | 350 | Keypress connect send macro play start 7 | X | X | 300 | Keypress ENTER 8 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::TRUE 9 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN2%::FALSE 10 | RUN ACTION | GOTO MACRO LINE | IDLE_CHECK * | . * | #################### * | PAUSE_MACRO * | #################### 11 | IF | BOOLEAN VARIABLE | %BOOLEAN2% | IS TRUE | GOTO MACRO LINE | IDLE_CHECK 12 | RUN ACTION | SELECT WINDOW BY NAME | Terminal - BETA 13 | X | X | 350 | Keypress connect send macro play pause 14 | X | X | 300 | Keypress ENTER 15 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::FALSE 16 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN2%::TRUE 17 | RUN ACTION | GOTO MACRO LINE | IDLE_CHECK SLAVE.mmmacro1 | IF | FILE | D:\Macro\OUTPUT\output.txt | EXIST | DELETE FILE | D:\Macro\OUTPUT\output.txt * | start 2 | RUN ACTION | OUTPUT TO FILE | D:\Macro\OUTPUT\output.txt::APPEND_NEWLINE::%time% - - %random% 3 | RUN ACTION | WAIT SECONDS | 2 4 | RUN ACTION | GOTO MACRO LINE | start Here is what is should look like: minimousemacro.com/pic/forum/minimousemacro_connecttomacro.gif
|
|
|
Post by zeak on Apr 9, 2020 5:44:04 GMT
Ok so i've got it working using two MMM instances. The fist instance (MASTER) checks for IDLE and drives the second instance. The second instance (SLAVE) takes start/pause instructions from the first. I use the inbuilt macro terminal (https://www.turnssoft.com/terminal.html) with MMM automating it, to send play/pause to the second macro. Its a little complicate and requires binding a connection using tcp sockets on the localhost to use a communication channel between the two running macro's. The building and binding a socket is done using the mmm terminal and the 'connect set' commands. Like in the attached pic below. This could work but it is time consuming to setup and I was wanting to do this everyday, I might have to make a macro to automatically set it up for me. Wish that this action of IF IDLE could be running all the time in the background of just one macro.
|
|
|
Post by zeak on May 19, 2020 21:39:19 GMT
Hi Steve I think I finally found what I've been trying to ask you to do and I happen to find it when trying to set up your example to be automatically done in the morning when I start work. I was trying to use task manager to complete all the parts you mentioned using a vb script. Ignore the red rectangle, what I want to focus on is the Idle part. I was hoping something like all the options under Idle and possibly all the options under Power could be added into the settings for MMM.
|
|
|
Post by Steve on May 20, 2020 6:57:01 GMT
zeak yes thanks for that. Its a tricky one and to be honest I'm not sure how to get it done. I'll have to do a fair bit of research on it and I'm quite flat out. I've got a big update coming, hopefully June/July, with a few new features I'm trying to nut out. Most notably remote functionality with the ability to call and monitor remote MMM tasks across the network. I'm pretty keen to get that out. Also, I've got some new string functions to add in and I'm looking into user created functions. Functions is a big one too. The ability to define custom functions within the MMM code is huge. Functions that process a large body of work and return values is a big win for the user base. This is going to take some time to get out though. I'll be looking for some testing if your keen to give that a go again? The IDLE additions, yeah i'm really on the fence about. Integrating it with MMM is difficult at the moment. If you could research into it, get some information on the code that's needed or write some up that demo's picking up the hook needed to tap into the windows idle/sleep/wake functions (or whatever they may be) that would be really cool.
|
|