Jump to content

Run Program inside GUI


dieterhatn
 Share

Recommended Posts

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

#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

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 4 years later...

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

Link to comment
Share on other sites

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

Spoiler

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.

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

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