Jump to content
Macro Express Forums

lemming

Members
  • Posts

    140
  • Joined

  • Last visited

Posts posted by lemming

  1. Hi you could achieve this by creating/updating an environment variable which is readable by other macros, for instance, MacroAisRunning=YES. The relevant commands are:

     

    Variable Modify String -> Save to Environment Variable

     

    Variable Set String -> Set from an Environment Variable

     

    For example if you have Macro A and Macro B, you can get Macro A to set MacroAisRunning=YES right after it is launched. Macro B can read this environment variable to check if Macro A is running. Remember to set MacroAisRunning=NO before terminating Macro A.

     

    You can also achieve this by saving macro statuses to INI files or text files, though this requires disk access.

  2. This is a known problem and it even affects scripting languages like autohotkey. The obvious workaround is to make the leftmost monitor the main. If your user is not willing to do this, another solution might be to temporarily move the window to the main monitor, perform the needed operations, then move it back to the secondary.

  3. Hi Terry, I just came across this topic. Hopefully you already have a solution.

     

    Anyway, I played around with AHK and came up with a regex one-liner to glean the data you wanted.

     

    alltext := RegExReplace( alltext, "s)\[([^\]]+)\.jpg\][^\[]*- COMMENT -.{0,2}\n" , "$1.jpg`n" )
    

     

    This regex captures the filename in between the square brackets, then it discards everything that is between .jpg and - COMMENT - (inclusive). Whatever that is left is the result you wanted. I've attached a zip with two files, an .ahk file (with comments) and a text file containing the data you posted. Both files need to be in the same folder.

    Terry data.zip

  4. Hi, you could save yourself a lot of trouble and make your script more reliable by launching an Google advanced search URL instead of trying to type in stuff. For instance, here is the direct URL to search for the word "transition" in the site that you listed.

     

    https://www.google.com/search?as_q=transition&as_qdr=all&as_sitesearch=http%3A%2F%2Fsupport2.magix.net%2Fboards%2Fmagix%2Findex.php%3Fshowforum%3D113&as_occt=any&safe=images

     

    Most of it looks like gobbledegook, but it is quite straightforward. All the stuff after /search? are search parameters and each parameter is separated by an ampersand (&). as_q= is the search word and as_sitesearch= is the domain. You could surf the links below to find out exactly what they mean, but you usually don't need to. Here's what you could do:

    1. Do a search with the Google advanced search page as you normally would.

    2. Copy the resulting URL from your web browser. It'll be a long URL.

    3. In a text editor, remove any parameters that are blank, e.g. &as_rights=

    4. The URL can now be launched by MEP, saved as a bookmark, etc. It'll take you directly to the search results without the need to type in search strings.

     

    More info:

     

    Google Search URL Parameters – Query String Anatomy

    http://www.blueglass...string-anatomy/

    Scroll down to Google “Advanced Search” URL Parameters

  5. Hi does your task involve copying data from Word or other Rich Text program? Or maybe copying from a live web page? If you then paste this formatted data into a text editor, it may lead to unexpected delays. Some editors have a "paste as plain text" option which should make things faster. Other editors like Notepad++ just discard all formatting and will automatically paste as plain text. I don't use Ultra Edit nor Boxer, so I can't comment on them

  6. I can never remember all the codes for special characters as I use them infrequently. So typing "degreess" is much quicker than looking it up or opening the character map to insert. And only 4 keystrokes more. But I concede that those who can remember all of the codes for the special characters should not write macros like this. I just use it as a crutch fro me feeble mind. Pop quiz: What's the char code for the "approximate" (≈) symbol? I win! I cheated however because all I had to do was type the key left of the "1" twice. Actually that's a lot fewer characters that the Alt method. ;)

     

    Yeah, good points. I realize too that more people are using notebooks these days instead of desktops. The alt-code sequences only work with a numeric keypad, and practically all notebooks lack them. You have to press an additional key to toggle a pseudo numeric keypad, so generating an alt-code sequence might require three hands, depending on the keyboard layout! In this case, MEP or Charmap would be useful.

  7. You can just do this with plain old DOS copy command. Assuming all the text files are in one folder and you want the final file to be in the same folder, you just need cd to the right location and type:

     

    copy *.txt mergedfile.txt

     

    You can also make use of DOS in MEP to achieve similar results - just use Program Launch with cmd.exe, which is the command-line interpreter, i.e. the Dos prompt. You don't have to include the full path for cmd.exe. You can then put these in the Program Parameters:

     

    /K copy "C:\Users\Lemming\Desktop\test\*.txt" "C:\Users\Lemming\Desktop\test\mergedfile.txt"

     

    The /K option keeps the Dos window open after the command is finished. This would also pause your script till the window is closed. If you want the window to close immediately, change /K to /C. You'll also need to specify the full path for your files.

     

     

    Has anyone written a macro for MEP to copy text from text files located in a folder and appending the text sequentially to make an independent large text file containing all the text from the other text files? The text files are from a batch run on an OCR program called Tesseract OCR 3.01 run under GUI interface called VietOCR ( PS its FREE)
  8. Hi you could have just created a symbolic link to the old directory (like an alias or shortcut), so your macros could just chug along thinking nothing has changed.

     

    The Junction utility from Sysinternals does this:

     

    http://technet.micro...s/bb896768.aspx

     

    But as Cory noted, it's not a good practice to hard-code directory paths!

     

    Update: You can also do this in Vista or Win 7 with the built-in Mklink command:

     

    http://www.maximumpc.com/article/howtos/howto_use_symbolic_links_master_vistas_file_system

  9. Hi Daniel, sorry to hear about your injury. I think it may be hard for others to imagine dealing with limited mobility and partial access to the keyboard.

     

    Macex does not seem to support the "quick-correct" feature. But anyway, you could also set up similar abbreviations in Microsoft Word - the AutoCorrect feature has been available for years.

     

    But I get where you're coming from; I used Superkey many years ago too and that "quick-correct" feature was awesome and I could make it work in any program. The only equivalent these days seems to be AutoHotkey. Since it is a rival product I won't link to it but you can always google for it. You'd want to look at its "Hotstrings" feature (needs Windows NT/2000/XP or later).

     

    -Lemming

     

    Yes..I know the ### thing will do that, but it would be much easier if an invented word would do the same thing....instead of typing ###. Via this method, it would be easy to remember and type "words" (see below) that would insert what you want by simply pressing the 3rd letter of a word 3 times. Examples follow:

     

    ackkk = acknowledged

    deaaa= Dear customer representative:

    briii = Bring all records to the meeting when you attend.

    attt = attorney-client privilege

     

    BTW..I have an overuse injury to my right hand, so reaching for the right shift key in order to type ### is literally a pain. I would imagine I could change it to aaa or some such, but that's not as efficient and memorable as the convention described above. Like I said, I can use that wp feature to get it done easily, but would like to use the same abbreviations in other apps.

     

    I did this all the time in superkey. How I wish someone would port superkey to win7. Perhaps I can get used to MEP such that I can get most of the functionality out of it I used to get out of superkey. By far, MEP is the most intuitive and complete macro program I've encountered in the last 20 years since I surrendered DOS to windows.

  10. Hi, you can launch the built-in Windows util systeminfo.exe and capture the output in a variable. However, this util can be slow because it tries to gather a lot of other info about your system. Also it only shows "System Boot Time", so you'd have to parse through a lot of other info and also perform additional calculations to determine uptime. On the plus side, systeminfo.exe is installed on every Windows PC (since Win XP I believe), and you do not have to specify its exact location since it resides in the default Windows path.

     

    An easier method would be to use the uptime.exe utility which you can get for free at http://uptimeexe.codeplex.com/

     

    It's a command-line util which does not have to be installed. Just copy it to anywhere. It runs in a split second and will report your boot time and also your uptime. I've written a script that parses the info from uptime.exe into separate variables. You can add additional logic for your purposes.

     

    -Lemming

     

    System Uptime for TsunamiZ.mex

     

    May I suggest to add a way to get system uptime? I want to make a macro that doesn't run unless a certain amount of system uptime has elapsed.

     

    BTW: I use Windows 7.

  11. GNU utilities for Win32

     

    Some ports of common GNU utilities to native Win32. In this context, native means the executables only depend on the Microsoft C-runtime (msvcrt.dll) and not an emulation layer like that provided by Cygwin tools.

     

    http://unxutils.sourceforge.net/

     

    Includes classic Unix utils for text search and manipulation with regular expressions (regex), such as grep, sed, awk. Other useful utils include wget, tail, head, sort, uniq, etc.

  12. In a related matter, I find that for many public websites, the main cause for slowdowns are ads and ad servers, not the main web server or the main content itself.

     

    I installed Adblock Plus and FlashBlock and they've significantly reduced the "slow loading" and "not loading properly" problems. If you're accessing a public site which runs ads, these two extensions could help make your scripts more reliable.

     

    http://adblockplus.org/en/

    https://addons.mozil...don/flashblock/

  13. Hi you could try Windows's built-in Runas program. It's been around since XP days, I believe. It lets you run any program under a different user account, including as Admin. More info and examples at http://ss64.com/nt/runas.html

     

    You can run it using "Activate or Launch". You should not need to specify its exact location, since it resides in \System32, which is in the default Windows path. Anyway, on my system (Win 7), the path is:

     

    C:\Windows\System32\runas.exe

     

    Hi,

    I would like to start a program as administrator. I use the "Activate or Launch" command, but I can't find a option to "start program as administrator". I'm wrong? Do I have to use another function?

    Thanks & Best regards from Vienna,

    Alexander

  14. Terry and Paul, thanks for your help! I'll try Paul's fix.

     

    I've attached a sample script, which fails as described.

     

    It's a 1-line script, with just a Window Activate command, with Window Title set to "Microsoft word", and all other fields left as defaulted.

     

    More info on my symptom:

     

    -- by "Activate" here I mean both "Activate or Launch" and "Window Activate"; they both get the symptom when activating Word.

     

    -- To clarify: the symptom I see is that the macro just takes focus from the original window, and leaves me with no window having focus. I.e. on my XP box, the active window has a blue bar and keystrokes go to that app, and the inactive windows have grey top bars and don't respond to keystrokes. When the macro runs, all windows including the top window become inactive and stay that way until I manually activate a window.

     

    -- Activate will elicit this symptom and be unusable for hours or days at a time. Then for some reason, activate will work for an hour or so, and then the cycle repeats.

     

    -- I have a hunch the symptom is related to having MS Outlook running. However, I can't avoid Outlook: most of my clients use it and so must I.

     

     

    Follow-on question for Terry: What workaround do you use in place of Activate? I don't see how delays would help- remember, the symptom I see is that the macro just takes focus from the original window, and leaves me with no window having focus. I could wait a second or an hour; no window ever takes focus.

     

    Follow-on question for other readers: has anyone had Activate work reliably-- e.g. for years-- with Word 2003/2007 on XP?

     

    Thanks-- Robert

     

    Hi I usually don't face problems in activating Word, but I faced a similar situation on one particular computer some years back. I believe it was Word 2003 on XP.

     

    My workaround was to launch Word again (i.e. Program Launch, not Activate). This results in Word launching a new instance, with the side effect of Word being activated. If you close that new instance (Window Close), you should be left with whatever Word document that was already open, and it will be in the foreground. Kludgy, but it worked for me.

     

    The Word executable is usually WINWORD.EXE. The path will vary. You can also launch Word with the /n switch (no document open), but you'd still need to close the new instance.

  15. Generally people have lists of things and they put it in excel just because it’s a handy way you have a grid.

    [...]

     

    Yea, I've seen this quite often. Usually, they're just storing data with no calculations or formulas. Sometimes there aren't even numbers. On their PCs, they almost always have Word too, so I would suggest to them to use Word's tables and its table wizard instead. Data entry is a lot easier in a Word table, and the tables are very customisable.

  16. Excel files are binary files (i.e. not plain text files), so you can't use AsciiFileBeginProcess on them. You might want to check out XLS2CSV:

     

    www.brothersoft.com/xls2csv-69870.html

     

    Does exactly as its name says. Small, fast and free. You don't even need to have Excel installed. Once data is in CSV format, it is a lot easier to read with MEP. It works from the command line, so you can call it from within macros with the Program Launch command.

     

    I've was using XLS2CSV for a project where I needed to extract data from dozens of xls files every day.

    Publisher's description

    Microsoft Excel (XLS) file to Comma Seperated Values (CSV) file conversion program. This product helps you to convert your Microsoft Excel files to the standard Readable CSV file format which can be useful for your software or web site.

  17. Just remembered that I came up with an “image capture and compare” solution last year for MEP. This can serve as an OCR replacement, and might suit your purpose if the screen info doesn't change rapidly:

     

    http://pgmacros.invisionzone.com/index.php?showtopic=4531

     

    My script uses external programs though (IrfanView and md5.exe), and it is not very fast and needs to save to disk. You might be able to speed things up with a RAM drive.

  18. Like Cory says, if your text appears in exactly the same spot every time, then you may not even need OCR. Anyway, you could use MEP's windows resizing and repositioning commands to ensure this. Does the text also appear in the exact font and color each time?

     

    You can think of the search area as a square grid, and each number has a unique layout on the grid. For example, the number 42 has a different layout when compared to 76. So all you need to do is compare pixels at a dozen (or so) precise coordinates, and you'd have a crude form of OCR.

     

    MEP should be fast enough to do this every second, or every 1/2 second.

     

    Finding out the precise pixel coordinates can be tricky. You will probably need to use Window's built-in screen magnifier (It's just called "Magnifier" in Win 7; I forgot what it's called in earlier versions) and also AutoIt3 Window Spy, a utility which will report the exact coordinates of your mouse cursor. AutoIt3 Window Spy is installed as a part of AutoHotkey_L (http://l.autohotkey.net/).

  19. You don't even need Macex for this. You could use the well known grep program from Unix. For Windows, you can get grep via GNU utilities for Win32 which can be found at http://unxutils.sourceforge.net/

    You only need the file egrep.exe which is in \usr\local\wbin

     

    For your given example:

    statusdict /setpage known {statusdict begin 792 1224 1 setpage end} if

     

    This one-liner will DISPLAY all lines which match the pattern in the file dirty.eps

     

    egrep "\{statusdict begin [0-9]{3} [0-9]{4} [0-9] setpage end\} if" dirty.eps

     

    This one-liner will REMOVE all lines which match the pattern in the file dirty.eps and write the results to clean.eps

     

    egrep -v "\{statusdict begin [0-9]{3} [0-9]{4} [0-9] setpage end\} if" dirty.eps >clean.eps

     

    -v mean invert-match, or select non-matching lines

    [0-9]{3} means "match any three-digit number"

    [0-9]{4} means "match any four-digit number"

    [0-9] means "match any one-digit number"

     

    The curly brackets have a special meaning in regex, so you need to "escape" them you're looking for the literal characters. Hence, the use of the backslash char in the search pattern, i.e. \{ \}

     

    I regularly have to grapple with extremely huge text files (over 200 million lines, file size 2GB+ each). I processed one such file using a much more complex pattern, and egrep took only about 10 seconds. It may not seem fast, but it is still faster and easier than autoit/autohotkey. Anyway, processing such large files would not be feasible with Macro Express. For your file, which is "only" about 30,000 lines and has relatively simple patterns, I would estimate egrep will take less than a second to perform the task you want. You can also call egrep from Macex.

  20. Just adding on a bit to what Kevin said. You not only need to add delays between actions, but also between keystrokes. I think the <ALTD>vmoc<ALTU> part might be the problem here. As it is, it will just blast 4 keystrokes within a few ms. You might need to separate all the keystrokes, e.g.:

     

    <ALTD>v<ALTU>

    Delay 0.1 seconds

    <ALTD>m<ALTU>

    Delay 0.1 seconds

    (...and so on...)

     

    Or you can try the Keystroke Speed command as Kevin suggested.

     

    >>Set the value(s) high, test the macro(s) and then lower the values. <<

    We do use delays but I suspect not effectively. My high would you say 350 ms. Also if I understand delay rightat the point of the command delay time is changed. But after the next command runs. It seems to me that timing is back to normal. If that is not true. Then I would need a way to bring it back to normal and I have attempted to test using delay set to zero. Am I right in my assumptions that delay is only a temporary command by command delay.

×
×
  • Create New...