Jump to content
Macro Express Forums

# rberq

Members

701

29

1. ## HEX Variables

Sixteen IF statements in all, to place a displayable text character into a text variable: If Variable %N1% = 0 Variable Set String %T10% "0" End If If Variable %N1% = 1 Variable Set String %T10% "1" End If .... If Variable %N1% = 10 Variable Set String %T10% "A" End If .... If Variable %N1% = 15 Variable Set String %T10% "F" End If
2. ## HEX Variables

Yes, integer arithmetic would give a whole number quotient. To isolate the remainder you could multiply the quotient by 16 and subtract the product from the original random number -- again entirely with integer arithmetic. Or as you say, just generate two separate random numbers, one for each character you want to end up with. I tried "Variable Set to ASCII Char" and it did not product a useful result. I was assuming that you want displayable characters -- for example, random number 26 is hexadecimal x'1A', so you want two displayable characters, '1' and 'A'. You are right about having to work hard only for generating characters 'A' through 'F'. The test macro below will properly produce a text string for value '9' but will NOT produce an 'E' for value 14. Run it and see. Variable Set Integer %N1% to 9 Variable Modify Integer: Convert %N1% to text string %T1% Variable Set Integer %N2% to 14 Variable Modify Integer: Convert %N2% to text string %T2% Text Box Display: %T1% %T2% But you don't know ahead of time whether you will be generating a numeric character or a letter character. The series of IF statements I suggested will handle both cases.
3. ## HEX Variables

A hex value expressed by two characters can be anything from x'00' to x'FF', which is decimal 0 to 255. So you could (1) Generate a random integer from 0 to 255. (2) Using Macro Express's integer arithmetic, divide the generated integer by 16, ignoring the remainder, and you will have a quotient from 0 to 15 representing the leftmost hex character. (3) The remainder from the above division will likewise be an integer from 0 to 15 repesenting the rightmost hex character. (4) Use a simple lookup array, or a series of IF statements, to convert the two integers to letters/numbers. IF QUOTIENT = 0 THEN LEFTLETTER = '0' IF QUOTIENT = 1 THEN LEFTLETTER = '1' ... ... IF QUOTIENT = 14 THEN LEFTLETTER = 'E' IF QUOTIENT = 15 THEN LEFTLETTER = 'F' ... ... IF REMAINDER = 0 THEN RIGHTLETTER = '0' IF REMAINDER = 1 THEN RIGHTLETTER = '1' etc. There is probably a more elegant way to do it, but I'm into brute force this morning.
4. ## Macro stops at login

On a couple occasions I set up ME on an always-active network server to do off-hours functions like this. Depends whether you have such servers available, whether you have permission to use them, and so on. You might not even need ME if you can use the Windows scheduler on the server to start the job.
5. ## Launch separate Powershell script silently

From Samrae's example -- would this work, to launch it directly from ME without a batch file? Program Launch: "Powershell.exe"
6. ## Tips for beginners

Go methodically through the commands and use them one by one in very simple macros. Use the Help system. When you do something for learning purposes, make frequent use of Text Box Display so you can see the result. Sounds tedious and probably is, but I should have done it early on. I still occasionally find command options that I have never used. A couple simple examples: // Variable Set String %T1% " ABCD " Variable Set String %T2% " EFGH " Variable Modify String: Append %T2% to %T1% Text Box Display: T1 result is ***%T1%*** Variable Modify String: Trim %T1% Text Box Display: T1 result is ***%T1%*** // Variable Set String %T1% "000123" Text Box Display: T1 result is %T1% Variable Modify String: Convert %T1% to integer %N1% Text Box Display: N1 result is %N1% Variable Modify Integer: Convert %N1% to text string %T1% Text Box Display: T1 result is %T1% //
7. ## Run a macro every minute but don't run it if it's already running

Didn't you already ask the first question in another thread? I believe the answer was, the scheduled macro will not run again if the previous instance is still running. I would recommend you do some testing to make sure that is true. For your related question, this should work: 1) When your macro starts, create a temp file -- let's call it marker.txt. 2) Start the batch script. 3) Use a Repeat loop to check over and over for the existence of marker.txt. Do not exit from the Repeat loop as long as the file exists. Somewhere inside the Repeat loop, include a few seconds delay -- this is just so looping won't chew up so much processor time. 4) As the last step in your batch script, delete marker.txt. 5) Next time the macro goes through the Repeat loop, the file will no longer exist, so exit from the Repeat and the macro can continue with whatever else it needs to do.
8. ## Program macro at random interval

This is what I think Cory is saying, simplified just a little: :BEGIN (generate a random number between 60 and 120) Repeat until RAND > 60 Variable Set Integer (random) RAND (max 120) Repeat end Repeat until RAND = 0 Wait for time to elapse (1 minute) Subtract 1 from RAND Repeat end Do whatever stuff the macro is intended for GOTO :BEGIN This will ALWAYS wait between one and two hours, though you said you want it USUALLY to wait that long. You can expand the random number range if desired to get some times less than an hour or more than two hours.
9. ## Beginner's question

The Macro Express Help feature is good for looking up something like this. I found the following note: Note 1: If a macro is scheduled to run every 1 second and the macro takes 5 seconds to execute, then this function will not operate properly. A bit ambiguous. I tested with a very simple macro scheduled to run every 15 seconds and display a text box that went away only when I clicked OK. If I did not click to allow the macro to end, a second text box did not appear no matter how long I waited. Don't know if the second (or third or fourth etc.) instance was queued, or was running but frozen, or what. You could set up a test macro and experiment with various timings to get a better feel.
10. ## Program macro at random interval

Take a look at Cory's suggestion, though -- his is simpler to program. Execute the macro only once, so it does its thing then idles for the random time before doing its principle function again, generating a new random interval, and so on. You don't even have to intervene to start it running, just schedule it to run when Macro Express is started. My thinking is kind of stuck at the Macro Express 3 level which doesn't allow for more than one macro to run at a time -- therefore I missed the option of having your macro run only once for a duration of many hours or even days. With ME3 if the macro runs continuously, then no other macros can run. With ME Pro a long-running macro doesn't block other macros from running.
11. ## Program macro at random interval

Schedule your macro (with Macro Express) to run every 1 minute. Durin each run of the macro: If "timer file" does not exist, generate a random number between 60 and 120 (because you want between 1 and 2 hours). Store the number in a text file ("timer file"). If "timer file" DOES exist, read it, decrement the number by 1, and check whether the number has reached zero. If not, store the new (decremented) number in "timer file" and exit from the macro without doing anything else. If time HAS reached zero, delete "timer file" and do whatever other stuff the macro is intended for. Because you have deleted "timer file", next time the macro runs 1 minute later the whole scheduling process will begin again. If you have Macro Express run your macro every 5 minutes, instead of every 1 minutes, then the decrement described above would be 5, not 1. And so on -- since you have a fairly broad time range for your random runs, it is not really necessary to check "timer file" as often as every minute. Somebody will probably embarrass me with a much simpler method, but that's all I have come up with for now.
12. ## Wait for Text Playback - does it work?

Thanks for the clarification. Perhaps you could add a few lines to the Macro Express HELP topic to explain this. I admit it seems intuitively obvious what the Wait should do, but obvious isn't quite good enough for some of us literal-minded OCD folks.
13. ## Wait for Text Playback - does it work?

I set up a test macro to copy a large block of text, switch into Notepad or Word, then type the text. After typing it displays the begin and end time for typing. I could detect no difference with and without the Wait Text Playback. So, I don't know what the command is good for, either. I wonder if it had some use in much earlier versions of Windows. // // Variable Set Integer %N1% from Current Minute Variable Set Integer %N2% from Current Second Text Type: <CTRLD>a<CTRLU> Delay 300 Milliseconds Macro Run: 0_Generic_Copy_To_Clipboard Variable Set String %T1% from Clipboard Delay 300 Milliseconds Text Type: <ALTD><TAB><ALTU> Delay 500 Milliseconds Text Type: %T1% Wait Text Playback Variable Set Integer %N3% from Current Minute Variable Set Integer %N4% from Current Second Text Box Display: Begin / End Times // //
14. ## Gmail / Googlemail settings

Are you saying you have it working with Macro Express? What settings?
15. ## Gmail / Googlemail settings

Here are a couple links I found through Google. I tinkered a bit but didn’t get it to work yet. Basically a script file and a batch file to execute the script. If you can get it to work then you can run (launch) the batch file from Macro Express. Script “testgmail.ps1”: \$EmailFrom = “myemailname@gmail.com” \$EmailTo = “addressee@yahoo.com” \$Subject = “test subject line” \$Body = “test text” \$SMTPServer = “smtp.gmail.com” \$SMTPClient = New-Object Net.Mail.SmtpClient(\$SmtpServer, 587) \$SMTPClient.EnableSsl = \$true \$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“myemailname”, “myPasswrd”); \$SMTPClient.Send(\$EmailFrom, \$EmailTo, \$Subject, \$Body) pause Batch file: cd\windows\system32\WindowsPowerShell\v1.0 powershell c:\temp\testgmail.ps1 pause https://superuser.com/questions/80255/send-email-via-gmail-from-command-prompt https://www.howtogeek.com/120011/stupid-geek-tricks-how-to-send-email-from-the-command-line-in-windows-without-extra-software/ Edit: edited this post to give the script file name the extension "ps1" instead of "txt".
16. ## Gmail / Googlemail settings

I tried your settings with Macro Express version 3 and got the same error you did. I changed the port to 25 and got the "success" message from two send commands, and the ME email log showed success, but neither recipient got the mail, and my gmail account does not show the messages in its Sent folder. Sorry, no help from me. But please post again if you figure it out because it would be handy to have it working.
17. ## Is there an alternative way to repeat keystrokes

Very clever. So when you have extracted an item from the list, on the next pass you can type the item then <ARROW DOWN> to get the subsequent item, and so on???
18. ## Is there an alternative way to repeat keystrokes

If you have to do it on a regular basis, experiment with Page Down followed by Arrow Down -- loop within loop. It might work if Page Down consistently advances by a predictable number of rows. (What the heck, you have solved your problem, but aesthetics demands an elegant solution instead of brute force.)
19. ## Is there an alternative way to repeat keystrokes

Make peace. I don't understand why this is a problem. If you want fewer passes through the Repeat loop -- lower processing overhead -- do something like Variable Modify Integer: %x% = %x% / 10 Repeat with Variable: Repeat %x% times Text Type: <ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN> End Repeat Or put the loop in a separate macro that you call (run) from your main macro. It will at least LOOK a little cleaner.
20. ## Problem pasting to PaintShop Pro

If the Launch command is freezing ME, you could try launching PaintShop Pro indirectly. Write a simple batch file "start_paintshop.bat" which consists of two lines: start c:\path\paintshoppro.exe exit Then in your macro, launch the batch file: ProgramLaunch c:\path\start_paintshop.bat You might need a brief pause after the launch for it to complete, or a short loop to mark time until PSP is running. Might work.
21. ## "If Variable Contains" with multiple integers

Can I, using one "if variable" statement, check to see if my generic variable has any ONE of those numbers and to return the message as a result? The short answer is no, you can’t. The longer answer is, take a look at SWITCH / CASE in the Help section. Still a lot of lines to code, but it’s more readable than a bunch of IF / OR / IF / OR … commands. How about dividing your result integer by 12, then checking the remainder? You would still need an IF or CASE for each month, but not half a dozen or so for each month. As far as I know, Macro Express does not just give you the remainder when you divide integers, so you will have to divide by 12 then multiply the result by 12 and subtract from the original. Or code a loop to subtract 12 over and over until the result is less than 12. If the data from the user is text you will have to convert to integer (Variable Modify Text) before doing the math. Probably easiest of all: convert text string to decimal, divide by 12, and check the decimal portion of the quotient to determine the month -- 0.08 is January, 0.16 February, 0.25 March, and so on.
22. ## MEP 4.7.1.1 Tethering Multiple Choice Menu to Program

I have never worked with macros on two monitors, but I will take a stab at your problem. Maybe someone else will step up and give a better answer. 1) You can use command "Variable Set Integer" to get location/coordinates of the current window. So if the relevant application's window has focus you can check which monitor it is on. You may be able to get coordinates also with the "Get Control" command even if the window doesn't currently have focus -- I'm not sure of that. 2) When you code a menu in Macro Express, you can tell it the coordinates at which to display the menu, so hopefully you can pick spots that are reasonable on each monitor even if people use different resolutions. (You can get their screen resolutions also by the "Variable Set Integer" command, if you need to.) I don't think you can change, on the fly, the location to display the menu. But you could code the same menu two times in the macro, at different display locations, and say something like IF WINDOW-TOP-LEFT-CORNER LESS THAN 1920 DISPLAY LEFT-MENU ELSE DISPLAY RIGHT-MENU END IF I know you said you would like to tether the menu to a program, but the best I can come up with is to check window name(s); and code some logic to position the menu because I don't think it can be automatically tethered. Good luck, feel free to ask more questions, and let us know how it works out.
23. ## Announcement: Macro Express v 3.11a

www.macros.com/download.htm You should be able to apply the same license code you used for your initial installation and for your last upgrade.
24. ## Saving to Excel in background

Automated. The macro scans the clipboard text for identifiers, then finds a value after the third subsequent dollar sign for each identifier.
25. ## Saving to Excel in background

I have a macro to do a similar thing, but on a smaller scale -- a dozen or so values rather than your 50. Rather than use a text file, I copy the whole screen to the clipboard, extract the fields I want into ME variables, switch once to Excel, Ctrl-Home to the first cell, and type arrow keys to get to the desired cells to type the variables. It is very fast and reliable, but it doesn't do Excel in the background like you would prefer. The logic to make sure there are no missing fields is in the extraction macro.
×

• Leaderboard