Sign in to follow this  
Followers 0
phanan

How to hide the Process of AutoIT Script

10 posts in this topic

#1 ·  Posted (edited)

Hi everyone! Im very new to AutoIT

I hav juzt written a simple code. This code is about saving the content of log file (*.fmt) to Excel, then filter, then doing some calculations. So when this code is running, i saw the Excel open, doing filter & doing calculation & give result

So the Problem here is how to make all this process into background (mean no display the Excel Window, no display Calculation) and juzt give the Result only. Hope to be helped :)

Thanx a lot ;)

Edited by phanan

Share this post


Link to post
Share on other sites



Have a look at the flags in _ExcelBookOpen (hint: $fVisible)

1 person likes this

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

Have a look at the flags in _ExcelBookOpen (hint: $fVisible)

I hav uploaded my code by the Mediafire Link. So can u waste ur time to take a look on it?

Thanx

Share this post


Link to post
Share on other sites

phanan,

Rather than using Mediafire, just post the code here. But please use Code tags - put [autoit] before and [/autoit] after it. Then you get a nice scriollable box with pretty colurs like this: :)

; This is between code tags
$sFred = "Fred"

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@Melba23: cauze im new to this forum so I do not know this code tag function. thanx for ur recommend :)

Here is my code (mayb a little hard to see ;)). Thiz code used to calculate the Call Setup Time of MS1 & MS2 from the Log File *.FMT

#include <Excel.au3>
Dim $oExcel,$sRangeOrRow, $iColumn, $sField, $sCriteria,$i
$name = InputBox("Input Form","ENTER THE NAME OF UR LOG FILE"&@CRLF&@CRLF&"Ex: Ur logfile is Buu_dien_HCM.fmt. Then juzt enter Buu_dien_HCM in the line below")
$path = "C:Temp"&$name&".fmt"
$vipsave = "C:Temp"&$name
$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.Workbooks.OpenText($path, _
            437,        _   ; Origin    
            1,        _   ; StartRow
            1,        _   ; DataType = x1Delimited
            1,         _   ; TextQualifier = x1DoubleQuote
            False,    _   ; ConsecutiveDelimiter
            True,      _   ; Tab
            False,    _   ; Semicolon
            True,      _   ; Comma
            False,    _   ; Space
            False      _   ; Other
)
_ExcelBookSaveAs($oExcel, $vipsave, "xls", 0, 1) ;  Save file, overwrite existing file if necessary
; #FUNCTION# ====================================================================================================================
; Name...........: _ExcelFilter
; Description ...: Applies a filter to an excel file.
; Syntax.........: _ExcelFilter($oExcel,$sRangeorRow, $iColumn, $sField, $sCriteria)
; Parameters ....: $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
;              $sRangeOrRow - The range in A1 format, or a row number for R1C1 format
;              $iColumn - The specified column number for R1C1 format (default = 1)
;              $sField- the field no. where filter is to be applied.
;              $sCriteria- the criteria for filter is to be applied. For e.g filter by country name "India".
; Return values .: Success    - Returns 1
;              Failure   - Returns 0 and sets @error on errors:
;              @error=1 - Specified object does not exist
;              @error=2 - Row or column invalid
;              @extended=0 - Row invalid
;              @extended=1 - Column invalid
; Author ........: Manjish Naik (naikma@gmail.com)
; Modified.......: None as yet
; Remarks .......: None
; Related .......:
; Link ..........;
; Example .......; _ExcelFilter($oExcel,1,2,2,"Amit Ravindra,Patil"), this filters out all entries except the one having "Manager Name" as "Amit Ravindra,Patil".
;                                                                  The "manager name" is second filter field located at 1 row and 2nd column, hence $sField=2.
; ===============================================================================================================================
Func _ExcelFilter($oExcel, $sRangeOrRow, $iColumn, $sField, $sCriteria)
    If Not StringRegExp($sRangeOrRow, "[A-Z,a-z]", 0) Then
        If $sRangeOrRow < 1 Then Return SetError(2, 0, 0)
        If $iColumn < 1 Then Return SetError(2, 1, 0)
        $oExcel.ActiveSheet.Cells($sRangeOrRow, $iColumn).Select
        $oExcel.selection.Autofilter($sField, $sCriteria)
    Else
        $oExcel.ActiveSheet.Range($sRangeOrRow).Select
        $oExcel.selection.Autofilter($sField, $sCriteria)
    EndIf
EndFunc   ;==>_ExcelFilter
_ExcelFilter($oExcel,1,2,2,"MS1")
_ExcelFilter($oExcel,1,6,6,"Call Setup")
Send("{CTRLDOWN}")
Send("a")
Send("c")
Send("{CTRLUP}")
Send("{SHIFTDOWN}")
Send("{F11}")
Send("{SHIFTUP}")
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(1000)
_ExcelSheetActivate($oExcel,"Sheet1")
$number=_ExcelWriteFormula($oExcel,"=Counta(R2C6:R500C6)",2,16)
$no=_ExcelReadCell($oExcel,2,16)
For $i=1 to $no Step 1
for $j=1 to 10 Step 1
_ExcelWriteFormula($oExcel,"=Left(R"&$i+1&"C8,11)",$i+1,13)
_ExcelWriteFormula($oExcel,"=Mid(R"&$i+1&"C8,14,4)",$i+1,15)
Next
Next
$result = 0
$count1 = 0
For $k=1 to $no Step 1
$setup=_ExcelReadCell($oExcel,$k+1,13)
If $setup = " setup time" Then
  $count1 = $count1 + 1
  $result=$result + _ExcelReadCell($oExcel,$k+1,15)
EndIf
Next
_ExcelWriteCell($oExcel,$count1,2,16)
$MS1=$result/$count1

Sleep(1000)
_ExcelSheetActivate($oExcel,$name)
_ExcelFilter($oExcel,1,2,2,"MS2")
_ExcelFilter($oExcel,1,6,6,"Call Setup")
Send("{CTRLDOWN}")
Send("a")
Send("c")
Send("{CTRLUP}")
Send("{SHIFTDOWN}")
Send("{F11}")
Send("{SHIFTUP}")
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(1000)
_ExcelSheetActivate($oExcel,"Sheet2")
$number=_ExcelWriteFormula($oExcel,"=Counta(R2C6:R100C6)",2,16)
$no=_ExcelReadCell($oExcel,2,16)
For $i=1 to $no Step 1
for $j=1 to 10 Step 1
  _ExcelWriteFormula($oExcel,"=Left(R"&$i+1&"C8,11)",$i+1,13)
  _ExcelWriteFormula($oExcel,"=Mid(R"&$i+1&"C8,14,4)",$i+1,15)
Next
Next
$result = 0
$count2 = 0
For $k=1 to $no Step 1
    $setup=_ExcelReadCell($oExcel,$k+1,13)
If $setup = " setup time" Then
  $count2 = $count2 + 1
  $result=$result + _ExcelReadCell($oExcel,$k+1,15)
EndIf
Next
_ExcelWriteCell($oExcel,$count2,2,16)
$MS2=$result/$count2
$round_MS1 = Round($MS1,2)
$round_MS2 = Round($MS2,2)
_ExcelSheetActivate($oExcel,$name)
Send("{ESC}")
;_ExcelBookClose($oExcel,1,0) ;Close & Save
If ($count1 <> 0) And ($count2 <> 0) Then
MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = "&$round_MS1&@CRLF&"MS2 = "&$round_MS2)
ElseIf ($count1 = 0) & ($count2 <> 0) Then
MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = Unknown"&@CRLF&"MS2 = "&$round_MS2)
Else
MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = "&$round_MS1&@CRLF&"MS2 = Unknown")
EndIf
Edited by phanan

Share this post


Link to post
Share on other sites

Thanx everyone, I juzt hav found the solution for thix. Thanx for joining my ques.

Share this post


Link to post
Share on other sites

You may want to look into the excel.au3 functions a bit further. Seeing how you are using "Send" in your script your code will fail if the window is hidden.

So instead of using Send(), I used ControlSend(). Thanx for ur contribution :)

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