Jump to content

2 scripts in 2 TabSheets in same GUI ?


Recommended Posts

Probably the title is not correct,but here is what i would like to learn..

1) I have 2 scripts from other users that embed a cmd window in their own guis.

2) I made a gui with 2 tab sheets and i want to put the one script in one tabsheet and the other script to the other tabsheet. (cmd's functions and buttons)

is that possible ?

this is a simple gui i made with koda post-71357-0-37068200-1334173801_thumb.p

This is the code

#include
#include
#include
#include
#include
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 627, 416, 192, 114)
$Tab1 = GUICtrlCreateTab(8, 16, 609, 361)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Button1 = GUICtrlCreateButton("Button1", 16, 328, 75, 25)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Button2 = GUICtrlCreateButton("Button2", 24, 344, 75, 25)
GUICtrlCreateTabItem("")
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

This is the 1 script by autoit/user Country73

#include
#include
#include
Opt("GUIOnEventMode", 1)
Global  $MAIN, $CMD_WINDOW
Global  $IP_CONFIG, $OTHER, $BUTT_CLOSE
#Region ### START Koda GUI section ### Form=
$MAIN = GUICreate("CMD FUNCTIONS", 623, 449, 192, 114)
$CMD_WINDOW = GUICtrlCreateEdit("", 10, 10, 600, 289, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$WS_VSCROLL))
    GUICtrlSetFont($CMD_WINDOW, 12, 800, 0, "Times New Roman")
    GUICtrlSetColor($CMD_WINDOW, 0xFFFFFF)
    GUICtrlSetBkColor($CMD_WINDOW, 0x000000)
$IP_CONFIG = GUICtrlCreateButton("IP_CONFIG", 10, 310, 75, 25)
    GUICtrlSetOnEvent($IP_CONFIG, "_IP_CONFIGClick")
$OTHER = GUICtrlCreateButton("OTHER", 95, 310, 75, 25)
    GUICtrlSetOnEvent($OTHER, "_OTHERClick")
$BUTT_CLOSE = GUICtrlCreateButton("EXIT", 535, 310, 75, 25)
    GUICtrlSetOnEvent($BUTT_CLOSE, "_ExitNow")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    Sleep(100)
WEnd
Func _ExitNow()
    Exit
EndFunc
Func _IP_CONFIGClick()
    Local $foo = Run(@ComSpec & " /c " & "IPCONFIG /ALL",@SystemDir,@SW_HIDE,$STDOUT_CHILD)
    Local $line
    While 1
        $line = StdoutRead($foo)
        If @error Then ExitLoop
        If Not $line = "" Then GUICtrlSetData($CMD_WINDOW,$line)
    WEnd
EndFunc
Func _OTHERClick()
    GUICtrlSetData($CMD_WINDOW,"Create a CMD Function to be ran here")
EndFunc

And this is the 2 script by autoit/user MrCreatoR (4 years old but works)

#include
Opt("GUIOnEventMode", 1)
Global $Init_Dir = "C:"
$Main_GUI = GUICreate("Embed Command Line Prompt", 550, 300, 10, 10)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUIRegisterMsg(0xF, "WM_PAINT")
$iCmd_PID = Run(@ComSpec & " /k CD " & $Init_Dir, "", @SW_HIDE)
ProcessWait($iCmd_PID)
$Embed_hWnd = _GetHWndByPID($iCmd_PID)
WinMove($Embed_hWnd, "", -2, -23, 549, 342)
WinSetState($Embed_hWnd, "", @SW_SHOWMINIMIZED)
GUISetState(@SW_SHOW, $Main_GUI)
DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $Embed_hWnd, "hwnd", $Main_GUI)

While 1
    Sleep(100)
    If WinActive($Main_GUI) Then WinActivate($Embed_hWnd)
WEnd
Func Quit()
    ProcessClose($iCmd_PID)
    Exit
EndFunc
Func _GetHWndByPID($iPID)
    Local $aWinList = WinList()
    For $i = 1 To UBound($aWinList)-1
        If WinGetProcess($aWinList[$i][1]) = $iPID Then Return $aWinList[$i][1]
    Next
    Return 0
EndFunc
Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "ptr", 0, "int", 0)
EndFunc

Thanks in advance

Edited by armoros

[font="verdana, geneva, sans-serif"] [/font]

Link to comment
Share on other sites

You'd need to merge the 2 scripts together and have the controls etc. of one on one tab, and the rest on the other tab. You can't just embed the 2 scripts together into one GUI.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You'd need to merge the 2 scripts together and have the controls etc. of one on one tab, and the rest on the other tab. You can't just embed the 2 scripts together into one GUI.

Thank you BrewManNH

When you say merge you mean i ll take what i need from the 2 scripts and make a new one correct.

I'll tryit thank you..

[font="verdana, geneva, sans-serif"] [/font]

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

×
×
  • Create New...