Jump to content

Recommended Posts

Posted

is it possible to run executable files inside gui?

for example, i want to put the yahoo messenger inside my gui so i dont need to switch tab all the time?

i always have lots of window tabs open when im online so i was just thinking if i can put them and run them all inside 1 window.

sorry if its sounds confusing hope you can understand.

thanks.

Sorry for being noob but... thanks to you im learned something new.
Posted (edited)

Yes this is possible :D

I found this post from user "eukalyptus" in german autoit forum.

I hope this help you.

http://www.autoit.de/index.php?page=Thread&postID=60950#post60950

This code starts notepad.exe into a autoit gui as a child window.

#include <WindowsConstants.au3>
Opt("TrayIconDebug",1)

$hGui = GUICreate("Test GUI", 320, 240)
GUISetState(@SW_HIDE, $hGui)

$hPid=Run(@SystemDir & 'notepad.exe',"", @SW_HIDE)
WinWait("[CLASS:Notepad]", "", 5)
$hChild = WinGetHandle("[CLASS:Notepad]", "")
$NEXSTYLE = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hChild, "int", 236)
DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hChild, "int", 236, "int", BitOR($NEXSTYLE[0], $WS_EX_MDICHILD))
DllCall("user32.dll", "int", "SetParent", "hwnd", $hChild, "hwnd", $hGui)
WinMove($hChild, "", 0, 0,320,240)
GUISetState(@SW_SHOW, $hGui)
WinSetState($hChild,"",@SW_SHOW)

While GUIGetMsg()<>-3
Sleep(1)
WEnd

Func OnAutoItExit()
ProcessClose($hPid)
EndFunc
Edited by Autolaser

Regards Autolaser

Posted

Yes this is possible :D

I found this post from user "eukalyptus" in german autoit forum.

I hope this help you.

http://www.autoit.de/index.php?page=Thread&postID=60950#post60950

This code starts notepad.exe into a autoit gui as a child window.

#include
Opt("TrayIconDebug",1)

$hGui = GUICreate("Test GUI", 320, 240)
GUISetState(@SW_HIDE, $hGui)

$hPid=Run(@SystemDir & 'notepad.exe',"", @SW_HIDE)
WinWait("[CLASS:Notepad]", "", 5)
$hChild = WinGetHandle("[CLASS:Notepad]", "")
$NEXSTYLE = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hChild, "int", 236)
DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hChild, "int", 236, "int", BitOR($NEXSTYLE[0], $WS_EX_MDICHILD))
DllCall("user32.dll", "int", "SetParent", "hwnd", $hChild, "hwnd", $hGui)
WinMove($hChild, "", 0, 0,320,240)
GUISetState(@SW_SHOW, $hGui)
WinSetState($hChild,"",@SW_SHOW)

While GUIGetMsg()<>-3
Sleep(1)
WEnd

Func OnAutoItExit()
ProcessClose($hPid)
EndFunc

You forgot the include...

#include <WindowsConstants.au3>
Opt("TrayIconDebug",1)

$hGui = GUICreate("Test GUI", 320, 240)
GUISetState(@SW_HIDE, $hGui)

$hPid=Run(@SystemDir & 'notepad.exe',"", @SW_HIDE)
WinWait("[CLASS:Notepad]", "", 5)
$hChild = WinGetHandle("[CLASS:Notepad]", "")
$NEXSTYLE = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hChild, "int", 236)
DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hChild, "int", 236, "int", BitOR($NEXSTYLE[0], $WS_EX_MDICHILD))
DllCall("user32.dll", "int", "SetParent", "hwnd", $hChild, "hwnd", $hGui)
WinMove($hChild, "", 0, 0,320,240)
GUISetState(@SW_SHOW, $hGui)
WinSetState($hChild,"",@SW_SHOW)

While GUIGetMsg()<>-3
    Sleep(1)
WEnd

Func OnAutoItExit()
    ProcessClose($hPid)
EndFunc

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Posted

As usual, AutoIt code tags have been broken. I'll look into it.

Jon, after upgrading the forum.

Thats 10 days ago, not sure if stuff still messed up.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

  • 6 years later...
Posted

Hi, i try to use this code to make my own program.

Coppy - Paste (copy paste is way i study code, to see what does what.)

Gui Test will open, but notepad wont.

Is there any error with it?

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollbarConstants.au3>
#include <GuiRichEdit.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <Misc.au3>
#include <ColorConstants.au3>
#include <WINAPI.au3>
#include <sendmessage.au3>
#include <FontConstants.au3>
#include <WindowsConstants.au3>
Opt("TrayIconDebug",1)

$hGui = GUICreate("Test GUI", 320, 240)
GUISetState(@SW_HIDE, $hGui)

$hPid=Run(@SystemDir & 'notepad.exe',"", @SW_HIDE)
WinWait("[CLASS:Notepad]", "", 5)
$hChild = WinGetHandle("[CLASS:Notepad]", "")
$NEXSTYLE = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hChild, "int", 236)
DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hChild, "int", 236, "int", BitOR($NEXSTYLE[0], $WS_EX_MDICHILD))
DllCall("user32.dll", "int", "SetParent", "hwnd", $hChild, "hwnd", $hGui)
WinMove($hChild, "", 0, 0,320,240)
GUISetState(@SW_SHOW, $hGui)
WinSetState($hChild,"",@SW_SHOW)

While GUIGetMsg()<>-3
    Sleep(1)
WEnd

Func OnAutoItExit()
    ProcessClose($hPid)
EndFunc

 

Posted (edited)

Using old code (without checking it) and resurrecting old thread will hardly give the right results Try this instead and check help file to understand the changes I applied.

#include <Constants.au3>
#include <GUIConstants.au3>
#include <WinAPISysWin.au3>
#include <WinAPIGdi.au3>

$hGui = GUICreate("Test GUI", 320, 240)
$idButton = GUICtrlCreateButton ("Quit", 130, 210, 60, 20) 
Run('notepad.exe',"", @SW_HIDE)
$hChild = WinWait("[CLASS:Notepad]", "", 5)
_WinAPI_SetWindowLong ($hChild, $GWL_STYLE,$WS_BORDER)
_WinAPI_SetWindowLong ($hChild, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hChild, $hGui)
WinMove($hChild, "", 0, 0,320,200)
GUISetState(@SW_SHOW, $hGui)
WinSetState($hChild,"",@SW_SHOW)
_WinAPI_RedrawWindow ($hGUI)

While True
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $idButton
      ExitLoop
  EndSwitch
WEnd

GUIDelete ($hGui)

 

Edited by Nine

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