Jump to content
Macro Express Forums

paul

Members
  • Posts

    1,049
  • Joined

  • Last visited

Posts posted by paul

  1. Is the whole post based on Vista?

    Not at all. I composed it using XP Professional, but it should work as is under Windows 2000. Earlier than that I cannot guarantee <g>!

     

    Have your macro simply display a dialogue box to show that it's running. If it still doesn't work, please do as follows:

    - tell us what operating system you're using

    - run regedit.exe

    - export the contents of the registry key HKEY_CLASSES_ROOT\* to a file

    - edit that file and copy its contents to the clipboard

    - paste the clipboard text into your message

  2. This is what I do.

     

    I've written a macro (called, say, Pwd) which simply places the current password in a variable, e,g, T99. This macro is password-protected so that no-one else can edit or view its contents. Any macro that needs to use this password simply runs macro Pwd and uses the contents of T99.

     

    When my password changes, I have to edit only one macro.

     

    And yes, it would be possible to write a separate macro that prompts for a new password and recreates Pwd.

  3. Well, my general approach to problems like this is to avoid all ME commands which do an automatic "Wait for" and bomb out when they fail. Instead, within as many Repeat loops as you need, I use some sort of IF command, or write a subroutine in a separate macro, and look after my own loops and error conditions.

     

    Here's a practical example:

    Variable Set String %T91% "13395456/15/415/130/Mozilla Firefox"
    Macro Run: { Utility - Wait for Pixel }
    If Variable %N99% = 0
     Macro Stop
    End If

     

    T91 (delimited with "/") contains

    - Pixel

    - TimeoutSeconds

    - X-Offset1

    - Y-Offset1-

    - X-Offset2 (optional)

    - Y-Offset2 (optional)

    - X-Offset3 (optional)

    - Y-Offset3 (optional)

    - WindowName

     

    If N99 is 0, then we timed out and the pixel colour never appeared at the x,y location (of which I can have multiple pairs).

     

    Imagine that ME contained a "Wait n seconds for Pixel colour at x,y", and that if it failed it would issue an error message (just like Wait for control, or Wait for Window Title). My code above would be how I'd avoid using such a command.

     

    Yes, it's certainly more code, but you retain control. And once you've written and debugged the subroutine (in this case "{ Utility - Wait for Pixel }"), then you're actually writing about the same amount of code.

  4. Paul, your post says that VB Script can not make Windows API calls, but I was wondering if it can make calls to other API's?

    I suspect not.

    However, you might like to investigate an outstanding freeware scripting product called AutoIt3, which certainly does support API calls via DllCall. While it might seem like a competitor to Macro Express (and certainly there's a lot of overlapping functionality), I think ME is far easier for most people to utilize than AutoIt3.

     

    Here's the URL:

    http://www.autoitscript.com/autoit3/index.php

  5. The registry key is:

    HKEY_CLASSES_ROOT\Shell\Me Macro\command

    Its contents under '(Default)':

    "C:\Program Files\Macro Express3\MeProc.exe" /AContextMacro /VT1:%1

    I didn't make any mention of that registry key! Please take a fresh look at my message of 27th February, especially to the lines between Run regedit.exe and Close Regedit

     

    Let us know how you get on.

  6. But if ME was running they wouldn’t go into standby. It was my fax monitor macro and all it was did was check to see who the domain user was, compare it to a list saved in the macro and abort. No mouse keyboard or other UI commands.

    Well, to my great surprise, you're almost completely right! Running any macro does indeed stop the machine going into Standby, except if the command you're running is a Timed Delay!

     

    This is what I've tried, having set my machine to standby after 1 minute of inactivity.

     

    1) Have a macro running, which loops for 5 minutes; in the loop, do a normal delay for 90 seconds. Standby never occurred.

     

    2) Have a macro running, which loops for 5 minutes; in the loop, do a timed delay for 90 seconds. Standby occurred after one minute.

     

    3) Using a .bat file, loop for ever; in the loop, display a folder with the dir command, then wait for 5 seconds (using VB Script). Standby occurred after one minute.

     

    4) Using a .bat file, loop for ever; in the loop, display a folder with the dir command. Standby never occurred.

     

    My conclusion? That running a macro occupies enough CPU cycles to prevent standby from taking place. I assume that test 4 also consumes CPU cycles.

     

    I've written a quite complex set of ME macros to handle hibernation or standby on my computer, because having the machine hibernate automatically in the usual way interrupts long-running downloads. These macros can detect if downloads are taking place, or whether I am running some specific program (e,g, encoding one or more DVDs). If so, the machine simply tries again later. One advantage of the ME scheduler over the Windows one when specifying inactivity is that ME repeats the attempt to run the macro continuously, whereas the Windows scheduler does not.

  7. My first attempt was this:

    "C:\Program Files\Macro Express3\MeProc.exe" /AContextMacro /VT1%1

    The only thing wrong was the missing colon immediately before the %1.

     

    Then we got this:

    C:\Program Files\Macro Express3\Meproc.exe" /AContextMacro /VT1:%T1

    Here we have the mysterious appearance of an unwanted T in %T1.

     

    I doesn't seem to matter how many times I checked my script (and I took a great deal of care) - I'm not perfect after all <g>!.

     

    Paul you're my golden god for a day.

    So I can't be God, because God, by definition, is perfect <g>!

  8. Now if a macro runs it appears as activity to the system so it will not go into standby. E.G.: if the macro runs every 5 minutes and the sleep is set to kick in after 10 minutes it will never go to sleep. If the macro doesn't fire, do to the scheduling, it will go into standby.

    A machine's state of inactivity is quite precisely measured by the period in which no keyboard or mouse activity takes place. Running programs, downloading, etc. - none of these processes counts in terms of stopping an inactive countdown.

    Running an ME macro stops this inactive counter ONLY IF that macro moves the mouse or types some text - otherwise the inactive counter is not stopped.

  9. Ah, a (too?) early take-up of Vista <g>!

     

    Vista permissions are rather different to its predecessors, and I have not yet got any practical experience of how to avoid or resolve this type of problem. I think the real problem is that Vista, by default, does not grant you admin permissions - and I imagine that's what you need to change registry settings.

  10. ... after it finishes running it will disable it to prevent the scheduled macro from conflicting with my PC's standby

     

    I think you'll find it's the other way round! When your machine is in standby, or hibernating, none of the macros you schedule using ME's scheduler will run.

     

    However:

    IF you use the Windows scheduler to fire off your ME macro,

    AND assuming it's set to wake your machine,

    AND your BIOS can handle this,

    it's a different story.

  11. I assume you're using Windows XP.

     

    In the example below, we're going to add a context menu item called "Me Macro" to ALL files!

     

    - Run regedit.exe

     

    - Navigate to HKEY_CLASSES_ROOT\*

    (HKEY_CLASSES_ROOT is the first main branch in your registry)

     

    - If the key called "shell" doesn't exist, add it (exclude the double quotes) by right-clicking on *, choosing New / Key.

     

    - Right-click on "shell", and choose New / Key

     

    - Type "Me Macro", then press ENTER (without the quotes)

     

    - Right-click on "Me Macro", and choose New / Key

     

    - Type "command", then press ENTER (without the quotes)

     

    - Left-click on "command", then, in the right-hand pane, double-click on "Default"

     

    - Type in the following, including the quotes:

    "C:\Program Files\Macro Express3\MeProc.exe" /AContextMacro /VT1%1

     

    Close Regedit.

     

    Here's my ContextMacro macro:

     

    Variable Restore All Variables
    Text Box Display: (ContextMenu is now running! Parameter is %T1%)

  12. So given I don’t know the difference between VB, VBA and VBA

    VB is a full-blown stand-alone language, and belongs within Visual Studio.

     

    VBA comes with various applications, e.g. Word, Access, Outlook, etc. It's pretty similar to VB, although there are some things you can't do, e.g. build custom ActiveX controls).

     

    VB Script is a severely cut-down version of VB, e.g. you can't make Windows API calls, you can't compile it, you can't declare strongly typed variables (e.g. Dim Myvar as Long)

     

    and the last language I programmed in was Pascal

    Delphi is a popular and powerful Pascal-based language and application development tool.

     

    I’ve been wanting to learn VB for a long time but I haven’t had a need yet. And how much do I need to know to get done what I need for now?

    How long is a piece of string?

     

    Develop a basic understanding of COM or ActiveX (which is the main technique you need to master when communicating with Access databases).

     

    Read the Macro Express Help documentation (it's mostly very good), and get Joe's book (it's completely excellent)

     

    Get a book on VB Script (I've got quite a good one called "Windows Scripting Secrets" byTobias Weltner).

     

     

    What is WshShell?

    "The shell is the component of Windows that presents users with an interface to the operating system and provides familiar elements of the Windows desktop experience, including Windows Explorer, the Start menu, shortcuts, and desktop themes.

    The WshShell object gives your scripts the ability to work with the Windows shell. Your scripts can use the WshShell object to perform a number of system administration tasks, including running programs, reading from and writing to the registry, and creating shortcuts."

     

    Take a look at:

    http://msdn2.microsoft.com/en-us/library/ms950396.aspx

    and

    http://freenet-homepage.de/gborn/WSHBazaar/WSHBazaar.htm

     

    What is MeProc?

    It's part of Macro Express, and is documented in the Help.

     

    I would be willing to hire if inexpensive enough. If you’re like attorneys or Db programmers who get $100+ per hour forget I said anything. <g>

    OK, duly forgotten <g>!

  13. You can retrieve data from an Access database using VB Script. It's therefore not too difficult to construct a vb script that can be "called" from an ME macro.

     

    Here's a simple example (you'll need to provide a fully qualified Access database, a valid table name in the database, and the path to MeProc in your Macro Express folder). It assumes you've got Jet 4 (installed with Access 2003).

     

    1) Create a vb script called C:\Test.vbs, containing this code

    Dim MyConn, MyRs, WshShell, RecCount
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set MyConn = CreateObject("ADODB.Connection")
    MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FullyQualifiedAccessDatabasename;"
    Set MyRs = MyConn.Execute("SELECT COUNT(*) FROM TableName")
    RecCount = MyRs(0)
    MyRs.Close
    Set MyRs = Nothing
    MyConn.Close
    Set MyConn = Nothing
    WshShell.Run("""PathToME\MeProc.exe"" /AAccessReturn /VN1:" & RecCount)

     

    2) Create an ME macro called AccessStart, as follows:

    Program Launch: "Test.vbs" (Program Name=C:\Test.vbs")

     

    3) Create an ME macro called AccessReturn, as follows:

    Variable Restore All Variables
    Text Box Display: (Box Content=N1 is %N1% (returned from Access))

     

    This is one way to pass information back from Access. It's not my preferred way (I'd use the registry, as WshShell can write directly to the registry), but you can use this as a starting point for something more grand <g>!

     

    You call the vb script by running the macro called AccessStart. This macro then terminates. The vb script gets its data from your Access database, then calls the macro AccessReturn via MeProc, passing it the returned data (count of records in your table) in %N1%.

  14. If you do the following, you will be able to open an Access form:

     

    1) In your access database, create a macro to open your form

    I'll assume it's called MyMacro

     

    2) Write an ME macro with the following command (don't include the hyphen or leading spaces in the text below):

    Activate/Launch program

    Window Title:

    - Access

    Program Path/Name:

    - C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE

    (adjust this as necessary for your environment)

    Program Parameters:

    - C:\MyDbFolder\MyDbName.mdb /x MyMacro

    (adjust this as necessary for your environment)

  15. I've just done a quick test of Ctrl-F using IE7. It still works, albeit in a different way. Ctrl-F brings up the same dialog box as in IE6 where you enter your search term. If you then close the dialog box and press F3:

    - under IE6 this locates the next occurrence of your search string without redisplaying the dialog box

    - under IE7 this redisplays the dialog box with your search term; in order to do the next search, you have to press Alt-N for Next and close the dialog box again.

  16. Here's my ME macro:

    Program Launch: "MSACCESS.EXE" 'this opens a database called TestME.mdb

    Text Box Display: 'This displays "Arrived"

     

    Here's my TestME.mdb database:

    Table tblData

    DataId Primary Key AutoNumber

    DataText Text(200)

     

    Macro Autoexec

    RunCode CreateData ()

     

    Module Module1

    Option Compare Database

    Option Explicit

    Public Function CreateData()

    Dim MyRs As DAO.Recordset

    Dim lngI As Long

    Dim lngNumrecs As Long

    DoCmd.Hourglass True

    DoCmd.RunSQL "DELETE * FROM tblData"

    lngNumrecs = 100000

     

    Set MyRs = CurrentDb.OpenRecordset("tblData")

    With MyRs

    For lngI = 0 To lngNumrecs - 1

    .AddNew

    .Fields("DataText") = "Text " & Format$(lngI, "000000")

    .Update

    Next lngI

    .Close

    End With

    Set MyRs = Nothing

    DoCmd.Hourglass False

    DoCmd.Quit acQuitSaveNone

    End Function

     

    This function simply inserts 100,000 rows into tblData after deleting any existing rows in the table. It takes around 10 seconds to run on my machine.

     

    When I run the ME macro, the dialog box containing the word "Arrived" appears within 2 seconds (and Access is still running; Access closes itself after another 8 seconds or so).

     

    Here's my guess at what's happening on your machine. Whatever code or query your autoexec macro is running is CPU intensive and utilizes your CPU at 100% (this is very common with Microsoft Access - it is the greediest piece of software I've ever seen, and is very poor at releasing control to any other applications when it is occupied with a database task). The essential difference between my environment and yours is probably that I'm using dual CPUs, so I still have CPU available even when Access is doing its best to take over the machine! While your CPU is 100% occupied, ME is not going to be able to continue on with its macro, even though that's the way it is designed to operate. You can test this observation for yourself by inserting a line containing the word DoEvents after the line containing the word ".Update" in the above code - I'm pretty sure your ME macro will then be able to continue.

     

    I have written a generalized VB Server module that runs various VB code to return results to ME. I always have to write specific logic to force ME to wait until my VB server has finished (I use a flag in the registry to achieve this).

  17. OK, let's use http://www.macros.com/ as our example.

     

    If you open this URL, you can see a small box containing the word "RSS" on the left-hand side underneath the word "Search". On my computer this box is orange, with a pixel colour of 26367 (it'll probably be different for you) and this colour is located at position 58, 562 under Active Window using the Mouse Locator tool (again, this will be different for you). But the essential point to realize (or at least hope for) is that this box is always at the same location, and always this colour (if Kevin reads this, he'll probably ask his web designer to change this immediately <g>!).

     

    So you write a script along these lines:

    Web Site: http://www.macros.com [Default Browser]

    Repeat Start (Repeat 10 times)

    Get Pixel: Window Coords: 58,562 into %N1%

    If Variable %N1% = 26367

    Repeat Exit

    End If

    Wait Time Delay 1 Seconds

    Repeat End

     

    This opens the desired URL, then enters a loop for a maximum of 10 seconds to check the pixel colour at the specific location. When it equals our colour, then we assume the page is loaded and we exit the loop. At the end of 10 seconds, the loop terminates. If you check the value of %N1% after the loop has finished, it will equal our colour of 26367 if the page loaded successfully, and some other value if the page didn't load (or Kevin had the colour and/or location changed!).

     

    I hope this helps.

×
×
  • Create New...