Sign in to follow this  
Followers 0
johnmcloud

Add Checkbox(s) in a GUI List

18 posts in this topic

#1 ·  Posted (edited)

Hi guys,

I have this script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 248, 180)
$Edit = GUICtrlCreateEdit("", 8, 8, 233, 121)
$Button = GUICtrlCreateButton("Save", 8, 136, 233, 33)
GUISetState(@SW_SHOW)

$TestFile = @WorkingDir & "Test.txt"
FileOpen($TestFile, 2)
FileWrite($TestFile, "Word_1" & @CRLF & "Word_2" & @CRLF & "Word_3" & @CRLF & "Word_4")
GUICtrlSetData($Edit, FileRead($TestFile))

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button
     FileDelete(@WorkingDir & "Result.txt")
     FileWrite(@WorkingDir & "Result.txt", GUICtrlRead($Edit))
     ShellExecute(@WorkingDir & "Result.txt") EndSwitch
WEnd

I don't know how, i'd like to add a checkbox on every line of this list, so if i unchecked some and click on the button it save only the element with the checkbox enabled. I don't know how hany line has .txt, but i think we can read by array[0]

Hope I was clear, if not just ask and I'll try to post more information.

Thanks ;)

Edited by johnmcloud

Share this post


Link to post
Share on other sites



Not possible in an Edit control, you can do it in a ListView control though.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Can you provide a simple script example like mine? It's better for me to understand. I think i can integrate a listview control in a GUI, right?

Thanks for your time.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Below is a ruff script of what you could do. It gets buggy when you start scrolling, but there is a probably a workaround.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include<array.au3>
$Form1 = GUICreate("Form1", 248, 180)
$Edit = GUICtrlCreateEdit("", 20, 8, 233, 121)
$Button = GUICtrlCreateButton("Save", 8, 136, 233, 33)

Local $iBoxes,$aBoxes[1], $sMSG, $iLines=1

GUISetState(@SW_SHOW)




GUICtrlSetData($Edit,"a"&@crlf&"b"&@crlf&"c"&@crlf)



While 1
$nMsg = GUIGetMsg()

$aLines=StringRegExp(GUICtrlRead($Edit),"(.*)?(?:v)?",3)

$iLines=UBound($aLines)

$iBoxes= UBound($aBoxes)
If $iBoxes>$iLines Then
For $x=$iLines To UBound($aBoxes)-1
GUICtrlDelete($aBoxes[$x])
Next
EndIf

ReDim $aBoxes[$iLines]
If $iBoxes<$iLines Then
For $x=$iBoxes To UBound($aBoxes)-1
$aBoxes[$x-1]=GUICtrlCreateCheckbox("",2,($x-1)*14+8,14)
GUICtrlSetState(-1,$GUI_CHECKED)
Next

EndIf


Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Edit

Case $Button
$sMSG=""
$aEdit=StringRegExp(GUICtrlRead($Edit),"(.*)?(?:v)?",3)


For $x=0 To UBound($aBoxes)-1

If BitAnd(GUICtrlRead ($aBoxes[$x]),$GUI_CHECKED) Then

$sMSG&=$aEdit[$x]
EndIf
Next
MsgBox (0,"",$sMSG)
EndSwitch

WEnd
Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok guys, for now i have make this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>

Dim $item[6] = [5]

GUICreate("Example", 216, 201, -1, -1, -1, $WS_EX_ACCEPTFILES)
$listview = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 185)
$item[1] = GUICtrlCreateListViewItem("Select/Unselect All", $listview)
$item[2] = GUICtrlCreateListViewItem("Word1", $listview)
$item[3] = GUICtrlCreateListViewItem("Word2", $listview)
$item[4] = GUICtrlCreateListViewItem("Word3", $listview)
$item[5] = GUICtrlCreateListViewItem("Word4", $listview)
$button = GUICtrlCreateButton("Save", 11, 162, 186, 20)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button
For $i = 1 To $item[0]
    If BitAND(GUICtrlRead($item[$i], 1), $GUI_CHECKED) Then
     FileDelete(@WorkingDir & "Test.txt")
     FileWrite(@WorkingDir & "Test.txt", StringTrimRight(GUICtrlRead($item[$i]),1))
     ShellExecute(@WorkingDir & "Test.txt")
;~   MsgBox(0, 0, GUICtrlRead($item[$i]), 2)
    EndIf EndIf
Next
EndSwitch
WEnd

There are a couple of problems:

1) This script not read the information from a file, the problem is not how to do, but i don't know how many item has the file. In the example are 4, but may be even 500

2) Click on checkbox "Select/Unselect All" and make it working, so if is selected, all are selected and viceversa

Thanks to all ;)

Edited by johnmcloud

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I have resolved for the Select/Unselect all

Case $item[1]
For $i = 2 To $item[0]
If BitAND(GUICtrlRead($item[1], 1), $GUI_CHECKED) Then
     GUICtrlSetState($item[$i], $GUI_CHECKED)
Else
     GUICtrlSetState($item[$i], $GUI_UNCHECKED)
EndIf
Next

But sometime seems not work...if you click fast.

And this part not work:

If BitAND(GUICtrlRead($item[$i], 1), $GUI_CHECKED) Then
     FileDelete(@WorkingDir & "Test.txt")
     FileWrite(@WorkingDir & "Test.txt", StringTrimRight(GUICtrlRead($item[$i]), 1))
     ShellExecute(@WorkingDir & "Test.txt")
;~   MsgBox(0, 0, GUICtrlRead($item[$i]), 2)
EndIf

And i need also only to know how read an unknow number of line from a txt...

Please some advice/example

Thanks

Edited by johnmcloud

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Not work:

Case $button
For $i = 1 To $item[0]
     If _GUICtrlListView_GetItemChecked($listview, $i-1) Then
         FileDelete(@WorkingDir & "Test.txt")
         FileWrite(@WorkingDir & "Test.txt", StringTrimRight(GUICtrlRead($item[$i]), 1))
     EndIf
Next
ShellExecute(@WorkingDir & "Test.txt")

The .txt has only one element also if if select more, so if i select one work, but two or more not...

Edited by johnmcloud

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

This works for me...

Also for me, but when i write on a file i have only one value. I need to use FileWrite?

For $i = 1 To $item[0]
     If _GUICtrlListView_GetItemChecked($listview, $i - 1) Then
         FileDelete(@WorkingDir & "Test.txt")
         FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($listview, $i - 1) & @CRLF)
     EndIf
Next
ShellExecute(@WorkingDir & "Test.txt")
Edited by johnmcloud

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Thanks Zedna, update:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>

Dim $item[6] = [5]

GUICreate("Example", 216, 201, -1, -1, -1, $WS_EX_ACCEPTFILES)
$iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 185)
$hListView = GUICtrlGetHandle($iListView)
$item[1] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView)
$item[2] = GUICtrlCreateListViewItem("Word1", $iListView)
$item[3] = GUICtrlCreateListViewItem("Word2", $iListView)
$item[4] = GUICtrlCreateListViewItem("Word3", $iListView)
$item[5] = GUICtrlCreateListViewItem("Word4", $iListView)
$button = GUICtrlCreateButton("Save", 11, 162, 186, 20)
GUISetState(@SW_SHOW)

For $i = 1 To $item[0]
GUICtrlSetState($item[$i], $GUI_CHECKED)
Next

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button
FileOpen(@WorkingDir & "Test.txt", 2)
For $i = 2 To $item[0]
    If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then
     FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)
    EndIf
Next
If _GUICtrlListView_AllUnChecked($hListView) = True Then
    MsgBox(0, 0, "No element(s) selected")
Else
    ShellExecute(@WorkingDir & "Test.txt")
EndIf
Case $item[1]
For $i = 2 To $item[0]
    If BitAND(GUICtrlRead($item[1], 1), $GUI_CHECKED) Then
     GUICtrlSetState($item[$i], $GUI_CHECKED)
    Else
     GUICtrlSetState($item[$i], $GUI_UNCHECKED)
    EndIf
Next
EndSwitch
WEnd

Func _GUICtrlListView_AllUnChecked($hListView)
Local $iChecked = 0, $iCount = _GUICtrlListView_GetItemCount($hListView)
For $i = 0 To $iCount - 1
If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then
$iChecked += 1
EndIf
Next
Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked.
EndFunc ;==>_GUICtrlListView_AllUnChecked

Problems:

1) The Func _GUICtrlListView_AllUnChecked read also the first line ( select/unselect all ), how to remove from the _GUICtrlListView_GetItemCount ?

2) Read the ListView information from a txt, without know the number of the item

Edited by johnmcloud

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

New update:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>

Dim $SelectAll[1]

GUICreate("Example", 216, 201, -1, -1, -1, $WS_EX_ACCEPTFILES)
$iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 185)
$hListView = GUICtrlGetHandle($iListView)
$SelectAll[0] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView)
$Button = GUICtrlCreateButton("Save", 11, 162, 186, 20)
GUISetState(@SW_SHOW)

File_Create()
Load_Value()

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button
FileOpen(@WorkingDir & "Test.txt", 2)
For $i = 2 To $SelectAll[0]
    If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then
     FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)
    EndIf
Next
If _GUICtrlListView_AllUnChecked($hListView) = True Then
    MsgBox(0, 0, "No element(s) selected")
Else
    ShellExecute(@WorkingDir & "Test.txt")
EndIf
EndSwitch
WEnd

Func File_Create()
$Test = FileOpen(@WorkingDir & "Test.txt", 2)
FileWrite($Test, "Value11" & @LF & "Value22" & @LF & "Value33" & @LF & "Value44")
EndFunc

Func _GUICtrlListView_AllUnChecked($hListView)
Local $iChecked = 1, $iCount = _GUICtrlListView_GetItemCount($hListView)
For $i = 0 To $iCount - 1
If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then
$iChecked += 1
EndIf
Next
Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked.
EndFunc ;==>_GUICtrlListView_AllUnChecked

Func Load_Value()
$File = FileRead(@WorkingDir & "Test.txt")
$array = StringSplit($File, @LF)
For $i = 1 To $array[0] - 1
GUICtrlCreateListViewItem(StringTrimRight($array[$i], 1), $iListView)
Next
EndFunc ;==>Load_Value

Now the script load the information from a txt ( remove last line and last letter of every line, but i need it )

I need to add only a working checkbox "Select/Unselect All"

Please :D

Edited by johnmcloud

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I think i'm not understand :(

I have not figured out how to apply it to my situation. I have no variables, I have only one value ($SelectAll), the others are generated from the contents of the file

So i want to click on "Select/Unselect All" checkbox, if checked the other are checked and viceversa.

The script, with the new button for load the value and one for save:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>

Dim $SelectAll[1]
 
$_1 = GUICreate("Example", 217, 202, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE))
$iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 180)
$hListView = GUICtrlGetHandle($iListView)
$ButtonSave = GUICtrlCreateButton("Save", 107, 164, 92, 20)
$ButtonLoad = GUICtrlCreateButton("Load", 19, 166, 84, 20)
GUISetState(@SW_SHOW)

File_Create()

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $ButtonLoad
   $SelectAll[0] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView)
   Load_Value()
  Case $ButtonSave
   FileOpen(@WorkingDir & "Test.txt", 2)
   For $i = 2 To $SelectAll[0]
    If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then
     FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)
    EndIf
   Next
   If _GUICtrlListView_AllUnChecked($hListView) = True Then
    MsgBox(0, 0, "No element(s) selected")
   Else
    ShellExecute(@WorkingDir & "Test.txt")
   EndIf
EndSwitch
WEnd

Func File_Create()
$Test = FileOpen(@WorkingDir & "Test.txt", 2)
FileWrite($Test, "Value11" & @LF & "Value22" & @LF & "Value33" & @LF & "Value44")
EndFunc   ;==>File_Create

Func _GUICtrlListView_AllUnChecked($hListView)
Local $iChecked = 1, $iCount = _GUICtrlListView_GetItemCount($hListView)
For $i = 0 To $iCount - 1
  If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then
   $iChecked += 1
  EndIf
Next
Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked.
EndFunc   ;==>_GUICtrlListView_AllUnChecked

Func Load_Value()
$File = FileRead(@WorkingDir & "Test.txt")
$array = StringSplit($File, @LF)
For $i = 1 To $array[0] - 1
  GUICtrlCreateListViewItem(StringTrimRight($array[$i], 1), $iListView)
Next
EndFunc   ;==>Load_Value
Edited by johnmcloud

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I think i have a solution:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>

Dim $SelectAll[1]

$_1 = GUICreate("Example", 217, 202, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE))
$iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 180)
$hListView = GUICtrlGetHandle($iListView)
$ButtonSave = GUICtrlCreateButton("Save", 107, 164, 92, 20)
$ButtonLoad = GUICtrlCreateButton("Load", 19, 166, 84, 20)
GUISetState(@SW_SHOW)

File_Create()

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonLoad
$SelectAll[0] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView)
Load_Value()
Case $ButtonSave
FileOpen(@WorkingDir & "Test.txt", 2)
For $i = 2 To $SelectAll[0]
    If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then
     FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)
    EndIf
Next
If _GUICtrlListView_AllUnChecked($hListView) = True Then
    MsgBox(0, 0, "No element(s) selected")
Else
    ShellExecute(@WorkingDir & "Test.txt")
EndIf
Case $SelectAll[0]
If _GUICtrlListView_GetItemChecked($iListView, $SelectAll) Then
_GUICtrlListView_SetItemChecked($iListView, $SelectAll[0], 1)
_GUICtrlListView_SetCheckedStates($hListView, 1)
EndIf
If Not _GUICtrlListView_GetItemChecked($iListView, $SelectAll) Then
_GUICtrlListView_SetItemChecked($iListView, $SelectAll, 2)
_GUICtrlListView_SetCheckedStates($hListView, 2)
EndIf
EndSwitch
WEnd

Func File_Create()
$Test = FileOpen(@WorkingDir & "Test.txt", 2)
FileWrite($Test, "Value11" & @LF & "Value22" & @LF & "Value33" & @LF & "Value44")
EndFunc ;==>File_Create

Func _GUICtrlListView_AllUnChecked($hListView)
Local $iChecked = 1, $iCount = _GUICtrlListView_GetItemCount($hListView)
For $i = 0 To $iCount - 1
If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then
$iChecked += 1
EndIf
Next
Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked.
EndFunc ;==>_GUICtrlListView_AllUnChecked

Func Load_Value()
$File = FileRead(@WorkingDir & "Test.txt")
$array = StringSplit($File, @LF)
For $i = 1 To $array[0] - 1
GUICtrlCreateListViewItem(StringTrimRight($array[$i], 1), $iListView)
Next
EndFunc ;==>Load_Value

Func _GUICtrlListView_SetCheckedStates($hListView, $iType) ; By Zedna, Modified by guinness.
Local $fState = False, $iCount = _GUICtrlListView_GetItemCount($hListView)
If $iType < 0 Or $iType > 2 Then
Return SetError(1, 0, 0)
EndIf
If $iType Then
$fState = True
EndIf
For $i = 0 To $iCount - 1
If $iType = 2 Then
$fState = Not _GUICtrlListView_GetItemChecked($hListView, $i) ; Invert checked state with $iType 2.
EndIf
_GUICtrlListView_SetItemChecked($hListView, $i, $fState)
Next
EndFunc ;==>_GUICtrlListView_SetCheckedStates

There is only a problem, if you click fast on checkbox "select/unselect all" sometimes lose the function. Someone what to test for search a workaround?

Thanks

Edited by johnmcloud

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

  • Similar Content

    • crushyna
      Error check implementation (problem with loop exit)
      By crushyna
      Hi everyone!
      I'm developing small testing tool for new software in my company.
      Tool itself is working correctly (it follows scripted test commands one by one), but I'm trying to develop an error checking function.

      Mechanics are simple: every time software (external) shows specific error (via window class), program asks for next step. Continue, or abort test (and return to main GUI)?
      The error check function is switched on/off via Checkbox in GUI.

      Here are some code fragments:

      Checkbox:
      Global $idCheckbox1 = GUICtrlCreateCheckbox("Enable TP.net error handling", 352, 40, 249, 17) GUICtrlSetFont(-1, 12, 400, 0, "Calibri") GUICtrlSetColor(-1, 0x000000)  
      Checkbox switch:
      GUISetState(@SW_SHOW) Local $Choosen While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCheckbox1 If _IsChecked($idCheckbox1) Then $cSwitch1 = 1 Else $cSwitch1 = 0 EndIf Case $idAddTest (and so on...)  
      Function call:
      (alot of ElseIf commands...) ElseIf $aItem = $idOperatorIn Then WywolanieOkna() WinActivate($hFSO) ControlClick($hFSO, "", "[NAME:lblCashierNumber]") Sleep($Sleep_05) Send("0000019{Enter}19{Enter 2}") Sleep($Sleep_75) EndIf #EndRegion ### START ELSEIF ARMY ### Next If $cSwitch1 = 1 Then MsgBox( 0, "Error check!", "Error check ON!") /// just for testing purposes CheckError() Else Return EndIf EndSwitch WEnd
      Classic _IsChecked function:
      Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked  
      And Checkerror() function itself:
      Func CheckError() Local $Answer If ControlCommand($hMsgPanel, "", "[NAME:panelMsgBox]", "IsEnabled", "") Then ;~ Sleep($Sleep_05) $Answer = MsgBox(52, "Error!", "An error occured! Continue testing?") ;~ Sleep($Sleep_05) Switch $Answer Case 6 MsgBox(0, "Error!", "Test will now continue.", 3) Send("{Enter}") WinActivate($hWnd) Return Case 7 MsgBox(64, "Error!", "Test cancelled.", 5) $ElseIfArmyOff = 1 ControlClick($hMsgPanel, "", "[NAME:cmdOK]") WinActivate($AppName) #cs MsgBox( 0, "test1", $idTSList) Local $idTSListCopy For $i = 0 to _GUICtrlListView_GetItemCount($idTSList) - 1\ #ce $idTSListCopy = _GUICtrlListView_GetItemTextString($idTestCaseList, $LoopCount) ExitLoop EndSwitch EndIf Return 1 EndFunc ;==>CheckError
      Problem is: i can't make this function (CheckError() ) return to main gui state, that means: break the If/ElseIf loop.
      The switch is working correctly (MsgBox on error shows only when it's activated).
      Checkerror() function works correctly - recognizes the error, stops script until decision is made. But it doesn't terminate If/ElseIf loop.

      Any help appreciated!
    • Vivaed
      List files in folder, delete all but newest version
      By Vivaed
      I am trying to read all the files in a folder, then whatever file is newest, keep only that one and delete the rest.
      Example files:  (these all have version numbers embedded in them, I dont want to rely on the file name)
      Faint.exe
      Faint-v2.0.exe
      Faint-v3.0.exe
      Faint-v4.0.exe
       
      What I have so far:
      #include <File.au3> RemoveOldFiles() ConsoleWrite(FileGetVersion("C:\WB Resources\FAINT_DONT_LINK_THESE\Faint-v4.0.0.exe") &@CRLF) Func RemoveOldFiles() Local $aFileList = _FileListToArray("C:\WB Resources\FAINT_DONT_LINK_THESE\", "*.exe",$FLTA_FILES) For $i = 0 To UBound($aFileList) - 1 $aFileVersion = FileGetVersion($aFileList[$i]) ConsoleWrite($aFileList[$i] & @CRLF) ConsoleWrite($aFileVersion & @CRLF) Next EndFunc OUTPUT: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\bot\ownCloud\WellBeats\Delete Old Files\delete-test.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop 3 0.0.0.0 a.exe 0.0.0.0 b.exe 0.0.0.0 Faint-v4.0.0.exe 0.0.0.0 4.0.0.18 <-- This is the correct file version.... +>07:34:26 AutoIt3.exe ended.rc:0 +>07:34:26 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6647 Not sure what I am missing here?
      Thanks!
    • Rapidnxit
      [solved] send multiple files by email from a file list
      By Rapidnxit
      Hi! I want to send by mail some files with a certain extension (.xml in my case). These files are located in the script folder. First, I thought to use _FileListToArrayRec function to have a list of these files. But than I don't know how to send them all at once. I know that I can attach multiple files in this way: path1;path2;path3; etc.  and so I have tried to make a string of this type with the path of the files (with a for loop) but It doesn't attach any file (only instructions.txt). How could I do? ( what I did is just an idea, if there's something better that would be great) Thanks!
      $aArrayXml = _FileListToArrayRec(@ScriptDir, "*.xml", $FLTAR_FILES) _ArrayDisplay($aArrayXml, "LIST XML") $LenghtArrayXml = UBound($aArrayXml) If ($LenghtArrayXml > 2) Then For $i = 2 To $LenghtArrayXml - 1 $temp = "&@ScriptDir&""\"&$aArrayXml[$i]&";"&"""" $XmlListFile = $XmlListFile & $temp Next EndIf $XmlListFile = StringTrimLeft($XmlListFile, 1) if($LenghtArrayXml = 2)Then $rc =_INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&";"&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) Else $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&$XmlListFile&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) EndIf  
    • jloyzaga
      simple multi list box
      By jloyzaga
      I'd just like to find an example of a multi select list box that outputs the selections to a file. Finding lots of complex examples in examples folder and cannot find and simple ones. like simple single select list box. 
      I'm trying to put together a selection criteria. where listbox 1 has a list of environment names - when selected it will open up another control (overlay is good to cover first GUI) it then lists Applications. When selected I will use the selection to list some items from excel as a multi select list box. So are there simple examples of these that i can look at and use to create a gui that I can understand?
       
      Joe
    • ruslanas402
      Open webpages by checking boxes
      By ruslanas402
      Hello everyone, don't even know how to ask.  My code is:
      #include <String.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') $x = 16 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&amp;') $Checkbox1 = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Somehow I need to open webpages where checkbox is checked by presing button view, I think I need somehow asign $actualdata with $actualdata2. Any ideas would be very appreciated