Sign in to follow this  
Followers 0
timdecker

Fix Logic - Need Pause with OK to Continue Script and Such....

10 posts in this topic

Okay, here are the order of operations for how this script is suppose to function:

Step 1: Manual input
Step 2: Manual input
BEGIN PROGRAM
Step 3: Text to input box
Step 4: Press button --> then pause 3 seconds
Step 5: Halt program until a dialogue box with an "Okay to Continue" button is pressed. This allows the user to make modifications to the target application if needed....
Step 6: Repeat steps 3-5 until done with array
 

Here is the current code:

#cs
Solution to that is to move the window to the same screen location every time the program is run or the loop recycles.
Or test to see if it's on the X/Y you want and if not, force it there.


Use this as example for input box field when testing submition: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_legend
#ce

#include <file.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <GuiListView.au3>
#include <Array.au3>


Global $a_csv
Global $listview
Global $checkboxName
Global $iCount
Global $runProg
Global $acheck
Global $mapColumn
global $runProg


$s_Path = FileOpenDialog("Select CVS File", @ScriptDir, "comma seperated values (*.csv)")
If @error Then
    MsgBox(4096, "", "No File(s) chosen")
    Exit
Else

    _FileReadToArray($s_Path, $a_csv)
    buildGUI()



EndIf



Func copyToInput()
    $allRows =  _GUICtrlListView_GetItemCount($listview)
    For $rows = 0 to $allRows-1
        $material_name = _GUICtrlListView_GetItem($listview, $rows, 0)
        $letter = _GUICtrlListView_GetItem($listview, $rows, 3)
        ;where to input if statement so only checkbox that is checked runs????
        If GUICtrlRead($aCheck[1]) <> 1 and GUICtrlRead($aCheck[4]) <> 1 then continueloop
        If GUICtrlRead($aCheck[1]) = 1 Then
        controlsettext("HPOV", "", 4, $material_name[3])
        endif
        If GUICtrlRead($aCheck[4]) = 1 Then
        controlsettext("HPOV", "", 5, $letter[3])
        endif

        controlclick("HPOV", "", 6)

 Sleep(2000)
        ;there you can put some sleep(5000) = 5seconds, more or less, if u know exact applications processing time for this operation

        ;or ControlGetText("Myapplication title", "", CONTROL_WHICH_CHANGES_AFTER_BUTTONPRESS) and compare to older reads

        controlclick("Job", "", 2)

 Sleep(2000)
        ;there you can put some sleep(5000) = 5seconds, more or less, if u know exact applications processing time for this operation

        ;or ControlGetText("Myapplication title", "", CONTROL_WHICH_CHANGES_AFTER_BUTTONPRESS) and compare to older reads


    Next
EndFunc

Func buildGUI()
    GUICreate("CSV Listview", 900, 450, -1, -1)
    $listview = GUICtrlCreateListView(StringReplace($a_csv[1], ",", "|"), 10, 10, 600, 210)
    $checkboxName = StringSplit($a_csv[1], ",")
    $iCount = $checkboxName[0]

    ;creating buttons
    Global $aCheck[$iCount + 1]
    Global $mapColumn[$iCount + 1]
    $nextSample = GUICtrlCreateButton("Map sample submition button ", 395, 320, 180, 30)
    $runProg = GUICtrlCreateButton("Run Program", 700, 250, 180, 30)
    GUICtrlSetState($runProg, $GUI_DISABLE)
    $btnStop = GUICtrlCreateButton("Stop", 700, 400, 180, 30)

     For $j = 1 To $iCount
        ; Store controIDs of the checkboxes
        $aCheck[$j] = GUICtrlCreateCheckbox($checkboxName[$j], 10, 190 + (50 * $j), 100, 30)
        $mapColumn[$j] = GUICtrlCreateButton("Map " & '"'  & $checkboxName[$j] & '"' & " to input box", 150, 190 + (50 * $j), 180, 30)
        GUICtrlSetState($aCheck[$j], $GUI_UNCHECKED)
        GUICtrlSetState($mapColumn[$j], $GUI_DISABLE)
            Next

    For $i = 2 To UBound($a_csv) - 1
        $s_temp = StringReplace($a_csv[$i], ",", "|")
        GUICtrlCreateListViewItem($s_temp, $listview)
    Next

    Global $aOut['']['']
    For $i = 2 to $a_csv[0]
        $aLine = stringsplit($a_csv[$i] , ",",3)
            If ubound($aLine) > ubound($aOut , 2) Then redim $aOut[$i][ubound($aLine)]
            _ArrayAdd($aOut , $a_csv[$i] , 0 , ",")
            ;consolewrite("line: "  & $aLine[2] & @LF)
    Next



    GUISetState()


        While 1
            $msg = GUIGetMsg()
            Switch $msg
                Case $GUI_EVENT_CLOSE
                    ExitLoop

                Case $runProg
                    copyToInput()

                Case Else
                    For $i = 1 To $iCount
                        If $msg = $aCheck[$i] Then
                            If GUICtrlRead($msg) = 1 Then
                                GUICtrlSetState($mapColumn[$i], $GUI_ENABLE)
                                GUICtrlSetState($runProg, $GUI_ENABLE)
                                Local $text = ""
                                For $k = 0 to $a_csv[0]-1
                                  $text &= ControlListView ("CSV Listview", "", $listview, "GetText", $k, $i-1) & @crlf

                                Next
                                ;Msgbox(0,$checkboxName[$i], $text) ; debug, can see the list of samples you selected
                            Else
                                GUICtrlSetState($mapColumn[$i], $GUI_DISABLE)
                            EndIf
                            ExitLoop
                        EndIf
                    Next
            EndSwitch
    WEnd

EndFunc

Where are you Zobengrauzis? :sorcerer:

Tim

Share this post


Link to post
Share on other sites



is it possible that the checkboxes are needed to be changed in middle of the loop, or they are good how they are from start to beggining?

Share this post


Link to post
Share on other sites

is it possible that the checkboxes are needed to be changed in middle of the loop, or they are good how they are from start to beggining?

 

The checkboxes are fine.

What happens is...after the "send experiment" button is pressed, a new "method" may need to be used...maybe not. Which is why I would like for a halt to occur after "send experiment" button is pressed so the tech can do what he needs to do, then click resume on the popup box. This halt and popup box should appear everytime the "Send Experiment" button is pressed.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

the default msgbox function puts the script on halt, so here you dont need any witchmagic to work this part. just call msgbox, any kind, after the button press.

Func copyToInput()
   $title = "(METTLER) - TGA-200A with gas box"

   
   
    $allRows =  _GUICtrlListView_GetItemCount($listview)
    For $rows = 0 to $allRows-1
        $material_name = _GUICtrlListView_GetItem($listview, $rows, 0)
        $letter = _GUICtrlListView_GetItem($listview, $rows, 3)
        ;where to input if statement so only checkbox that is checked runs????
        If GUICtrlRead($aCheck[1]) <> 1 and GUICtrlRead($aCheck[4]) <> 1 then continueloop
        If GUICtrlRead($aCheck[1]) = 1 Then
        controlsettext($title, "", "Edit_whichone?", $material_name[3])
        endif
        If GUICtrlRead($aCheck[4]) = 1 Then
         controlsettext($title, "", "Edit_whichone?",  $letter[3])
        endif

controlclick($title,"","Button_whichone?")

msgbox(0,"", "You Shall Not Pass!" & @CRLF & "Ok actually you can, just press something")

;next actions here will be only go when msgbox is pressed


    Next
EndFunc
Edited by Zobengrauzis

Share this post


Link to post
Share on other sites

 

the default msgbox function puts the script on halt, so here you dont need any witchmagic to work this part. just call msgbox, any kind, after the button press.

Func copyToInput()
   $title = "(METTLER) - TGA-200A with gas box"

   
   
    $allRows =  _GUICtrlListView_GetItemCount($listview)
    For $rows = 0 to $allRows-1
        $material_name = _GUICtrlListView_GetItem($listview, $rows, 0)
        $letter = _GUICtrlListView_GetItem($listview, $rows, 3)
        ;where to input if statement so only checkbox that is checked runs????
        If GUICtrlRead($aCheck[1]) <> 1 and GUICtrlRead($aCheck[4]) <> 1 then continueloop
        If GUICtrlRead($aCheck[1]) = 1 Then
        controlsettext($title, "", "Edit_whichone?", $material_name[3])
        endif
        If GUICtrlRead($aCheck[4]) = 1 Then
         controlsettext($title, "", "Edit_whichone?",  $letter[3])
        endif

controlclick($title,"","Button_whichone?")

msgbox(0,"", "You Shall Not Pass!" & @CRLF & "Ok actually you can, just press something")

;next actions here will be only go when msgbox is pressed


    Next
EndFunc

Nice Zobengrauzis!

Now...if you remember, I have a button that will run the program once you have selected the necessary checkboxes. I was messing around earlier trying to create a button that would stop the program completely and also a button is exit the program. I was using the tutorial on the site and reading other topics but could not get the onEvent function to work. Is this not what I need?

Thanks again!

Tim

Share this post


Link to post
Share on other sites

You cant stop the loop with gui button, but in ure case - you can abort middle way by making the msgbox with Ok/Cancel - and with capturing cancel pressed, escape from loop with exitloop (while with OK you proceed).

for the exit, change

Case $GUI_EVENT_CLOSE
                    Exit

Share this post


Link to post
Share on other sites

 

You cant stop the loop with gui button, but in ure case - you can abort middle way by making the msgbox with Ok/Cancel - and with capturing cancel pressed, escape from loop with exitloop (while with OK you proceed).

for the exit, change

Case $GUI_EVENT_CLOSE
                    Exit

Okay, but where do I read $IDCANCEL to escape from the loop?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

$whatbutton = msgbox(.....)





$whatbutton will change value to that button pressed value

to make it shorter,

if msgbox(.....) = 2 then exitloop
Edited by Zobengrauzis

Share this post


Link to post
Share on other sites
$whatbutton = msgbox(.....)





$whatbutton will change value to that button pressed value

to make it shorter,

if msgbox(.....) = 2 then exitloop

It works! Thanks, Zobengrauzis!

I am going to go test it out in the lab and get feedback from the techs.

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