Jump to content

Recommended Posts

Posted (edited)

If I don't like the dll interface to AutoIt, isn't it easy to rewrite the functions?

Currently I'm focused on window manipulation, so wouldn't I need just to use user32.dll functions?

Or are there so many hacks and tricks I should know before I could write my on WinActivate() and WinExists() ?

Edited by amokoura
Posted

Check out the source. It's got most of those functions in it. The source is outdated, but it is a useful starting point.

Thanks! The Window functions might've not changed much.

  • Developers
Posted

BTW I checked AutoHotKey's source. At least it's available. And most likely similar with AutoIt.

Just do a search on that topic and I am sure you get all the details on that one.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • Moderators
Posted (edited)

If I don't like the dll interface to AutoIt, isn't it easy to rewrite the functions?

Currently I'm focused on window manipulation, so wouldn't I need just to use user32.dll functions?

Or are there so many hacks and tricks I should know before I could write my on WinActivate() and WinExists() ?

I'm sure that:

GetActiveWindow

SetActiveWindow

IsWindow

FindWindow

API calls are all you're looking for?

Edit:

Forgot SetActiveWindow

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Thank you! I was just blind.

I'm sure that:

GetActiveWindow

SetActiveWindow

IsWindow

FindWindow

API calls are all you're looking for?

Edit:

Forgot SetActiveWindow

Yeah. Exactly those. And the one which returns all windows.

For now, I've managed well with the AutoIt dll. Just preparing for a situation where I might have to write as elegant Window manipulation functions as AutoIt has. Gotta check how much effort it would require.

Posted

There is no function that just returns all the windows. You have to call EnumWindows for that, and provide a function to pick up each individual window. It's kinda messy.

Yeah. That's why I'll try to stick with AutoIt as long as possible :)

Posted (edited)

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


struct WinInfo
{
    HWND WindowHandle;
    LPSTR WindowTitle;
};

BOOL CALLBACK PartnerCallback(HWND hWindow, LPARAM lParam)
{
    std::vector<WinInfo> *pVector = (std::vector<WinInfo>*)lParam;
    WinInfo wi;
    wi.WindowHandle = hWindow;
    wi.WindowTitle = new char[256];
    GetWindowTextA(hWindow, wi.WindowTitle, 256);
    pVector->push_back(wi);

    return TRUE;
}

std::vector<WinInfo>* WinList()
{
    std::vector<WinInfo> *pVector = new std::vector<WinInfo>();
    EnumWindows(PartnerCallback, (LPARAM)pVector);
    return pVector;
}

int main()
{
    std::vector<WinInfo> *pWindows = WinList();

    for (size_t i = 0; i < pWindows->size(); i++) {
        std::cout << pWindows->at(i).WindowTitle << "\n";
        delete[] pWindows->at(i).WindowTitle;
    }
    delete pWindows;

    while(1) {} 
}

Well, here is one way to do it. Probably not the best way. Hell, probably not even a good way - but it works. :)

Edited by chris95219

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...