Jump to content
Sign in to follow this  
smcombs

Command Line Interface in gui

Recommended Posts

smcombs

Well I am trying to make my own console program because the developers of Console2Beta dont seem to be updating or fixing old problems. I know there is a better way to do this but right now this is my code:

CODE
#Include <Misc.au3>

#include <Date.au3>

#Include <File.au3>

#Include <Array.au3>

#Include <Guitab.au3>

#Include <GuiEdit.au3>

#Include <GuiRebar.au3>

#Include <GuiButton.au3>

#Include <GuiListView.au3>

#include <GuiToolbar.au3>

#include <TabConstants.au3>

#include <GuiConstants.au3>

#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

#include <ButtonConstants.au3>

#include <WindowsConstants.au3>

#NoTrayIcon

HotKeySet("{ESC}","Terminate")

Global $btn,$t,$b, $rdo, $chk, $iMemo, $hCtrl, $edit, $index,$tab

$index = 0

$gui1 = GUICreate("Console", 900, 900, -1, -1,$WS_CLIPCHILDREN)

$tab = GUICtrlCreateTab(10,60,850,800)

;$item = GUICtrlCreateTabItem("test");_GUICtrlTab_InsertItem($tab,$index,"test")

$button = GUICtrlCreateButton("Button1",0,860,20,20)

$height = @DesktopHeight - 30

GuiSetState(@SW_SHOW)

$btncreate = False

$btnclicked = False

$var = WinList()

$location = 3

GUIRegisterMsg($WM_COMMAND,"WM_COMMAND")

GUIRegisterMsg($WM_NOTIFY,"WM_NOTIFY")

Run("cmd.exe /k COLOR 07")

Sleep(1000)

$handle = WinGetHandle("Administrator: C:\Windows\system32\cmd.exe","")

$gui = WinGetHandle("Console","")

$handle1 = ControlGetHandle("Console","","[CLASS:SysTabControl32; INSTANCE:1]")

_WinAPI_SetParent($handle,$handle1)

Sleep(1000)

WinMove("Administrator: C:\Windows\system32\cmd.exe","",0,0)

Do

Sleep(100)

Until GUIGetMsg() = $gui_EVENT_CLOSE

;Gets all visible windows

Func IsVisible($handle)

If BitAnd( WinGetState($handle), 2 ) Then

Return 1

Else

Return 0

EndIf

EndFunc

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)

#forceref $hWnd, $Msg, $wParam

Local Const $BCN_HOTITEMCHANGE = -1249

Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)

Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")

Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")

Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")

Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")

Local $sText = ""

Switch $nNotifyCode

Case $BCN_HOTITEMCHANGE ; Win XP and Above

If BitAND($dwFlags, 0x10) = 0x10 Then

;MsgBox(0,"","test")

$sText = "$BCN_HOTITEMCHANGE - Entering: " & @CRLF

ElseIf BitAND($dwFlags, 0x20) = 0x20 Then

$sText = "$BCN_HOTITEMCHANGE - Leaving: " & @CRLF

EndIf

EndSwitch

Return $GUI_RUNDEFMSG

EndFunc ;==>WM_NOTIFY

; React on a button click

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

#forceref $hWnd, $Msg

Local $nNotifyCode = BitShift($wParam, 16)

Local $nID = BitAND($wParam, 0x0000FFFF)

Local $hCtrl = $lParam

Local $sText = ""

Switch $nNotifyCode

Case $BN_CLICKED

state()

Case $BN_PAINT

$sText = "$BN_PAINT" & @CRLF

Case $BN_PUSHED, $BN_HILITE

$sText = "$BN_PUSHED, $BN_HILITE" & @CRLF

MsgBox(0,"","test1")

Case $BN_UNPUSHED, $BN_UNHILITE

$sText = "$BN_UNPUSHED" & @CRLF

Case $BN_DISABLE

$sText = "$BN_DISABLE" & @CRLF

Case $BN_DBLCLK, $BN_DOUBLECLICKED

$sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF

Case $BN_SETFOCUS

$sText = "$BN_SETFOCUS" & @CRLF

Case $BN_KILLFOCUS

$sText = "$BN_KILLFOCUS" & @CRLF

EndSwitch

Return 0 ; Only workout clicking on the button

Return $GUI_RUNDEFMSG

EndFunc ;==>WM_COMMAND

Func state()

_GUICtrlTab_InsertItem($tab,$index,"test")

$sel = _GUICtrlTab_GetCurSel($tab)

MsgBox(0,"",$sel)

$index = $index + 1

EndFunc

Func Terminate()

ProcessClose("cmd.exe")

Exit

EndFunc

My question is can I use ObjCreate and actually create my own command line object(if it is an object???) instead of running the .exe itself and putting it in the gui. I am running x64 bit Vista right now. You may have to change the window titles for the wingethandle and controlgethandle. I was going to try and look at Console's source but I really want to try and work this out on my own. Thanks

Share this post


Link to post
Share on other sites
nguyenbason

Run("cmd.exe /k COLOR 07")
Sleep(1000)
$handle = WinGetHandle("Administrator: C:\Windows\system32\cmd.exe","")oÝ÷ Øz0q©ò¢è¶§vW¨}§±yø¥y«­¢+ØÀÌØíIÕ¸ôIÕ¸ ÅÕ½Ðíµ¹á½¬
=1=HÀÜÅÕ½Ðì¤)M±À ÄÀÀÀ¤(ÀÌØí¡¹±ô]¥¹Ñ!¹± ÀÌØíIÕ¸°ÅÕ½ÐìÅÕ½Ðì¤


UnderWorldVN- Just play the way you like it

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.