Jump to content

Determine whether .exe is GUI or Console app?

Recommended Posts

I have a rather odd problem that I'm hoping someone can help me out with. How I can tell from within AutoIt whether a given .exe file is a console or GUI application?

I searched the forum and found several dicussions on the technical differences between the two, but I haven't found anything to help me actually do it in AutoIt. Any suggestions?


Link to post
Share on other sites
  • Moderators

The only simple way to do this is by using WinExists().

I am not aware of any other way (a macro or something) that gives you such an ability.

WinExists() would work, but what happens if the window is hidden?...

If you know the 'Class' names of the programs GUI(s), you could always find them scribing for a control handle.

While 1
    $FindGui = ControlGetHandle('classname=AutoIt v3 GUI', "", "")
    If $FindGui <> "" Then MsgBox(48, "Found", "There is an AuotIt GUI running")

***Note... Most programs always have the same Class... the Afx: class(s) change the last 6 characters, but if you know the first so many... you can find them... but you could run into errors with them.

Generally with the above method... no window is truly 'hidden'.

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 post
Share on other sites

erebus and SmOke, thanks for the suggestions, but I actually need to determine this before I run the program.

w0uter, can offer any tips on how to do that? I've actually tried this approach, but failed pretty miserably. Specifically, I tried using the Binary Read/Write UDFs provided by Larry in another thread, but couldn't figure out how exactly to use it. The example that was provided didn't work.

Link to post
Share on other sites

And I imagine that you also want to know if a random (and not standard) exe is a GUI or console application before running it, right?

I'm not sure what you mean by a random .exe, but yes, I need to know if a given .exe that is passed to my AutoIt program is a GUI or console application. The reason for this is that I need to treat it differently depending on what kind of program it is. Currently, I have a checkbox in the GUI to allow the user to select whether or not it's a console app. It works, but it's kind of clunky. Auto-detecting this would help make this more user-friendly. Edited by nitro322
Link to post
Share on other sites

Yes I agree with you and I understand the reason you want to do it. Of course everybody that wants to do something abnormal (as far as the capabilities of AU3 is concerned) doesn't mean that it is not necessary or useful.

However I cannot see how you can determinate this except of the idea that w0uter dropped on the table.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...