Hello,

I've created a macro using AutoHotkey to automate a particularly boring task I have to repeat hundreds of times each day.

The task requires me to get info from a web page, move to an application where I paste info from the web page and process an order, then move to another web page interface for an access database.

AutoHotkey automates the mouse clicks and copy/paste, but if all 3 apps are not laid out properly the macro clicks in the wrong place and everything turns into a mess.

I thought that if I could use windows messages to communicate to each application, I could make the macro work a lot better. No matter where the window was or what screen resolution was used the windows message would work.

Any advice if I'm on the right track here or if I need to look at a different approach? If windows messages are the right approach, any idea on where to start? I've tried using Winspector Spy, but it causes my app to crash so I can't see what messages it's using to process the orders.

Thanks,

Vincent

A way to do this would be to record every relevant message and the time between this message and the last message. To record it you could do something like this:

#include <iostream>
#include <vector>
#include <windows.h>

using namespace std;

struct Action {
   HWND hwnd;   // Window Handle
   UINT msg;    // Message ID
   UINT delay;  // Delay to next message
};

// Use windows hooks to fill up this vector with actions
vector<Action> actions;

I suggest to actually read the messages from all applications you look up windows hooks.
For some information about hooks and how to use them go here.

As for playing them back, I would suggest you make a seperate thread because using the Sleep function stops all other messages from being handled on your application until the delay has finished.

For playing back the actual message, take a look at SendMessage or PostMessage.

I hope this helps.

I suggest to actually read the messages from all applications you look up windows hooks.

Sorry, I dont know what happened, but I just realised this sentence makes no sense at all ;)

It seemed to make sense to me -- read/display all windows messages from all apps.

I'm trying to understand how hooks work and how to use them.

I think I'm in over my head here, but it feels like I'm on the right path.

Thanks for your input here, I never would of thought of using hooks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.