Jump to content

[solved] Rewriting basic AutoIt functions


Recommended Posts

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
Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

#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
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...