Sign in to follow this  
Followers 0
samonlinesuper

How to start the test with select items

14 posts in this topic

Dears,

With the help, I can have the menu to select the item that I want, but how can I start the test case by case which I selected in right side once the "RUN" button is pushed. I tried many ways to acompliish this task and failed. Please help me and thank you.

Below is my code.

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <GUIListBox.au3>

#include <WindowsConstants.au3>

#include <Array.au3>

Global $aItem[6][2] = [[5,""],["Upgrade/Downloadgrade,0],["Item2",0],["Item3",0],["Item4",0],["Item5",0]]

$DualListDlg = GUICreate("Choices Dialog", 751, 514, 247, 156)

GUISetIcon("", -1)

$ListBox1 = GUICtrlCreateList("", 8, 8, 305, 227, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL))

$Button1 = GUICtrlCreateButton(">", 332, 15, 31, 25)

$Button2 = GUICtrlCreateButton(">>", 332, 48, 31, 25)

$Button3 = GUICtrlCreateButton("<", 332, 81, 31, 25)

;GUICtrlSetState(-1, $GUI_DISABLE)

$Button4 = GUICtrlCreateButton("<<", 332, 114, 31, 25)

$ListBox2 = GUICtrlCreateList("", 384, 8, 331, 227, $LBS_MULTIPLESEL)

$Button5 = GUICtrlCreateButton("&RUN", 112, 273, 75, 25)

$Button6 = GUICtrlCreateButton("&CLOSE", 192, 273, 75, 25)

; $Button7 = GUICtrlCreateButton("&Help", 272, 273, 75, 25)

GUISetState(@SW_SHOW)

Update_Listviews()

While 1

$msg = GUIGetMsg()

Switch $msg

Case $Button1

Shift($ListBox1, 1)

Update_Listviews()

Case $Button3

Shift($ListBox2, 0)

Update_Listviews()

Case $Button6, $GUI_EVENT_CLOSE

ExitLoop

EndSwitch

WEnd

Func Update_Listviews() ; scan array and reload listboxes accordingly

Local $str1, $str2

For $x = 1 to $aItem[0][0] ; loop through array

If $aItem[$x][1] Then ; if 1, add to right listbox string

$str2 &= $aItem[$x][0] & "|"

Else ; if 0, add to left listbox string

$str1 &= $aItem[$x][0] & "|"

EndIf

Next

GUICtrlSetData($ListBox1, "")

GUICtrlSetData($ListBox1, StringTrimRight($str1, 1)) ; strip trailing "|" and load to left listbox

GUICtrlSetData($ListBox2, "")

GUICtrlSetData($ListBox2, StringTrimRight($str2, 1)) ; strip trailing "|" and load to right listbox

EndFunc

Func Shift($control, $dest)

Local $row = 0

For $x = 1 to $aItem[0][0] ; loop through array

If $aItem[$x][1] <> $dest Then ; is array element not already in dest listbox?

If _GUICtrlListBox_GetSel($control, $row) Then $aItem[$x][1] = $dest ; if row selected , move array element

$row += 1

EndIf

Next

EndFunc

Share this post


Link to post
Share on other sites



What should happen when RUN is pressed?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Dears,

If "RUN" is pressed then the select items in the "right" pane will start to execute one by one or one after the other.

Share this post


Link to post
Share on other sites

User GUICtrlCreateListView() instead. It will be much easier to get the items afterward.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Dears,

Could you show me the example, sorry I am new in this field and programming.

Share this post


Link to post
Share on other sites

Dear all,

Could anyone help me about this question?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Dear UEZ,

I used GUICtrlCreateListView to create menu, but I still cannot "Shift" item which selected from left to right when ">" button is pressed, could you help and below is my code, thank you.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
Global $aItem[100][2]
$Form1_1 = GUICreate("Automation Test", 656, 443, 235, 19, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP), BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE))
GUISetBkColor(0xE0FFFF)
$ListView1 = GUICtrlCreateListView("Test Items", 40, 32, 249, 281, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOLABELWRAP))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 300)
$ListView1_0 = GUICtrlCreateListViewItem("Upgrade/Downloadgrade", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("Item2", $ListView1)
$ListView2 = GUICtrlCreateListView("Selected Items", 355, 33, 249, 281)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 300)
$Button1 = GUICtrlCreateButton(">", 304, 48, 33, 33)
$Button2 = GUICtrlCreateButton(">>", 304, 90, 33, 33)
$Button3 = GUICtrlCreateButton("<", 304, 138, 33, 33)
$Button4 = GUICtrlCreateButton("<<", 304, 182, 33, 33)
$ButtonRUN = GUICtrlCreateButton("RUN", 168, 352, 97, 41)
$ButtonCLOSE = GUICtrlCreateButton("Close", 320, 352, 97, 41)
GUISetState(@SW_SHOW)
Update_Listviews()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $Button1
    Shift($ListView1, 1)
    Update_Listviews()
  Case $Button3
   Shift($ListView2, 0)
   Update_Listviews()
  Case $GUI_EVENT_CLOSE
  Case $ButtonCLOSE, $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd
Func Update_Listviews() ; scan array and reload listboxes accordingly
Local $str1, $str2
For $x = 1 to $aItem[0][0] ; loop through array
  If $aItem[$x][1] Then ; if 1, add to right listbox string
   $str2 &= $aItem[$x][0] & "|"
  Else ; if 0, add to left listbox string
   $str1 &= $aItem[$x][0] & "|"
  EndIf
Next
GUICtrlSetData($ListView1, "")
GUICtrlSetData($ListView1, StringTrimRight($str1, 1)) ; strip trailing "|" and load to left listbox
GUICtrlSetData($ListView2, "")
GUICtrlSetData($ListView2, StringTrimRight($str2, 1)) ; strip trailing "|" and load to right listbox
EndFunc
Func Shift($control, $dest)
Local $row = 0
For $x = 1 to $aItem[0][0] ; loop through array
  If $aItem[$x][1] <> $dest Then ; is array element not already in dest listbox?
   If _GUICtrlListView_GetItemSelected($control, $row) Then $aItem[$x][1] = $dest ; if row selected , move array element
   $row += 1
  EndIf
Next
EndFunc
Edited by samonlinesuper

Share this post


Link to post
Share on other sites

Try this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>

Global $aItem[100][2]
$Form1_1 = GUICreate("Automation Test", 656, 443, 235, 19, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP), BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE))
GUISetBkColor(0xE0FFFF)
$ListView1 = GUICtrlCreateListView("Test Items", 40, 32, 249, 281, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOLABELWRAP))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 300)
$hListView1 = GUICtrlGetHandle($ListView1)
GUICtrlCreateListViewItem("Upgrade/Downloadgrade", $ListView1)
GUICtrlCreateListViewItem("Item2", $ListView1)
$ListView2 = GUICtrlCreateListView("Selected Items", 355, 33, 249, 281)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 300)
$hListView2= GUICtrlGetHandle($ListView2)
$Button1 = GUICtrlCreateButton(">", 304, 48, 33, 33)
$Button2 = GUICtrlCreateButton(">>", 304, 90, 33, 33)
$Button3 = GUICtrlCreateButton("<", 304, 138, 33, 33)
$Button4 = GUICtrlCreateButton("<<", 304, 182, 33, 33)
$ButtonRUN = GUICtrlCreateButton("RUN", 168, 352, 97, 41)
$ButtonCLOSE = GUICtrlCreateButton("Close", 320, 352, 97, 41)
GUISetState(@SW_SHOW)
Update_Listviews()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            Shift($hListView1, 1)
            Update_Listviews()
        Case $Button3
            Shift($hListView2, 0)
            Update_Listviews()
        Case $ButtonRUN
            For $i = 0 To _GUICtrlListView_GetItemCount($hListView2) - 1
                ConsoleWrite("Running " & $i & "(" & _GUICtrlListView_GetItemText($hListView2, $i) & ")" & @CRLF)
            Next
        Case $ButtonCLOSE, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Update_Listviews() ; scan array and reload listboxes accordingly
    Local $str1, $str2
    For $x = 1 To $aItem[0][0] ; loop through array
        If $aItem[$x][1] Then ; if 1, add to right listbox string
            $str2 &= $aItem[$x][0] & "|"
        Else ; if 0, add to left listbox string
            $str1 &= $aItem[$x][0] & "|"
        EndIf
    Next
    GUICtrlSetData($ListView1, "")
    GUICtrlSetData($ListView1, StringTrimRight($str1, 1)) ; strip trailing "|" and load to left listbox
    GUICtrlSetData($ListView2, "")
    GUICtrlSetData($ListView2, StringTrimRight($str2, 1)) ; strip trailing "|" and load to right listbox
EndFunc   ;==>Update_Listviews

Func Shift($control, $dest)
    Local $i, $s
    Switch $dest
        Case 0 ;right to left
            $s = _GUICtrlListView_GetSelectedCount($control)
            If $s > 0 Then
                $aSelected = _GUICtrlListView_GetSelectedIndices($control, True)
                For $i = 1 To UBound($aSelected) - 1
                    _GUICtrlListView_AddItem($hListView1, _GUICtrlListView_GetItemText($control, $aSelected[$i]))
                    _GUICtrlListView_DeleteItem($hListView2,  $aSelected[$i])
                Next
            EndIf
        Case 1 ;left to right
            $s = _GUICtrlListView_GetSelectedCount($control)
            If $s > 0 Then
                $aSelected = _GUICtrlListView_GetSelectedIndices($control, True)
                For $i = 1 To UBound($aSelected) - 1
                    _GUICtrlListView_AddItem($hListView2, _GUICtrlListView_GetItemText($control, $aSelected[$i]))
                    _GUICtrlListView_DeleteItem($hListView1,  $aSelected[$i])
                Next
            EndIf
    EndSwitch
EndFunc

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Dear UEZ,

Thank you and It works, thank you again.

Share this post


Link to post
Share on other sites

Dear UEZ,

Sorry to bother you again, the example that you shared is worked well. How to make selected items to get execute when I click "RUN"?

This is trouble me for sometimes, thank you if you can help.

Share this post


Link to post
Share on other sites

Look in the While/WEnd loop

Case $ButtonRUN
            For $i = 0 To _GUICtrlListView_GetItemCount($hListView2) - 1
                ConsoleWrite("Running " & $i & "(" & _GUICtrlListView_GetItemText($hListView2, $i) & ")" & @CRLF)
            Next

Instead of ConsoleWrite() you can use Run, RunWait, ShellExecute, ShellExecuteWait, etc. Look in the help file for more details.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Dear UEZ,

Sorry, it is me again.

I change the consoelwrite ro "RUN"; however, the items that I choose already compile to "exe" file so I modify as

Run("(" & _GUICtrlListView_GetItemText($hListView2, $i) & ")", "" )

but fail to excute, could you give me advice. Sorry again, I am beginner of programming.

Edited by samonlinesuper

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