Sign in to follow this  
Followers 0
amokoura

[solved] Rewriting basic AutoIt functions

16 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Wait a minute, there isn't any source available?? Where can I get?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

http://www.autoitscript.com/forum/index.php?showtopic=8389

It's a sticky at the top of this forum. (C++)

Yeah I checked it out but there aren't any source files in the mentioned site.

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

Edited by amokoura

Share this post


Link to post
Share on other sites

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.

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

I never said it was hard. I just said it was messy.

Share this post


Link to post
Share on other sites

#14 ·  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

Share this post


Link to post
Share on other sites

Why are you using pointer-to-struct?

Share this post


Link to post
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
Sign in to follow this  
Followers 0