lattey

Pass the value of checked box from autoit to vbscript

7 posts in this topic

#1 ·  Posted (edited)

i have a vbscript that called an autoit exe file and autoit exe file will return value to vbscript.

vbscriptto call the exe and create array:

Set objShell = CreateObject("WScript.Shell")
objShell.Run ( "C:\Datalog\test.exe")


Dim intCtr: intCtr=-1
Dim tempArr()
Set UID = CreateObject("System.Collections.ArrayList")

CurLot = ""


For Each filelog in FileList    
    LogFile = Split(filelog, "~")(1)
    
    Set otf = fso.OpenTextFile("C:\Datalog\" & LogFile, 1)

        intCtr=intCtr+1
        sFile = Split(LogFile, "_")
        CurStep = sFile(4)
        Redim preserve tempArr(intCtr)
        tempArr(intCtr)=CurStep
            
next

autoit:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <Array.au3>

Global $Count = 10
Global $CheckBox[$Count]
global $array1[1]

$hGUI = GUICreate("Test", 500, 500)


Global $array_Pstep[10] = ["P1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10"]
$Spacing = 24
For $i = 0 To  UBound($array_Pstep) - 1
    $CheckBox[$i] = GUICtrlCreateCheckbox($array_Pstep[$i], 80, $Spacing + (20 * $i), 65, 17)
Next

$submit = GUICtrlCreateButton("submit",10, 300, 80, 30)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg

        case $submit
            _ArrayDisplay($array1)
        Case Else
            For $i = 0 To $Count - 1
                If $CheckBox[$i] = $Msg Then
                    MsgBox("", "Pressed", $i)
                    _ArrayAdd($array1, $array_Pstep[$i])
                    ExitLoop

                EndIf

            Next

    EndSwitch

WEnd

i need to compare the array in vbscript and array return by autoit. but i dont know how to pass the value of array in autoit to vbscript. Please help.

Edited by lattey

Share this post


Link to post
Share on other sites



#2 ·  Posted

Just out of curiosity, why are you guaranteeing yourself a headache by mixing and matching two very similar-syntax languages, rather than simply converting the vbscript to AutoIt and skipping the middle man?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

the original script is in vbscript and i just need to add the comparing array feature with checked box. Since vbscript must used the hta, i prefer to used autoit. 

besides, the vbscript have dependency with other vbscript. 

Share this post


Link to post
Share on other sites

#5 ·  Posted

hi junkew,

 

can you please give me sample of how to do 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

  • Similar Content

    • ur
      By ur
      I am maintaining all the reusable code in a separate file as library.au3.
      In that file I have referenced some dependent files using fileinstall, so that they will be extracted when necessary.
       
      Problem is, if I use a function in the library.au3 in another script which doesn't require this dependent file, as I am including the whole file using include tag, it is embedding that file also.
      Is there any way to exclude that.
       
    • GTAVLover
      By GTAVLover
      I recently tried to use ControlClick method to send a mouse click command to a button in a application, but I noticed that it is not working when I give first parameter as a window handle (HWND). But, when I give class name or window title, it works fine. I used AutoItX3 and VBScript. 
      Following are the commands I tried in VBScript:
      Dim WINAPI: Set WINAPI = WScript.CreateObject("WinAPIWrapper.WINAPI") Dim AutoItX3: Set AutoItX3 = WScript.CreateObject("AutoItX3.Control") Dim WindowHandle: WindowHandle = WINAPI.WinAPI_FindWindow("my window title", "my window class") 'Window handle obtains fine by my wrapper function 'Above window handle is obtained as a hexadecimal string. (I.E. - 0x00000000) I tried it like: WScript.Echo CStr(AutoItX3.ControlClick(WindowHandle, "", "[CLASS:Button; INSTANCE:1]")) // DOES NOT WORK WScript.Echo CStr(AutoItX3.ControlClick(CLng("&h" + Replace(WindowHandle, "0x", "")), "", "[CLASS:Button; INSTANCE:1]")) // DOES NOT WORK WScript.Echo CStr(AutoItX3.ControlClick(000000, "", "[CLASS:Button; INSTANCE:1]")) // DOES NOT WORK WScript.Echo CStr(AutoItX3.ControlClick(0x00000000, "", "[CLASS:Button; INSTANCE:1]")) // DOES NOT WORK Only following commands work: WScript.Echo CStr(AutoItX3.ControlClick("[CLASS:my window class]", "", "[CLASS:Button; INSTANCE:1]")) // WORKS FINE WScript.Echo CStr(AutoItX3.ControlClick("My window title", "", "[CLASS:Button; INSTANCE:1]")) // WORKS FINE  
      If any of your suggestions don't work, I will have to write a wrapper function myself to send mouse click commands. I chosen AutoIt V3 because it is good specially when comes to send keystrokes to applications. Please tell me why this won't work when I give window handle as first parameter.
      Thanks in advance.
    • sumandevadiga
      By sumandevadiga
      Hello 
      Trying to add below code in my main script but this is not functioning can you advise what else i need to do?
       
      Dim fn As String Const myDir As String = "C:\AR\" '<- alter here Const newFolder As String = "C:\AR1\" '<- alter here fn = Dir(myDir & "AR_*.xlsm") Do While fn <> "" FileCopy myDir & fn, newFolder & Replace(fn, "AR", "AI") fn = Dir Loop  
    • Valnurat
      By Valnurat
      Is there any change that I can return a code for success or not success in my script?
      I have a script that look in a SQL db and write to the registry.
      I want to return some kind of a control, because I will call my script *.exe from VBScript.
      _Main() Func _Main() Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & $sUser & ';PWD=' & $sPassword & ';', $sQUERY, $oRecordset, $aRecordsetArray, $aRecordset_inner Local $oConnection = _ADO_Connection_Create() _ADO_Connection_OpenConString($oConnection, $sConnectionString) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) $sQUERY = "Select Shipdate from " & $sTableName & " where ComputerName = '" & @ComputerName & "'" $oRecordset = _ADO_Execute($oConnection, $sQUERY) $aRecordsetArray = _ADO_Recordset_ToArray($oRecordset, False) $aRecordset_inner = _ADO_RecordsetArray_GetContent($aRecordsetArray) RegWrite("HKEY_CURRENT_USER\SOFTWARE\ComputerInfo", "Shipdate", "REG_SZ", $aRecordset_inner[0][0]) EndFunc  
    • messilm10
      By messilm10
      how do i get the crash report of any application and any running script?????