Sign in to follow this  
Followers 0
Kiti

Production Steps

1 post in this topic

#1 ·  Posted (edited)

This script will increment any ("Step" & a number) found on the A column, if it has an "x" next to it, on the B column. It's pretty simple, and it's one of my first scripts I ever wroted in AutoIt. I was pretty unsure about how to use 2D arrays, and this make me understood them a lot better. I hope you like it! :) Tell me what you think!

#include <ExcelCOM_UDF.au3>
#include <GUIConstantsEx.au3>

Local $YesID, $ExitID, $msg
Local $oExcel = _ExcelBookNew(1)

$gui = GUICreate("Custom Msgbox", 210, 80)
GUICtrlCreateLabel("Please click a button!", 10, 10)
$YesID = GUICtrlCreateButton("Validate!", 25, 40, 100, 30)
$ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

GUISetState(@SW_SHOW); display the GUI

$Note_win = WinGetHandle("Custom Msgbox", "")
WinMove($Note_win, "", 700, 10)
WinSetOnTop("Custom Msgbox", "", 1)

For $K = 1 To 25
    _ExcelWriteCell($oExcel, "Step 1", $K, 1)
Next

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $YesID
            WinActivate("[CLASS:XLMAIN]", "")
            Send("{DOWN}"); fixes a bug: if you write "x" on a cell, and you don't select another cell, the GUI exits.
            $Cell = _ExcelFindInRange($oExcel, 'x', 1, 2, 25, 2, 0, 2, False, False)
            For $i = 1 To $Cell[0][0]
                $Step = _ExcelReadCell($oExcel, $Cell[$i][3], $Cell[$i][2] - 1)
                $level = StringTrimLeft($Step, 5)
                $nextlevel = $level + 1
                _ExcelWriteCell($oExcel, "Step " & $nextlevel, $Cell[$i][3], $Cell[$i][2] - 1)
            Next
            _ExcelReplaceInRange($oExcel, "x", "", 1, 2, 25, 2, 2, False, "", False)
        Case $ExitID
            _ExcelBookClose($oExcel)
            Exit
        Case $GUI_EVENT_CLOSE
            _ExcelBookClose($oExcel)
            Exit
    EndSwitch
WEnd
Edited by Kiti

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