Sign in to follow this  
Followers 0
engjcowi

[SOLVED] Creating a console

16 posts in this topic

#1 ·  Posted (edited)

Hi guys

Firstly i apologise if this is a dumb question but its late and ive been wrecking my brain. Can anyone point me in the direction to creat an output console so th euser can see exactly whats goin on. I dont know if anyone remembers dvd decrypter but that had an output console that displayed the info on where the program was upto and what is was doing.

It just needs to be small but scrollable once completed.

Thanks

Jamie

Edited by engjcowi

Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites



Hi enaiman

Thats for the suggestion. Ive tried creating a form and puttin in an edit box called $comconsole and then used the command

GUICtrlSetData($comconsole, "this has updated")
to update the information going to the edit box. My problem is that when i use the same command up to add further information such as using a command button it just overwrites whats already there.

is there anyway i can tell it to keep whats there and add to a new line only please?


Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites

Try this - Untested:

GUICtrlSetData($comconsole, GUICtrlRead($comconsole) & "this has updated")

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

DllCall("kernel32", "int", "AllocConsole")

Share this post


Link to post
Share on other sites

Nice tip jaberwocky, I've never used the default value parameter so I had forgotten about how it works in an edit control.


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

Jaberwocky thanks very much i didnt see that myself lol. All is now right with thte world and working and ive included an example below in case anyone would like to see.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 658, 386, 302, 218)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form2Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form2Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form2Restore")
$Edit1 = GUICtrlCreateEdit("", 24, 48, 353, 217)
GUICtrlSetData(-1, "Edit1" & @CRLF)
GUICtrlSetOnEvent(-1, "Edit1Change")
$Button1 = GUICtrlCreateButton("Button1", 160, 304, 153, 41, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1

    Sleep(100)
WEnd

Func Button1Click()
GUICtrlSetData($edit1, "this has updated" & @CRLF, ' ')


EndFunc
Func Edit1Change()

EndFunc
Func Form2Close()
exit
EndFunc
Func Form2Maximize()

EndFunc
Func Form2Minimize()

EndFunc
Func Form2Restore()

EndFunc

Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites

Hi

sorry to be a pain. Ive created the following program using the bits of code above to run mkisofs. Ther is 2 attempts below, 1 is readt to run, the other is blocked by #cs and #ce so just delete the other whilw wend loop then use the commented out 1 to try. The problem is that i use ctupdate in the directory which has lots of lists with long fielnames and after a very short period the the output just stops (see attached pic) but the program continues behind the scenes. If i remove the folder containing the files then it reads the percentage fine. Is there a limit to the information a edit box can contain?

Hope someone can help

Thanks

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 623, 451, 323, 153)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")

$Button1 = GUICtrlCreateButton("Exit", 176, 360, 265, 73, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Comconsole = GUICtrlCreateEdit("Console", 56, 32, 529, 297, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUICtrlSetData(-1, "Comconsole")
GUICtrlSetOnEvent(-1, "ComconsoleChange")
$Label1 = GUICtrlCreateLabel("ISO CREATION ", 264, 8, 83, 17)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

FileChangeDir(@ScriptDir & "\files\")


#cs
$pid = Run('mkisofs.exe -l -J -r -V "APHC" -o "' & @DesktopDir & '\APHC.iso" ' & '"' & @ScriptDir & '"', "", @SW_hide, 0x8) ; 0x8 = $STDERR_MERGED (StdOutRead receives Stdout and stderr)
$sOutput = ''
While 1

    Sleep(50)
    $sRead = StdoutRead($pid)
    If @error <> 0 Then ExitLoop
    $sOutput &= $sRead
    ;oolTip($sOutput)
    GUICtrlSetData($Comconsole, $sOutput, ' ')
WEnd
StdioClose($pid)
ToolTip("")
MsgBox(0, 'Finished', $sOutput)

#ce





$foo = Run('mkisofs.exe -l -J -r -V "APHC" -o"' & @DesktopDir & '\APHC.iso" ' & '"' & @ScriptDir & '"', "", @SW_Hide, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $line = StderrRead($foo)
    If @error Then ExitLoop
        $message = ""
    $message = $line
    GUICtrlSetData($Comconsole, $message, ' ')
Wend
MsgBox(0, 'ISO Created', $message)
StdioClose($line)





Func Button1Click()
ProcessClose("mkisofs.exe")
exit
EndFunc
Func ComconsoleChange()

EndFunc
Func Form2Close()
ProcessClose("mkisofs.exe")
exit
EndFunc

Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Add this line, after you create the edit box:

GUICtrlSetLimit(-1, 9999999)

@RichardRobertson

How about an UDF around that? ;)

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Why do you need a UDF? It's a single line. After you allocate it, you just use ConsoleWrite to send data to it.

Share this post


Link to post
Share on other sites

@Enaiman

Thanks thats done the trick.

Richard Robertson - i never knew that either thanks


Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites

@RichardRobertson

Why do you need a UDF? It's a single line. After you allocate it, you just use ConsoleWrite to send data to it.

So simple? - wow, I do need to have a closer look at that ;)

Thanks alot.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Hmm, I too was curious about this one-API-call-does-it-all, so I tested it out. But alas, it doesn't work with ConsoleWrite.

Here's the way I got it to work for me:

DllCall("kernel32.dll","bool","AllocConsole")
$hConsole=DllCall("kernel32.dll","handle","GetStdHandle","int",-11)
ConsoleWrite("Console handle:"&$hConsole[0]&", Error:"&@error&@CRLF)
$aRet=DllCall("kernel32.dll","bool","WriteConsoleW","handle",$hConsole[0],"wstr","Testing123","dword",10,"dword*",0,"ptr",0)
MsgBox(0,"see any consoles?","look harder!")

Note that WriteConsole must be called with a handle retrieved through GetStdHandle, and the program must not be run from SciTE (otherwise you won't get a valid handle).

Share this post


Link to post
Share on other sites

@Ascend4nt

Thank you very much for your input.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Well I've never tried using the console with AutoIt. I just knew the function.

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