Jump to content
dieterhatn

Run Program inside GUI

Recommended Posts

dieterhatn

Hi there, Is there a way to run an external program inside my Autoit GUI? Or even two programs in one GUI? thanks

Share this post


Link to post
Share on other sites
MikahS

You mean like creating a button and on pressing it, it will run another program?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
dieterhatn

 

You mean like creating a button and on pressing it, it will run another program?

 

I meant if you run a program within your script, the window will be attached to your gui.

Share this post


Link to post
Share on other sites
MikahS

It would have to be attached manually by you through parent - child settings. I'm positive though if you just ran a random program from inside the GUI like notepad, it will not be attached to the GUI automatically, but using something like this:

$Form1 = GUICreate("Attached window!", 629, 437, 314, 132, default,default, WinGetHandle("AutoIt Help")) ; as you can see we get the handle and attach it as the parent to the created GUI window -- essentially making our GUI created a child GUI
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
dieterhatn

It would have to be attached manually by you through parent - child settings. I'm positive though if you just ran a random program from inside the GUI like notepad, it will not be attached to the GUI automatically, but using something like this:

$Form1 = GUICreate("Attached window!", 629, 437, 314, 132, default,default, WinGetHandle("AutoIt Help")) ; as you can see we get the handle and attach it as the parent to the created GUI window -- essentially making our GUI created a child GUI

Isn't it exactly vice-versa? The doc says that if you define a Window Handle, the autoit GUI will become a child of the window you define.

Share this post


Link to post
Share on other sites
MikahS

Yes, it is somewhat the other way around, my apologies. :sweating:

Here is something that can the right way round:

#include <WinAPI.au3>

_WinAPI_SetParent(WinGetHandle("whatever window you want to make a child here", $hWnd) ; first param is the child window or the window we want to make a child and the second param is our created GUI
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
dieterhatn

That somewhat does what i want, but im experiencing some problems.

Im trying arround with a simple GUI and a notepad window i want to attach, but whenever I set the parent the notepad window just disappears.

The process is still running but its not visible anymore.

Share this post


Link to post
Share on other sites
MikahS

works for me with this script:

#include <WinAPI.au3>
#include <GUIConstants.au3>

Local $msg, $hwnd, $Nhandle

$hwnd = GUICreate("hello")
GUISetState()
Run("notepad")

$Nhandle = WinGetHandle("Notepad")

_WinAPI_SetParent($Nhandle, $hwnd)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
dieterhatn

works for me with this script:

#include &lt;WinAPI.au3&gt;#include &lt;GUIConstants.au3&gt;Local $msg, $hwnd, $Nhandle$hwnd = GUICreate("hello")GUISetState()Run("notepad")$Nhandle = WinGetHandle("Notepad")_WinAPI_SetParent($Nhandle, $hwnd)While 1&nbsp;&nbsp; &nbsp;$msg = GUIGetMsg()&nbsp;&nbsp; &nbsp;Switch $msg&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Case $GUI_EVENT_CLOSE&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Exit&nbsp;&nbsp; &nbsp;EndSwitchWEnd

What exactly happens when you run this code? for me nothing happens :/

Share this post


Link to post
Share on other sites
JohnOne

#include <WinAPI.au3>
#include <GUIConstants.au3>

Local $msg, $hwnd, $Nhandle

$hwnd = GUICreate("hello")
GUISetState()
$pid = Run("notepad", "", @SW_HIDE)
ProcessWait($pid)
$Nhandle = WinGetHandle("Untitled - Notepad")

_WinAPI_SetParent($Nhandle, $hwnd)
_WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
WinMove($Nhandle, "", 0, 0)

While ProcessExists($pid)
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ProcessClose($pid)
    EndSwitch
WEnd

Edited by JohnOne
  • Like 1

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
MikahS

What exactly happens when you run this code? for me nothing happens :/

You have not formatted it..

 

#include <WinAPI.au3>
#include <GUIConstants.au3>

Local $msg, $hwnd, $Nhandle

$hwnd = GUICreate("hello")
GUISetState()
$pid = Run("notepad", "", @SW_HIDE)
ProcessWait($pid)
$Nhandle = WinGetHandle("Untitled - Notepad")

_WinAPI_SetParent($Nhandle, $hwnd)
_WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
WinMove($Nhandle, "", 0, 0)

While ProcessExists($pid)
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ProcessClose($pid)
    EndSwitch
WEnd

 

Very cool. Just to understand you made the notepad window a pop-up and put it inside the GUI created? I like this.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
MikahS

I think it's better than what OP wanted ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Alwaysconfused

Currently trying to do something similar. I'm looking to attach a blank GUI around the notepad. Instead of the script running the notepad, I'm trying to make it attach a GUI around a notepad i have opened manually. Played about with the script above and this is what i have came up with, it runs, works but then comes up an error. Would it be possible to advise on my mistake, thanks in advance.

test.au3

Share this post


Link to post
Share on other sites
careca

I'd say instead of reviving a 4yo thread, create a new one for your issue.


Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
Alwaysconfused

Most probably a better idea. Thanks

 

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

×