Jump to content
Macro Express Forums

paul

Members
  • Posts

    1,049
  • Joined

  • Last visited

Posts posted by paul

  1. Sorry - I haven't used this feature and didn't realize the .ini file options were so inextricably tied to string variables.

     

    There is a way round this. It's a bit of a kludge, but does seem to work.

    Suppose this command:

    <VARIABLE MODIFY STRING Option="\x13" Destination="%T[3]%" Filename="%userprofile%\\Documents\\Macros\\MouseVariables.ini" Key="Location" Value="X" NoEmbeddedVars="FALSE"/>[/size]

    If you edit this and change %T[3]% to %N[3]%, you get an error message about the variable being of the wrong type.

    However...

    If you toggle the direct editor using the last icon to the left of your script, then you can replace

    Destination="%T[3]%

    with

    Destination="%N[3]%

    Toggle the direct editor again, and it works.

     

    BTW, I encourage you to use meaningful variable names instead of the old %t[3]% syntax because it makes later editing of the macro easier.

  2. I have attached an executable you might find useful - it terminates MEP using the context menu of the tray icon, then restarts it. This assumes that MEP is located at C:\Program Files (x86)\Macro Express Pro\MacExp.exe. For those of you with AutoIt, I include the source code.

    #NoTrayIcon
    #Include <GuiToolBar.au3>
    Dim $hSysTray_Handle, $iSystray_ButtonNumber
    
    $iSystray_ButtonNumber = Get_Systray_Index("Macro Express Pro")
    
    If $iSystray_ButtonNumber <> -1 Then
     Sleep(1000)
     _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
    Sleep(500)
    Send("t")
    EndIf
    Sleep(1000)
    ShellExecute("C:\Program Files (x86)\Macro Express Pro\MacExp.exe")
    
    Func Get_Systray_Index($sToolTipTitle)
     $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
     If @error Then
    MsgBox(16, "Error", "System tray not found")
    Exit
     EndIf
    
     Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
     If $iSystray_ButCount = 0 Then
    MsgBox(16, "Error", "No items found in system tray")
    Exit
     EndIf
    
     For $iSystray_ButtonNumber = 0 To $iSystray_ButCount
    If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) <> 0 Then
      Return $iSystray_ButtonNumber
    EndIf
     Next
     Return -1
    EndFunc

    RestartMacroExpress.zip

  3. You need to activate the Firefox window within your repeat loop, otherwise most mouse clicks by you will prevent your macro from finishing!

     

    My macro contains 2 additional capabilities:

    - a timeout, so that if the page never completes loading, I still regain control after the specified timeout (default is 120 seconds); I can tell if the page timed out in the If test after the repeat loop.

    - an additional delay for "difficult" pages, which I have, on occasion, found useful.

     

    Note that my firefox window is called xFirefox (when I start the computer, I rename Firefox to xFirefox using Actual

    Window manager, because ME has a long-standing bug and its Move Mouse to Tray icon doesn't work reliably for my tray which is displayed over 2 lines; as I always have Foobar2000 open in the tray, I need Firefox to start with a unique letter other than F).

     

    The pixel colours 11711149 and 8747885 used to work in earlier versions of Firefox.

  4. I don't use the icon (it's not even displayed on my screen), but I have reloaded it via Customize so as to be able to answer your question. I get no red while it's spinning (but obviously don't know how many FF versions that's been true for).

    I suspect I do something quite similar to you, but I use the X (Stop loading this page) instead of the spinning icon. I occasionally have to change the location or pixel colour, but the changes are isolated to a single macro. Here's the code I use, which works as of FF 14.0.1 - it's called FirefoxLoaded.

    <IF NOT PROGRAM Option="\x01" Program="FIREFOX.EXE"/>
    <MACRO STOP/>
    <END IF/>
    <IF VARIABLE Variable="%nTimeoutSecs%" Condition="\x00" Value="0" IgnoreCase="FALSE"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%nTimeoutSecs%" Value="120" _COMMENT="Default of 120 seconds before timeout"/>
    <END IF/>
    <VARIABLE MODIFY INTEGER Option="\x02" Destination="%nTimeout%" Value1="%nTimeoutSecs%" Value2="4"/>
    <COMMENT Value="Check background below X, wait until inactive"/>
    <REPEAT START Start="1" Step="1" Count="%nTimeout%" Save="FALSE" _COMMENT="nTimeoutSecs x 4"/>
    <WINDOW ACTIVATE Title="xFirefox" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
    <GET PIXEL COLOR Option="\x01" Rel_To_Screen="FALSE" X="69" Y="58" Destination="%nPixel%" _COMMENT="11711149 8747885"/>
    <IF VARIABLE Variable="%nPixel%" Condition="\x00" Value="11316393" IgnoreCase="FALSE"/>
    <REPEAT EXIT/>
    <END IF/>
    <DELAY Flags="\x02" Time="250"/>
    <END REPEAT/>
    <COMMENT/>
    <IF VARIABLE Variable="%nPixel%" Condition="\x01" Value="11316393" IgnoreCase="FALSE"/>
    <TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red255\\green0\\blue0;}\r\n\\viewkind4\\uc1\\pard\\qc\\cf1\\b\\fs32 Firefox timed out\\cf0\\b0\\f1\\fs16 \r\n\\par }\r\n" Left="Center" Top="385" Width="278" Height="72" Monitor="2" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x01" Delay="3"/>
    <DELAY Flags="\x01" Time="3"/>
    <MACRO STOP/>
    <END IF/>
    <READ REGISTRY VALUE Key="HKEY_CURRENT_USER\\Software\\Professional Grade Macros\\PhtData\\FirefoxAfterLoadDelay" Destination="%nDelayExtra%"/>
    <IF VARIABLE Variable="%nDelayExtra%" Condition="\x03" Value="0" IgnoreCase="FALSE"/>
    <DELAY Flags="\x01" Time="%nDelayExtra%"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%nDelayExtra%" Value="0"/>
    <WRITE REGISTRY VALUE Key="HKEY_CURRENT_USER\\Software\\Professional Grade Macros\\PhtData\\FirefoxAfterLoadDelay" Destination="%nDelayExtra%"/>
    <END IF/>

  5. Even without having touched the C language, I have learned 11 languages in my 32 years of programming. ME is 12. windows API is 13. There is no end :-)

    Yes. I've also learned several languages in my 40 years of programming; I suppose I've learnt 13 or so, but believe I've become expert at perhaps only 5 or 6. I always wonder whether the relentless pressure to produce more output in less time has led to a marked decrease in quality. They used to say that if you wrote 5 lines of bug-free Cobol a day, you were doing well. I wonder what that translates into these days!

  6. I did a google on Windows API and found some tutorials. I gather it can be very useful to know this language for both MS-access and I would assume for ME too.

    Uses for Windows API routines are very limited in ME, with Postmessage being the only option.

     

    FYI, here's some AutoIt code to fire a macro called, in this case, Textbox. I'm sure you're able to convert this into VBA if it's of interest.

    $dll = DllOpen("user32.dll")

     

    $hwnd = DllCall($dll, "hwnd", "FindWindowW", "wstr", "TMainWin", "wstr", "Macro Express Player")

    $hwnd = $hwnd[0]

    For $i = 1 to 10

    $Result = DllCall($dll, "bool", "PostMessage", "HWnd", $hwnd, "uint", 1044, "wparam", Asc(StringMid("Textbox", $i, 1)), "lparam", 0)

    Next

    $Result = DllCall($dll, "bool", "PostMessage", "HWnd", $hwnd, "uint", 1044, "wparam", 0, "lparam", 0)

    DllClose($dll)

  7. 2 issues to be aware of:

    - when you invoke MultiCharts from ME, then ME will probably not know when MultiCharts has finished. Assuming that the MultiCharts process terminates once finished, you have loop within ME until the MuliCharts process has been unloaded from memory

    - Access is an MDI application; this makes the process of handling its windows quite complicated, and not one that ME handles well. However this should be irrelevant if you are simply reactivating the Access window

     

    If you don't want to use the registry method of checking when ME has finished, you could also create a file and have Access check for its existence of absence.

  8. If I understand your message correctly, you need %N1% to increment by 1 each time you use it. You can do this directly in the Repeat statement itself (you'll see something like "store the counter into a variable"), or by including the statement "Variable Modify Integer %n1%: Increment" within the Repeat loop.

  9. I'd do as follows:

    - Place all the URLs into a text variable, delimited by some separator character, or fixed length (e.g. each URL is 100 characters long)

    - Place all the userids into a 2nd text variable, delimited or fixed length

    - Place all the passwords into a 3rd text variable, delimited or fixed length

     

    Write the main code within a repeat loop, repeating 4 times. Within each loop, extract the next value from each of your 3 text variables, and do the processing, exiting the macro when successful. Fixed length will make the extraction simpler, e.g. extract characters 1-100, then 101-200, etc., where you hold the start position in an integer variable; alternatively, you search for the next separator and extract accordingly.

  10. Some macro commands work when the PC is locked, but many don't.

     

    I have solved this problem in the past as follows:

    - Using the windows scheduler, I start a task at a specified time that writes 2 values to the registry and reboots the computer; the 2 registry values allow the computer to boot without soliciting a user or password

    - When Macro Express starts, it detects the 2 registry values and immediately restores them so that the next boot will require the usual credentials; it then runs whatever macro(s) you require, and reboots the machine once the macros have finished

  11. ...It all goes back to my complaint about the credence given to the term 'professional'. Just because they do it for a living doesn't mean they're experts who know how to do things properly. Professional car stereo installers for instance. I can't count how many automotive electrical systems I've troubleshot whose flaw was a 'professional' stereo or alarm installation. And it seems the programming world is even worse.

    I could write reams on this! And I couldn't agree with you more (even though I would have called myself a professional programmer).

    The causes are many and various:

    - The IT world is heavily populated with mediocrity

    - Many in the IT world have no business experience, and don't know how to think for themselves

    - Today the demands are such that a programmer is often required to know many languages; but to what level, and how much real knowledge is there?

     

    I actually spent most of my professional consultancy days fighting IT departments on behalf of users. Nowadays it's much harder, because IT seems to have conquered the world.

  12. ...I decided on VB.NET for several reasons: It’s consider easier syntax to learn with the caveat that it’s now OOP so you need to make that mental leap; It’s very similar to VBA used in Office macros, VBScript used in various administrative roles and web pages; is easy to jump into web languages like ASP. However my professional programmer friends look down on me as it’s largely considered a hobbyist language and they use things like C#.

    All I can say is your professional programmer friends are quite ignorant! The only major difference of note between the capabilities of C# and VB.NET is that the former allows you to write non-managed code, something which I imagine 99% of programmers should not need, or ever be allowed, to do. You know, non VB programmers have always looked down on, and sneered at, those who do use VB, and I've never understood why. Perhaps it has to do with the perception (for which there is, or used to be, some justification) that VB programmers come from the ranks of the hobbyist programmer, while C# are more likely to have learnt their skills at university, or in some more professional manner.

     

    I used to look down on VB myself, because I know there was a far superior language that unfortunately never became mainstream, namely APL.

    But that's another story.

  13. This is what I do in a macro which is only called by other macros. It displays a countdown message ("sleeping in n seconds") where n reduces by 1 each second. If any mouse movement is detected, the macro stops since I don't want to put the computer to sleep if I'm using it.

     

    n91 is preinitialized to 10.

    Text Box Display: Pausing
    Get Mouse Position into (%nMouseX1%, %nMouseY1%) Relative to Screen
    Repeat Until %n[91]% Equals "0"
     Delay: 1 seconds
     Get Mouse Position into (%nMouseX2%, %nMouseY2%) Relative to Screen
     If Variable %nMouseX1% Does not Equal "%nMouseX2%"
    Or
     If Variable %nMouseY1% Does not Equal "%nMouseY2%"
    Macro Stop
     Else
    If Window "Pausing" is running
      Variable Modify Integer %n[91]%: Decrement
    Else
      Macro Stop
    End If
     End If
     Update Textbox: Pausing
    End Repeat

×
×
  • Create New...