Sign in to follow this  
Followers 0
armoros

2 scripts in 2 TabSheets in same GUI ?

3 posts in this topic

#1 ·  Posted (edited)

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]

Share this post


Link to post
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

Share this post


Link to post
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]

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
Sign in to follow this  
Followers 0

  • Similar Content

    • luckyluke
      By luckyluke
      Hello,
      Im trying to read the output from CMD using Dllcall, here is my code:
      #include <WinAPI.au3> #include <array.au3> Global Const $STD_OUTPUT_HANDLE = -11 Global Const $_CONSOLE_SCREEN_BUFFER_INFO = _ "struct;int dwSizeX;" & _ "short dwSizeY;" & _ "short dwCursorPositionX;" & _ "short dwCursorPositionY;" & _ "short wAttributes;" & _ "short Left;" & _ "short Top;" & _ "short Right;" & _ "short Bottom;" & _ "short dwMaximumWindowSizeX;" & _ "short dwMaximumWindowSizeY;endstruct" $pCmd = Run( "cmd.exe" ) Sleep(1000) $hCmd = WinGetHandle("") ConsoleWrite('handle:' & $hCmd & @CRLF) $aRet = DllCall("kernel32.dll", "int", "AttachConsole", "dword", $pCmd) ;_ArrayDisplay($aRet) If $aRet[0] <> 0 Then $vHandle_data='' $vHandle='' $vHandle_data = DllStructCreate($_CONSOLE_SCREEN_BUFFER_INFO) ; Screen Buffer structure $aRet1 = DllCall("kernel32.dll", "hwnd", "GetStdHandle", "dword", $STD_OUTPUT_HANDLE) if not @error Then $vHandle = $aRet1[0] $aRet = DllCall("kernel32.dll", "int", "GetConsoleScreenBufferInfo", "hwnd", $vHandle, _ "ptr", $vHandle_data) MsgBox(0, '1',DllStructGetData($vHandle_data, 'dwSizeX') & _WinAPI_GetLastErrorMessage()) EndIf It did not work, i got the message 'The handle is invalid'. Please help?
      Thank you in advance!
    • Cipactli
      By Cipactli
      Have anybody succesfully played around with libmpv for mpv player to embed the player in gui ?
      Example of child gui.
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $hGui, $mpv_pid Local $sStream = "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4" $hGui = GUICreate("MPV Test", 640, 360, -1, -1) GUISetState(@SW_SHOW) $mpv_pid = Run(@ScriptDir & '\mpv.exe --wid="' & $hGui & '" "' & $sStream & '"') While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd MPV Player and Libmpv can be downloaded at https://mpv.srsfckn.biz/
       
      Best Regards
      -C
    • mihaijulien
      By mihaijulien
      Hello,
      I compiled a script I made that takes a command line parameter (the version of a .msi installer) when launched. The script was compiled with the /console option. The script (.au3) works fine but the executable returns  the following error:  
      Error: array variable has incorrect number of subscripts or subscript dimension range exceeded  
    • fosil
      By fosil
      Hi everyone.

      I'm currently working a program that constantly prints out log files through "consolewrite" and the "#AutoIt3Wrapper_Change2CUI=y" wrapper.

      Part of this program requires me to run a batch script.

      My issue is the batch script launches from the same window as consolewrite. I need the batch file to be launched through a different window as currently this causes an issue with the logs (which need to be very precise) but also causes the batch file to produce some funny behavior...

      Does anyone know how I can force the file to run on a second DOS window?

      Thanks in advance!!!
       
      Edit: Im using the "run" command if that helps. I tried "shellexecute" but that seemed to not launch the batch scripts at all.
    • Baboo85
      By Baboo85
      Hi all,
      I need to start a script that include:
      - admin privileges
      - multiple cmd commands
      - no bat, no exe, no tmp files created anywhere (especially in the user temp folder)
      In a bat file it would be simple, but users shouldn't see what commands I'm sending.
      Example of the script:
      echo off cls echo. echo I AM A TOOL echo. echo NOTE: echo - note 1 echo - note 2 echo - etc set USER1=0 set COMPUTER1=0 if /i %username% equ user.user ( set USER1=1 set COMPUTER1=1 ) if /i %username% equ another.user set USER1=1 if /i %computername% equ notebook set COMPUTER1=1 if %USER1% EQU 1 ( if %COMPUTER1% EQU 1 ( reg delete "HKLM\SOFTWARE\blablabla" /f ) else ( echo Computer not authorized. Contact assistance.) ) else ( echo User not authorized. Contact assistance.) echo. pause exit With the send("") is a disaster.
      I'm a noob here, so what can I do?
       
      EDIT: OR ELSE I explain the situation and what I need, so if there is a simple solution I can use that.
       
      SITUATION: our domain users have Users rights on the machine. Some of them need administrator rights.
      We create a local user with administrator rights, so that the users must insert username and password when asked to run something with administrator rights.
      We have an internal domain group policy that blocks EXE, BAT, COM, TMP files from the user local temp directory, for a security reason (malware). That also blocks most software installation.
      But some users are often out of office, away from workplace and in another country, they need a complete control on their computers.
       
      WHAT I NEED: I need to check the username and the computer name. If the username is the one with local administrator rights and the computer name is a computer that is qualified to temporary remove the policy, then I need to execute a REG DELETE command with administrator rights.
       
      I hope I explained myself.
       
      Thank you very much.