Jump to content

autoit console


Recommended Posts

Hi,

I'm making a GUI controled Console to test my/your autoit commands.

but i'm kinda stuck on the last point.

"execute autoit command"

This is the code

;Fileinstallers
FileInstall("C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\AutoIt.chm",@ScriptDir & "\AutoIt.chm")
FileInstall("C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\AutoIt3Help.exe",@ScriptDir & "\AutoIt3Help.exe")

;Creation of the GUI
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
GUICreate("Console")
$Mfile = GUICtrlCreateMenu ( "&File")
$MfileS = GUICtrlCreateMenuitem ( "&Save",$Mfile)
$input=GUICtrlCreateEdit ("",10,280,360,97,$ES_AUTOVSCROLL+$WS_VSCROLL)
$output=GUICtrlCreateEdit ("====================== Console Output ========================"&@CRLF,10,10,380,200,$ES_AUTOVSCROLL+$WS_VSCROLL+$ES_READONLY)
$Button1 = GUICtrlCreateButton("OK",370,280,25,100,)
GUISetOnEvent(-1, "_Command")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState ()
HotKeySet("{F1}","_help")
HotKeySet("{Enter}","_Command")

;Looping script
while 1
    
WEnd

;Functions
Func _Exit()
    If @GUI_CTRLID = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
EndFunc
Func _help()
    Run (@scriptDir & "\AutoIt3Help.exe")
EndFunc

;Run command
Func _Command()
    global $command = (GUICtrlRead ($input))
    GUICtrlSetData ($output,(_Go()&@CRLF),1)
EndFunc
Func _Go()
    Return ($command)
EndFunc

i hope you guys wanna help me.

P.S. the installed files are found in the autoit folder.

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

Hi,

Perhaps this is an stupid question, but what will the purpose be of your tool/program ?

Andre

Edited by Andre
What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

Hi,

Back again.

To prevent a 100% cpu usage make your waiting loop like this :

While 1

Sleep(5)

Wend

Andre

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

thanks for the tip,

but i stil need to know how i can let the script execute the command.

(u could use the command for real-time control over windows.)

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

as far as i know u will have to save the file and then runit with autoit3.exe

So real-time no !

Andre

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

ur opinion

but can somebody pleas help me with my problem.

this IS the support forum not the scrap forum.

you your just spamming

Edited by zeroZshadow
*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

Hi..

..IMHO Andre already posted a solution to your problem..

..so you let autoit save the commands in a file, and the run it with autoit3.exe ..

something like:

FileWriteLine("test.au3","MsgBox(0,"test","testing",20)")
Run("Autoit3.exe test.au3")

(untested)

..and.. please have a look about spelling.. so its easier to read your posts :-)

mfg Domonoky

Link to comment
Share on other sites

FileWriteLine("test.au3","MsgBox(0,"test","testing",20)")
Run("Autoit3.exe test.au3")

<{POST_SNAPBACK}>

How could that work? AutoIt doesn´t know when the String does end.

FileWriteLine("test.au3",'MsgBox(0,"test","testing",20)')
Run("Autoit3.exe test.au3")

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to comment
Share on other sites

I saw that to....

I made a little update.

the only problem i have now is that the made script can't return the output to the other script.

I tryed the #include command but then you need to enter the command

re-run the script and press enter again.

Like a very heavy LAG.

;Fileinstallers
FileInstall("C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\AutoIt.chm",@ScriptDir & "\AutoIt.chm")
FileInstall("C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\AutoIt3Help.exe",@ScriptDir & "\AutoIt3Help.exe")

;Creation of the GUI
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
GUICreate("Console")
$Mfile = GUICtrlCreateMenu ( "&File")
$MfileS = GUICtrlCreateMenuitem ( "&Save",$Mfile)
$input=GUICtrlCreateEdit ("",10,280,360,97,$ES_AUTOVSCROLL+$WS_VSCROLL)
$output=GUICtrlCreateEdit ("====================== Console Output ========================"&@CRLF,10,10,380,200,$ES_AUTOVSCROLL+$WS_VSCROLL+$ES_READONLY)
$Button1 = GUICtrlCreateButton("OK",370,280,25,100)
GUISetOnEvent($Button1, "_Command")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState ()
HotKeySet("{F1}","_help")
HotKeySet("{Enter}","_Command")

;Looping script
while 1
sleep(5)
WEnd

;Functions
Func _Exit()
    If @GUI_CTRLID = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
EndFunc
Func _help()
    Run (@scriptDir & "\AutoIt3Help.exe")
EndFunc

;Run command
Func _Command()
    global $command = (GUICtrlRead ($input))
    $file = FileOpen ( "input.au3",2)
    FileWriteLine("input.au3","Global $result = "&$command&@CRLF&"sleep(500)")
    Fileclose($file)
    Run("autoit3.exe input.au3")
    sleep(500)
    GUICtrlSetData ($output,($result&@CRLF),1)
EndFunc

thanks for your support so far!

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

ur opinion

but can somebody pleas help me with my problem.

this IS the support forum not the scrap forum.

you your just spamming

<{POST_SNAPBACK}>

I 'm just trying to help u.

Don't say i'm just spamming ! :lmao:

Andre

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

Use my _Execute UDF, available here:

http://www.autoitscript.com/forum/index.php?showtopic=7607

I updated several things and added my UDF.

It believe it works now.

;Fileinstallers
FileInstall("C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\AutoIt.chm",@ScriptDir & "\AutoIt.chm")
FileInstall("C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\AutoIt3Help.exe",@ScriptDir & "\AutoIt3Help.exe")

;Creation of the GUI
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
GUICreate("Console")
$Mfile = GUICtrlCreateMenu ( "&File")
$MfileS = GUICtrlCreateMenuitem ( "&Save",$Mfile)
$input=GUICtrlCreateEdit ('MsgBox(64, "Test", "1234")',10,280,360,97,$ES_AUTOVSCROLL+$WS_VSCROLL)
$output=GUICtrlCreateEdit ("====================== Console Output ========================"&@CRLF,10,10,380,200,$ES_AUTOVSCROLL+$WS_VSCROLL+$ES_READONLY)
$Button1 = GUICtrlCreateButton("OK",370,280,25,100,)
GUICtrlSetOnEvent($Button1, "_Command")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState ()
HotKeySet("{F1}","_help")
HotKeySet("{Enter}","_Command")

;Looping script
while 1
    Sleep(100)
WEnd

;Functions
Func _Exit()
    If @GUI_CTRLID = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
EndFunc
Func _help()
    Run (@scriptDir & "\AutoIt3Help.exe")
EndFunc

;Run command
Func _Command()
     Local $command
    $command = GUICtrlRead ($input)
    GUICtrlSetData ($output, $command & @CRLF, 1)
    _Execute ($command)
EndFunc

Func _Execute ($LineofCode, $rUsername = "", $rDomain = "", $rPassword = "", $rOpts = 1)
   Local $PrevSett, $RetVal, $RunAs = 0
   $LineofCode = StringReplace($LineofCode, '"', '""')
   If @NumParams > 1 Then
      If @OSVersion = "WIN_XP" OR @OSVersion = "WIN_2000" Then $RunAs = 1
   EndIf
   If $RunAs Then
      If $rUsername = "" Then $rUsername = @UserName
      If $rDomain = "" Then $rDomain = @ComputerName
      If $rPassword = "" Then
         $rPassword = InputBox('_Execute', 'Enter the password for username "' & $rUsername & '"')
         If @error Then Return 1
      EndIf
      $PrevSett = Opt("RunErrorsFatal", 0)
      RunAsSet($rUsername, $rDomain, $rPassword, $rOpts)
   EndIf
   $RetVal = RunWait(@AutoItExe & ' /c "Exit(' & $LineofCode & ')"', @WorkingDir)
   If @error Then
      MsgBox(16, "_Execute Error", "Error: Incorrect password or unknown username.")
      Return 1
   ElseIf $RunAs Then
      RunAsSet()
      Opt("RunErrorsFatal", $PrevSett)
   EndIf
   Return $RetVal
EndFunc
Link to comment
Share on other sites

mmm...

i don't think you understood my problem(not that i don't thank you for help)

i'll explane my program:

1. you can type any autoit command in the input box

2. press enter or push the button (button doesn't work??)

3. the command wil be run and the return wil be written in the output box. (not the command itself!)

4in the later version it wil rember all of the returns so you can control an window by this console.

example.

1. WinSetTitle ( "test", "", "test2" )

so you won't need to make new programs.

you can just test ur idea right away

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

Use the updated script I posted.

1. Works

2. Use the $BS_DEFPUSHBUTTON style to make the button respond to the enter key. And remove the enter hotkey from the script.

3. I didn't know. Change

Func _Command()
     Local $command
    $command = GUICtrlRead ($input)
    GUICtrlSetData ($output, $command & @CRLF, 1)
    _Execute ($command)
EndFunc

to

Func _Command()
     Local $command, $RetVal
    $command = GUICtrlRead ($input)
    $RetVal = _Execute ($command)
    GUICtrlSetData ($output, $RetVal & @CRLF, 1)
EndFunc

4. Explain what "returns" are. Because that sentence doesn't make sense to me.

Link to comment
Share on other sites

When i type the command MsgBox(1,"test","test") it normaly returns a number (i thought 1 for ok and 2 for cancel, not sure)

THAT return should be written in the ouput box.

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

When i type the command MsgBox(1,"test","test") it normaly returns a number (i thought 1 for ok and 2 for cancel, not sure)

THAT return should be written in the ouput box.

<{POST_SNAPBACK}>

Hello?

I said:

I didn't know. Change

Func _Command()
     Local $command
    $command = GUICtrlRead ($input)
    GUICtrlSetData ($output, $command & @CRLF, 1)
    _Execute ($command)
EndFunc

to

Func _Command()
     Local $command, $RetVal
    $command = GUICtrlRead ($input)
    $RetVal = _Execute ($command)
    GUICtrlSetData ($output, $RetVal & @CRLF, 1)
EndFunc
Edited by SlimShady
Link to comment
Share on other sites

oke sorry.

it works now but now i have some other problems.

i can't store variables.

so when i type $mem = memgetstats() then it will give an error.

while it should store the outcome in $mem so could see later see what $mem[0] till[8] was

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

I don't understand the point of this.

If it's to just run simple commands, great, but if you want this to 'record' things... it's not going to catch on. I could just write it in Scite and test it there.

A console is a cool idea, but not a very slow linear script writer -.-

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

I now updated the program again, with a solution the the write to console command.

;Fileinstallers
FileInstall("C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\AutoIt.chm",@ScriptDir & "\AutoIt.chm")
;Creation of the GUI
#include <GUIConstants.au3>
GUISetHelp (@ScriptDir&"\AutoIt.chm")
Opt("GUIOnEventMode", 1)
GUICreate("Console")
$Mfile = GUICtrlCreateMenu ( "&File")
$MfileS = GUICtrlCreateMenuitem ( "&Save",$Mfile)
$input=GUICtrlCreateEdit ("",10,280,360,97,$ES_AUTOVSCROLL+$WS_VSCROLL)
$output=GUICtrlCreateEdit ("====================== Console Output ========================"&@CRLF,10,10,380,200,$ES_AUTOVSCROLL+$WS_VSCROLL)
$Button1 = GUICtrlCreateButton("OK",370,280,25,100)
GUISetOnEvent($Button1, "_Command")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState ()
HotKeySet("{Enter}","_Command")

;Looping script
while 1
sleep(5)
WEnd

;Functions
Func _Exit()
    If @GUI_CTRLID = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
EndFunc

;Run command
Func _Command()
    global $command = (GUICtrlRead ($input))
    $file = FileOpen ( "input.au3",2)
    FileWriteLine("input.au3","$result = ("&$command&")"&@CRLF)
    FileWriteLine("input.au3","sleep(500)"&@CRLF)
    FileWriteLine("input.au3","ControlSend ( 'Console','',6,$result)")
    Fileclose($file)
    Run("autoit3.exe input.au3")
    sleep(500)
EndFunc

but it stil doesn't work like i want to.

it doesn't remember valua's i stores in variables,by the console and so i can't call there information. (so i can't use $mem = MemGetstats() and then use $mem)

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...