Jump to content
Macro Express Forums

The Problem For Random Time


ymanav

Recommended Posts

First of all , i am really sorry for my terrible english..

 

I created a macro which works brilliant for me :)

But i want my macro to start at random times..

 

For Example :

I clicked and activated it , it finished it work , it will start 5 minutes later

It will finish the work again and it will start 6 minutes later , not five..

The time must always different..

I will activate it , and it repats its work with random time differences..

 

I hope , I did explainep my situation and problem

And You understood it..

 

Work + Random Time 1 + Work Again + Random Time + Work + Random Time..

Link to comment
Share on other sites

First of all , i am really sorry for my terrible english..

 

I created a macro which works brilliant for me :)

But i want my macro to start at random times..

 

For Example :

I clicked and activated it , it finished it work , it will start 5 minutes later

It will finish the work again and it will start 6 minutes later , not five..

The time must always different..

I will activate it , and it repats its work with random time differences..

 

I hope , I did explainep my situation and problem

And You understood it..

 

Work + Random Time 1 + Work Again + Random Time + Work + Random Time..

 

I suggest you take a look at Repeat start with Variable and Variable set integer/Set random value.

Link to comment
Share on other sites

  • 4 weeks later...

What blopib suggested is probably the best option if you don't need to be running other macros in the mean time.

 

If you do, then your best bet is going to be to set a random integer (based on maximum and minimum number

of minutes between macro runs) and then attaching code to the end of your macro that will open the Macro Express

Editor, Open the macro you want to edit, change the schedule from the Properties tab of the Editor, and then save it.

 

I don't believe there is any way to change the properties of a macro without opening the Editor (if there is, I definitely

want to know about it!).

 

This part of your macro will end up looking something like this:

 

Get Mouse Position Screen: %N1%, %N2%
Move Mouse to Tray Icon: "Macro Express"
Mouse Left Button Click
Mouse Move Screen %N1%, %N2%
Variable Set Integer %N1% with a Random Number
Wait For Window Title: "Macro Express - Macro Explorer"
Text Type: <ALT>mh
Wait For Window Title: "Find"
Text Type: <NAME OF MACRO HERE>
Text Type: <ENTER><ESC><ENTER>
Wait For Window Title: "Scripting Editor"
Text Type: <SHIFT><TAB><ARROW RIGHT>
Repeat Start (Repeat 7 times)
 Text Type: <TAB>
Repeat End
Text Type: <ENTER>
Wait For Window Title: "Set Schedule"
Text Type: <TAB><TAB>
Text Type: %N1%
Text Type: <TAB><TAB>
Text Type: <ENTER>
Text Type: <CONTROL>s
Restart Macro Express

 

<MOUSEPOS:T:01:02><MOVETOTRAY:Macro ExpressF:F:0:0><LCLK><MMS2:1N,2N><IVAR2:01:06:10><WAITWIN2:000010:000000:Macro Express - Macro Explorer><TEXTTYPE:<ALT>mh><WAITWIN2:000010:000000:Find><TEXTTYPE:<NAME OF MACRO HERE>><TEXTTYPE:<ENTER><ESC><ENTER>><WAITWIN2:000010:000000:Scripting Editor><TEXTTYPE:<SHIFT><TAB><ARROW RIGHT>><REP3:01:000001:000001:00007:0:01:><TEXTTYPE:<TAB>><ENDREP><TEXTTYPE:<ENTER>><WAITWIN2:000010:000000:Set Schedule><TEXTTYPE:<TAB><TAB>><TEXTTYPE:%N1%><TEXTTYPE:<TAB><TAB>><TEXTTYPE:<ENTER>><TEXTTYPE:<CONTROL>s><RESTARTMACEXP:FT>

Link to comment
Share on other sites

Scasper,

 

I was interested in your macro approach which uses a command I've never used myself before, Move Mouse to Tray Icon: "Macro Express". But I'm getting very erratic results with it. I had it working inconsistently for a while earlier, but now I've tried a dozen times in succession and get 'The system tray icon, "Macro Express", could not be located' every time. After that I noticed that r-clicking the MX system tray icon no longer displayed a menu. So I closed MX via XP Task Manager and re-started it. Now I have the r-click menu back, but the macro still fails with that message. Also, while the message is displayed, I note that the system tray icon has disappeared and a minimised tab for tne MX macro has appeared in my taskbar. When I abort the macro, the sys tray icon returns.

 

Any ideas on what might be happening here please?

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

I think you will need to make a few modifications to your macro to get reliable operation. Here is my version:

 

[color="#0000FF"]// This macro will run at random intervals, set by N1
Keystroke Speed: 10 Milliseconds
Mouse Speed: 1 Milliseconds
// This is where you would insert commands for your macro
// My example is the following trivial one
// Activate NotePad (already running)
Activate Window: "Untitled - Notepad"
Wait For Window Title: "Untitled - Notepad"
Text Box Display: Your macro is running
// Record current position of mouse, in case it's important to return it
Get Mouse Position Screen: %N1%, %N2%
Delay 100 Milliseconds
// Open MX Editor by clicking its System Tray icon
Move Mouse to Tray Icon: "Macro Express"
Delay 100 Milliseconds
Mouse Left Button Click
Delay 100 Milliseconds
// Return mouse
Mouse Move Screen %N1%, %N2%
// Get a random number between 1 and 100 (choose your own) which will be the interval before next run
Variable Set Integer %N1% with a Random Number
Wait For Window Title: "Macro Express - Macro Explorer"
// Ensure Macro Explorer is displaying ALL macros (not just the last category you displayed).
Text Type: <HOME><TAB>
// Deselect the top macro automatically selected
// Otherwise that one, which is quite likely to be the one you want to find, especially during experiments,
// will be missed by the Find - which apparently ignores the starting position!
// The only way I can think of to do this is to click the top entry, based on its position
// To keep it simple I've assumed MX will be consistently sized and positioned the way I happen to have it at present
// It should be straightforward to add code to ensure this before this part of the macro was run
Mouse Move Screen 1314, 120
Text Type: <CTRLD>
Delay 100 Milliseconds
Mouse Left Button Click
Delay 200 Milliseconds
Text Type: <CTRLU>
Delay 200 Milliseconds
Text Type: <ALT>mh
Delay 200 Milliseconds
Wait For Window Title: "Find"
Text Type: Run at random intervals
Delay 100 Milliseconds
// Open Scripting Editor for 'Run at random intervals'
Text Type: <ENTER><ESC><ENTER>
Wait For Window Title: "Scripting Editor"
// Open its Properties
Text Type: <SHIFT><TAB><ARROW RIGHT>
Delay 100 Milliseconds
Text Type: <ENTER>
Delay 100 Milliseconds
// Tab 9 times to reach te Schedule button
// Note: this should already be checked
Text Type: <TAB><TAB><TAB><TAB><TAB><TAB><TAB><TAB><TAB>
// Open the Schedule dialog
// 'Other' and 'Play Macro Indefinitely' should already be specified as checked.
Text Type: <ENTER>
Delay 100 Milliseconds
Wait For Window Title: "Set Schedule"
// Navigate to the 'Every' box and enter the random number of minutes
Text Type: <TAB><TAB>
Delay 100 Milliseconds
Text Type: %N1%
Delay 100 Milliseconds
// Navigate to the 'OK' box and close
Text Type: <TAB><TAB>
Delay 100 Milliseconds
Text Type: <ENTER>
Delay 100 Milliseconds
// Save the macro with its new setting, so that it will restart in N1 minutes
Text Type: <CONTROL>s
Delay 100 Milliseconds
Restart Macro Express[/color]

 

And here is the code

 

 

<REM2:This macro will run at random intervals, set by N1><SPKEY:0010><SPMSE:00001><REM2:This is where you would insert commands for your macro><REM2:My example is the following trivial one><REM2:Activate NotePad (already running)><ACTIVATE2:Untitled - Notepad><WAITWIN2:000010:000000:Untitled - Notepad><TBOX4:T:4:CenterCenter000278000200:005:Your macro is runningDid you take a break since this message last time?
><REM2:Record current position of mouse, in case it's important to return it><MOUSEPOS:T:01:02><MSD:100><REM2:Open MX Editor by clicking its System Tray icon><MOVETOTRAY:Macro ExpressT:F:0:0><MSD:100><LCLK><MSD:100><REM2:Return mouse><MMS2:1N,2N><REM2:Get a random number between 1 and 100 (choose your own) which will be the interval before next run><IVAR2:01:06:3><WAITWIN2:000010:000000:Macro Express - Macro Explorer><REM2:Ensure Macro Explorer is displaying ALL macros (not just the last category you displayed).><TEXTTYPE:<HOME><TAB>><REM2:Deselect the top macro automatically selected><REM2:Otherwise that one, which is quite likely to be the one you want to find, especially during experiments,><REM2:will be missed by the Find - which apparently ignores the starting position!><REM2:The only way I can think of to do this is to click the top entry, based on its position><REM2:To keep it simple I've assumed MX will be consistently sized and positioned the way I happen to have it at present><REM2:It should be straightforward to add code to ensure this before this part of the macro was run><MMS2:1314,120><TEXTTYPE:<CTRLD>><MSD:100><LCLK><MSD:200><TEXTTYPE:<CTRLU>><MSD:200><TEXTTYPE:<ALT>mh><MSD:200><WAITWIN2:000010:000000:Find><TEXTTYPE:Run at random intervals><MSD:100><REM2:Open Scripting Editor for 'Run at random intervals'><TEXTTYPE:<ENTER><ESC><ENTER>><WAITWIN2:000010:000000:Scripting Editor><REM2:Open its Properties><TEXTTYPE:<SHIFT><TAB><ARROW RIGHT>><MSD:100><TEXTTYPE:<ENTER>><MSD:100><REM2:Tab 9 times to reach te Schedule button><REM2:Note: this should already be checked><TEXTTYPE:<TAB><TAB><TAB><TAB><TAB><TAB><TAB><TAB><TAB>><REM2:Open the Schedule dialog><REM2:'Other' and 'Play Macro Indefinitely' should already be specified as checked.><TEXTTYPE:<ENTER>><MSD:100><WAITWIN2:000010:000000:Set Schedule><REM2:Navigate to the 'Every' box and enter the random number of minutes><TEXTTYPE:<TAB><TAB>><MSD:100><TEXTTYPE:%N1%><MSD:100><REM2:Navigate to the 'OK' box and close><TEXTTYPE:<TAB><TAB>><MSD:100><TEXTTYPE:<ENTER>><MSD:100><REM2:Save the macro with its new setting, so that it will restart in N1 minutes><TEXTTYPE:<CONTROL>s><MSD:100><RESTARTMACEXP:FT>

 

ymnav:

Note that during testing I set N1 to a max of 3 minutes, not 100, so remember to change it to whatever you want.

 

Also, while I was composing this, the macro ran OK automatically a few times but just now gave an error because I had not excluded the possibility of a zero interval. So add the following directly after the random variable command:

// Ensure N1 is never 0

Variable Modify Integer: %N1% = %N1% + 1

 

 

Scasper: Re my previous post about the tray icon not working here, it all now seems OK. I think it may have been because of the Scroll Lock key being on, although that might be coincidence. Thanks a bunch for introducing me to the Move Mouse to Tray Icon command, which should prove very handy! ;)

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Hey Terrypin,

 

I haven't checked out your version of the code yet, but my first thought on the erratic success of the Move Mouse to

Tray Icon might be related to the tray itself. My first suggestion, assuming you hadn't already done so, would

be to right click on the task bar, select properties, access the "Customize" Button, and then make sure Macro Express

is set to "Always Show".

 

Of course, if it is already set to Always Show, then this won't fix anything. I'll take a look at your code in a little bit

and see if I can't incorporate any of your suggestions into my own personal knowledge base :)

 

Another option, that might be more consistently useful, would be to simply have the macro launch program, but since

the program is already running I'm not sure if that would work. I'll have to look into it (who knows, maybe that's what

your code will show me!)

Link to comment
Share on other sites

Scasper,

 

Thanks, but I don't have that option to hide inactive icons checked. (Maybe I should - the current inventory of 18 icons plus clock take up a fair bit of room, although on this 24" widescreen it's not too bad.) So that wasn't the cause. Nor it seems was it the Scroll Lock button. I've set that on again but the macro runs fine. (I have a hotkey assigned to it as well as Schedule for convenience.) So, remains a mystery, but working consistently now.

 

Once set up, that macro is all too easy to forget! With N1 still set to the 1-4 minute range, I had it popping up at all sorts of odd times. Of course, if I happened to be in the middle of playing with another macro or whatever, it would then usually fail. Now duly disabled, until maybe I set it up for something useful. That downside will always remain, of course. So in practice I'd probably consider using XP's Scheduled Tasks facility if the application allowed. At least while I remain fairly active with MX.

 

Thanks again for giving me the lead on this.

:)

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Always happy to help whenever I can. I find I'm looking for it myself far more often than I'm

able to provide it, unfortunatly.

 

Speaking of which, as I looked through your version of the macro I saw something I hadn't noticed:

the Find function ignores the macro currently highlighted (essentially the one you're working on). I

hadn't realized that. I had better keep that in mind if I ever need one macro that re-writes another.

 

I actually built a similar macro for my mother-in-law, who hasn't a programming bone in her body, but

needs to add new macros on a fairly regular basis. I can't always be there to write them for her, so

I built a macro that creates a new macro for her using information from prompts (the ones she creates

are very simple text-type macros with shortkey activations). Fortunately, she doesn't need to edit old

macros, so the Find problem isn't an issue. The macro I built for her uses the Mouse click on tray icon,

and she hasn't ever had a problem with it. You say yours is working consistently now, so maybe the

problem will remain unsolved, but it would be nice to isolate it to take steps to prevent it with confidence.

 

I personally don't know why running a particular macro at an irregular or random schedule would be

desirable, but I wonder if it is enough of a need that our friends at Insight want to look into making it

an option under the Scheduled option.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...