Jump to content
Macro Express Forums

paul

Members
  • Posts

    1,049
  • Joined

  • Last visited

Posts posted by paul

  1. My suggestion is to follow the logic below:

    Repeat until all variables have been copied to the clipboard
     repeat until %n[1]% <> %n[1]% (i.e. for ever)
    copy Var1 value to clipboard
    read clipboard value into Var2
    if Var1 = Var2 exit inner repeat
    delay 500ms
     end inner repeat
    end outer repeat

     

    You can make this more sophisticated by counting the failures and terminating the macro after dome specified number of failures within the inner loop.

  2. If AHK scripts recognize window titles, why not use AHK for everything?

    Ease of use is the main answer, plus AHK has a truly horrible, totally non-standard syntax.

     

    I am reasonably familiar with AHK, and tried developing AHK scripts triggered by window titles. I poured through the Help system, posted questions on the AHK forum, and still have no idea how to do it.

    I'm with you there!

  3. Any ideas on how this force this script to run instantly as the result of the creation of a window? (In this situation, "Window gains focus" is OK for testing, but not for real life.)

    My best suggestion is to use AutoHotkey and make it responsible for recognizing window names and firing off the relevant MEP macro. Such AHK scripts would be really simple to write.

  4. But Alan, your code doesn't get triggered by anything. I believe Toast wants the macros to start automatically based on the Window title.

     

    There are 2 main approaches. If all your target windows share some common text, e.g. Windows Internet Explorer, then you could write a macro similar to what Alan described above, where this macro is triggered by a window title containing your common text being opened. I'd use this approach if possible.

    If there's no common text, you'll have to write one macro for each target window, and have each macro triggered by opening a window containing the target text. Depending on how many windows you're attempting to control, this may get rather messy and hard to manage. But it should work.

  5. Hello I have a macro that uses the wait for window to appear command and often the window doesn’t ever appear so the macro times out

    I need it to just start over if the window doesn’t appear

    but I can't find any options on that command for failures

    In ME3 you will have to handle this yourself.

    Your code will follow this logic:

    Repeat until %n1% <> %n1% (i.e. for ever)
     Launch program that opens your target window
     Set %n1% to 0 (just in case this variable has already been set to other than 0)
     Repeat 10 times
    If target window is present
      set %n1% = 1
      Repeat exit
    else
      delay 2 seconds
    End if
     End repeat
     If %n1% = 1
    Repeat exit
     End if
    End repeat

    Notes

    - Each "wait for window" set of commands (the inner repeat loop) will wait for up to 20 seconds - you can vary this as you like.

    - You need to determine how long to allow the outer loop to run before giving up - follow the same technique as for the inner repeat loop.

  6. Here's a 3-line example of passing in variable %T[1]% to AutoIt, and returning variable %T[2]% from AutoIt. Note that you can pass in multiple variables to AutoIt, but can receive only one parameter back (that console output variable you alluded to). Of course, you can receive from AutoIt the one variable in as complex a format as you like, e.g. a/b/c/d/e/f/g which could be converted into 7 different values in MEP.

    Variable Set String %T[1]% to ""Input Parameter""
    External Script: AutoIt
    Text Box Display:

    <VARIABLE SET STRING Option="\x00" Destination="%T[1]%" Value="\"Input Parameter\""/>
    <EXTERNAL SCRIPT Language="AutoIt" Dest="%T[2]%" Script="msgbox(0,\"My Title\",\"My Text\")\r\nConsoleWrite(\"Returned Value is \" & $CmdLine[1])\r\n\r\n" Parameters="%T[1]%"/>
    <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Passed in:%T[1]%\r\n\\par Returned:%T[2]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

  7. The new version of IP.Board contains new and updated features including some that help moderators. We decided to upgrade so we could use these new features. We did not ask about outline view. Your question was forwarded to Invision support. This is their response:

    We also seem to have lost the ability to remember where we were in a thread - in other words, this forum used to scroll down to the 1st unread message in a thread (useful if there are lots of messages).

     

    This is so typical of software development these days - ignorance reigns supreme.

  8. I'll try some more using your tip of NOT using named variables in the Run Macro in Variable commands to see if that might be a workaround/solution.

     

    If I find positive results, I'll post back here.

    I don't think you will find any positive results.

    I've just been playing with this some more.

    I have this macro, that returns the current time of day in seconds since midnight.

    <VARIABLE SET INTEGER Option="\x13" Destination="%N[1]%"/>
    <VARIABLE SET INTEGER Option="\x14" Destination="%N[2]%"/>
    <VARIABLE SET INTEGER Option="\x15" Destination="%N[3]%"/>
    <VARIABLE MODIFY INTEGER Option="\x02" Destination="%N[1]%" Value1="%N[1]%" Value2="3600"/>
    <VARIABLE MODIFY INTEGER Option="\x02" Destination="%N[2]%" Value1="%N[2]%" Value2="60"/>
    <VARIABLE MODIFY INTEGER Option="\x00" Destination="%N[1]%" Value1="%N[1]%" Value2="%N[2]%"/>
    <VARIABLE MODIFY INTEGER Option="\x00" Destination="%N[99]%" Value1="%N[1]%" Value2="%N[3]%"/>
    <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %n[99]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

    When run, this returns 8498 when the time is approximately 02:21

    But I cannot persuade it to return anything other than 0 when run within a macro (remembering to replace all % signs in the variable being set to {%}, and to include the NoEmbeddedVars="FALSE" command in each line, as per the Help).

    <VARIABLE SET STRING Option="\x00" Destination="%tMacroCode%" Value="<VARIABLE SET INTEGER Option=\"\\x13\" Destination=\"{%}N[1]{%}\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x14\" Destination=\"{%}N[2]{%}\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x15\" Destination=\"{%}N[3]{%}\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"{%}N[1]{%}\" Value1=\"%N[1]%\" Value2=\"3600\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"{%}N[2]{%}\" Value1=\"%N[2]%\" Value2=\"60\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"{%}N[1]{%}\" Value1=\"%N[1]%\" Value2=\"%N[2]%\" NoEmbeddedVars=\"FALSE\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"{%}N[99]{%}\" Value1=\"%N[1]%\" Value2=\"%N[3]%\" NoEmbeddedVars=\"FALSE\"/>\r\n<TEXT BOX DISPLAY Content=\"{\\\\rtf1\\\\ansi\\\\ansicpg1252\\\\deff0\\\\deflang3081{\\\\fonttbl{\\\\f0\\\\fnil\\\\fcharset0 Tahoma;}{\\\\f1\\\\fnil Tahoma;}}\\r\\n\\\\viewkind4\\\\uc1\\\\pard\\\\f0\\\\fs16 %n[99]%\\\\f1 \\r\\n\\\\par }\\r\\n\" Left=\"Center\" Top=\"Center\" Width=\"278\" Height=\"200\" Monitor=\"2\" OnTop=\"FALSE\" Keep_Focus=\"TRUE\" Mode=\"\\x00\" Delay=\"0\"/>" NoEmbeddedVars="FALSE"/>
    <RUN MACRO IN VARIABLE Variable="%tMacroCode%"/>

     

    Update 10 minutes later

    OK, the Help file sprouts garbage! I got this to work as follows:

    - ignore the {%} Help statement, and omit the NoEmbeddedVars="FALSE" statement

    - instead, simply copy the desired commands, and tick the Don't process embedded variables tick box

    <VARIABLE SET STRING Option="\x00" Destination="%tMacroCode%" Value="<VARIABLE SET INTEGER Option=\"\\x13\" Destination=\"%N[1]%\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x14\" Destination=\"%N[2]%\"/>\r\n<VARIABLE SET INTEGER Option=\"\\x15\" Destination=\"%N[3]%\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"%N[1]%\" Value1=\"%N[1]%\" Value2=\"3600\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x02\" Destination=\"%N[2]%\" Value1=\"%N[2]%\" Value2=\"60\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"%N[1]%\" Value1=\"%N[1]%\" Value2=\"%N[2]%\"/>\r\n<VARIABLE MODIFY INTEGER Option=\"\\x00\" Destination=\"%N[99]%\" Value1=\"%N[1]%\" Value2=\"%N[3]%\"/>\r\n<TEXT BOX DISPLAY Content=\"{\\\\rtf1\\\\ansi\\\\ansicpg1252\\\\deff0\\\\deflang3081{\\\\fonttbl{\\\\f0\\\\fnil\\\\fcharset0 Tahoma;}{\\\\f1\\\\fnil Tahoma;}}\\r\\n\\\\viewkind4\\\\uc1\\\\pard\\\\f0\\\\fs16 %n[99]%\\\\f1 \\r\\n\\\\par }\\r\\n\" Left=\"Center\" Top=\"Center\" Width=\"278\" Height=\"200\" Monitor=\"2\" OnTop=\"FALSE\" Keep_Focus=\"TRUE\" Mode=\"\\x00\" Delay=\"0\"/>" NoEmbeddedVars="TRUE"/>
    <RUN MACRO IN VARIABLE Variable="%tMacroCode%"/>

    Notes

    1. The final display command can either be part of the code stored in the variable or run after the macro variable has been run, because the value %n[99]% is not out of scope once the macro variable has been run - its value is retained.

    2. I changed all the %n[x]% references to %an[x]%, declared variable %an% as an integer array of 99 elements making it available to macros, and, to my amazement, the code worked. So it looks as if Insight has done a lot of work in this area, almost none of which has ever been described in any of their documentation accompanying each new release.

     

    To sum up: it looks as if user variable names are fine as long as they are predefined in the macro that runs the macro variable command. Further, variables persist even after the variable macro has run. I take my hat off to Insight for this - 'tis a shame about the lack of documentation.

  9. With apologies for getting further OT, a couple of queries:

    1. I have a dozen or so AHK scripts in regular use. Presumably there will be no 'conflict' if I run those as well as AutoIt scripts?

    No conflicts occur.

    2. But ideally I'd like to settle on just ONE of those tools. Are there any aids to help convert AHK to AutoIt?

    Not that I know of. But I am willing, able and available (for a fee) to help you with this, or to do the conversions for you if you don't have the time.

    3. Forum seems just as active as AHK's and many resources available. Of the scores of 'tutorials', can you recommend one or two to get me started please?

    Wiki recommended

    Regular Expressions

    Function documentation

    Regular Expressions

    Forums search for StringRegExp

  10. This doesn't work:

    %T[%N[5]%]%

    It does for me!

    Try this code and let us know what your results are:

    <VARIABLE SET STRING Option="\x00" Destination="%t[1]%" Value="First" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%t[2]%" Value="Second" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%t[3]%" Value="Third" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%t[4]%" Value="ourth" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%t[5]%" Value="Fifth" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%n[1]%" Value="1"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%n[2]%" Value="2"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%n[3]%" Value="3"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%n[4]%" Value="4"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%n[5]%" Value="5"/>
    <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 The 5th element of t1 is %t[5]%\r\n\\par \r\n\\par The nth element of t1 is %t[%n[5]%]%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

  11. You want it checked if you want to reuse, not uncheck.

     

    Now if you're running in tabbed mode then you should also check your tab browsing settings. Internet Options > General tab > Open Links from other programs in:

     

    You just need to look around in the IE settings. Also use the help file.

    Cory, none of these settings makes the slightest difference - I have tried them all.

  12. Not long after MEP was released, I complained about the rotten implementation of the Run Macro in Variable command which had worked so successfully in ME3.

    Variable handling hardly works, since MEP has no ability to decide what type a variable is, though I seem to remember that %t[n]% formats may work OK. I can no longer remember the details, but I decided that this command obviously proved far too hard for Insight - I don't know why they ever included it in MEP.

    In days of yore, I co-authored a macro library for ME3, which depended heavily on this command.

  13. 3. Use AutoHotkey, a scripting language in which I'm dipping my toes, and which has strong RegEx as far as I can gather. It also benefits from a very active and helpful forum.

    AutoHotkey is a very useful utility, and I suspect there are some things (mainly keyboard and hotkey orientated) that cannot be done so easily in other languages like AutoIt (which shares some common ancestry with AutoHotkey). But as far as language constructs and syntax are concerned, AutoHotkey really is truly horrible. It's totally non-standard; one example is of text strings that included embedded spaces, which, in most cases, don't require (and must not use) surrounding quotation marks.

    I'm certain that AutoIt is at least as powerful as AutoHotkey in its handling of regular expressions, and I firmly believe that the AutoIt Help documentation is superior to that in AHK, and that the AutoIt forums are supported in a more professional way.

  14. However ME Pro limits the option "wait for the web page" (which I use a lot) only to IE.

    I wish Firefox had this option too...

    While Firefox is still loading a page, you'll notice that there's an X between and below Edit and View in the menu bar that is not greyed out. I've written a macro called FirefoxLoaded that runs after I've requested a specific URL, and returns control only after this X becomes greyed out, OR after a timeout usng some predefined value (in my case, 120 seconds). FirefoxLoaded checks for a specific pixel value in the centre of the X (this pixel value, together with its exact location, varies according to the graphics card and OS you use, but, once set, is stable).

  15. This is quite odd!

    My default browser is Firefox, for which the Web SIte command works as expected; if Firefox is not running, this command loads Firefox with the requested page. If Firefox is running, this command simply opens a new tab showing the requested page.

    But, like you, my experience with IE is quite different. The Web Site command always seems to open a new non-maximized window for IE, even though I have declared my preference for tabs.

    So I suggest the following code as a workaround:

    Variable Set String %tUrl% to "www.myhq.com"
    If Not Program "IEXPLORE.EXE" is running
     Program Launch: "iexplore.exe" (Normal)
    Parameters: 
    End If
    Window Activate: Internet Explorer
    Text Type (Simulate Keystrokes): <ALT>d
    Delay: 500 milliseconds
    Text Type (Simulate Keystrokes): %tUrl%<ENTER>

    <VARIABLE SET STRING Option="\x00" Destination="%tUrl%" Value="www.myhq.com" NoEmbeddedVars="FALSE"/>
    <IF NOT PROGRAM Option="\x01" Program="IEXPLORE.EXE"/>
    <PROGRAM LAUNCH Path="C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe" Mode="\x00" Default_Path="TRUE" Wait="1" Get_Console="FALSE"/>
    <END IF/>
    <WINDOW ACTIVATE Title="Internet Explorer" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
    <TEXT TYPE Action="0" Text="<ALT>d"/>
    <DELAY Flags="\x02" Time="500"/>
    <TEXT TYPE Action="0" Text="%tUrl%<ENTER>"/>

×
×
  • Create New...