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

    • Simpel
      List of HotKeySets
      By Simpel
      Hi,
       
      I have written a programm offering me a lot of hotkeys to work with windows. All in all there are 40 hotkeys defined now.
      Now I made a portable version of it. But in this there are a lot of hotkeys useless. So I had to change some things. But that's not my point.
      Because of all these many hotkeys I sometimes know I made a hotkey but what were the keys I have to press.
      So I want to make a little help GUI or html or whatever. Now I'm interested to automate my own list of hotkeys.
      How can I collect all my hotkeys and necessary keys for this in a list?
       
      Regard, Conrad
    • Nighterfighter
      Get value of "fake" checkbox inside Excel 2010
      By Nighterfighter
      Hey guys, I am finishing up a script that will run a import a lof of VBA code, the .bas files, (more VBA code than can easily be ported into AutoIt. Thousands of lines...) to do some work on Excel spreadsheets.
       
      However, Excel has a security setting where it blocks macros from being run/loaded, unless both the "Enable All Macros" setting is enabled, and the "Trust access to the VBA project object model" checkbox is enabled. However, that checkbox appears to be fake. Using the AutoIt WindowInfo tool, there is no control ID for that checkbox.
       
      I have spent the last several hours trying to get this to work. Here is what I have so far, all of the control-send down/up etc are to get to the right menu options inside Excel.
       
      #include <Excel.au3> #include <FileConstants.au3> Global $oExcel, $oWorkbook, $oCurrSheet, $sMsg Global $sXLS = "C:\Users\SNIP\Downloads\test.xlsm" Global $sWorkbook = @ScriptDir & "\test.xlsm" Global $sBAS = @ScriptDir & "\Module1.bas", $sMacroName = "Main" SelectExcelFile() SelectBASFile() $oExcel = _Excel_Open() $sWorkbook = _Excel_BookOpen($oExcel, $sWorkbook); WinWaitActive("Microsoft Excel - " & $sWorkbook) ;MsgBox($MB_OK,"Open","Workbook is open") ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!f"); Sleep(50) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!t"); Sleep(50) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!f"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{ENTER}"); Sleep(105) ControlSend("Excel Options", "", "", "!t"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!e") Sleep(105) ControlSend("Trust Center", "", "", "!v") ;This part is not working. It doesn't select the checkbox, even though alt+v does manually. Sleep(100) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{ENTER}") Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!{F4}") $oExcel.VBE.ActiveVBProject.VBComponents.Import($sBAS) $oExcel.Application.Run("Main") ;These two functions are just to select the files. Func SelectExcelFile() ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Select Excel File To Sort." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Excel Files (*.xlsx;*xlsm;*.xls;)|", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Display the list of selected files. $sWorkbook = $sFileOpenDialog ;Assign the file selected to the workbook file ; MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog) EndIf EndFunc ;==>Example Func SelectBASFile() ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Select BAS Macro." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "BAS Files (*.bas;)|", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Display the list of selected files. $sBAS = $sFileOpenDialog ;Assign the file selected to the workbook file ;MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog) EndIf EndFunc ;==>Example  
      What's the best way to get the value of that imaginary checkbox, and if it isn't checked, check it? Or if it is checked, leave it alone? I tried doing a PixelSearch but that didn't work.
       
       
      And I can't manually enable the developer settings. This program will go to a few other users who won't know how to do that, and I can't remote in.
    • 31290
      Show button when clicking a checkbox
      By 31290
      Hi everyone, 
      I'm trying to display a button once a checkbox is clicked in my main GUI and to hide said button when the said checkbox is unticked:
      #include <ButtonConstants.au3> #Include <Constants.au3> #include <Date.au3> #include <File.au3> #Include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> Opt("GUIOnEventMode", 1) f_MainGui() While 1 Sleep (10) Wend Func f_MainGui() Global $g_MainGUI = GUICreate ("SEE Delete Temp Files", 400, 450) GUISetFont (8.5, 700, 0) GUISetBkColor ($Color_White) $g_Label1 = GUICtrlCreateLabel ("Select action(s):", 150, 96, 360, 17) $g_Label2 = GUICtrlCreateLabel ("Web Browsers:", 13, 125, 360, 17) Global $g_ChkBox1 = GUICtrlCreateCheckbox ("I.Explorer [ Cookies / Temp Internet Files / Tracking Data]", 16, 152, 360, 17) Global $g_ChkBox2 = GUICtrlCreateCheckbox ("Chrome", 16, 176, 120, 17) Global $g_ChkBox3 = GUICtrlCreateCheckbox ("Firefox", 16, 200, 120, 17) $g_Label3 = GUICtrlCreateLabel ("Windows Explorer:", 13, 231, 360, 17) Global $g_ChkBox4 = GUICtrlCreateCheckbox ("C:\Temp", 16, 255, 120, 17) Global $g_ChkBox5 = GUICtrlCreateCheckbox ("C:\Windows\Temp", 16, 279, 130, 17) Global $g_ChkBox6 = GUICtrlCreateCheckbox ("C:\Users\XXXXXX\Recent", 16, 303, 200, 17) Global $g_ChkBox7 = GUICtrlCreateCheckbox ("C:\Users\XXXXXX\Local Settings\Temp", 16, 327, 250, 17) Global $g_SelWB = GUICtrlCreateButton ("Select All Web Browsers", 16,360,150,25) GUICtrlSetOnEvent (-1, "f_SelectAllWB") Global $g_SelWinExpl = GUICtrlCreateButton (" Windows Explorer Only", 16,390,150,25) GUICtrlSetOnEvent (-1, "f_WinExplOnly") Global $g_SelAll = GUICtrlCreateButton ("All", 16, 420, 70, 25) GUICtrlSetOnEvent (-1, "f_SelAll") Global $g_SelAll = GUICtrlCreateButton ("None", 95, 420, 70, 25) GUICtrlSetOnEvent (-1, "f_SelNone") Global $g_SubmitAndClean = GUICtrlCreateButton ("Clean Temp Files", 264, 360, 120, 85) GUICtrlSetState ($g_SubmitAndClean, $GUI_HIDE) GUICtrlSetOnEvent (-1, "f_SumitAndClean") GUISetOnEvent ($GUI_EVENT_CLOSE, "_exit") GUISetState() EndFunc I tried everything ==> "Do...Until", "While...Wend", hotkeys etc... and the best I can have a a button that can't stop flicking. 
      I work exclusively with Events and for sure, when going trough the non event method,  Switch...Case...EndSwitch, it's working...
      I'm sure that this may be a beginner question but I think my mind stopped working after an all day coding on different projects
      Thanks in advance
    • nbg15
      List Content of "Qt5QWindowIcon" Class
      By nbg15
      Hello everybody,
      i've spent hours to google and find out how to get content of scrollable list view of our CMS Software...
      i checked it with the "AutotIT window info" tool, but the only things I get are this:

      Class: Qt5QWindowIcon
      Instance: 18
       
      but how can I get list contents of a class like that?
       
      I was using AutoIT couple a months ago (but it was a ListView32 box) <-- was easy
       
      Thanks for any hints...
       
      Rickey
       
      P.S: I also checked the AutoIT Editors help pages (Keywords: "Qt5QWindowIcon" "Qt5Q", nut cant find nothing... Thanks!
    • wakillon
      TinyBackupBox
      By wakillon
      Do a backup of a folders list