DannyJ Posted June 15, 2021 Posted June 15, 2021 (edited) I have two ListViews (with itmes), and two buttons. I need an idea to, if I select an item from $List1 enable $Button1 and disable $Button2. The other $List2 works the same vay: if I select something from $List2 then I need to disable $Button1 and enable $Button2 Here is myexample code, which is not working expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 590, 399, 589, 289) $Button1 = GUICtrlCreateButton("Button1", 64, 272, 187, 25) $Button2 = GUICtrlCreateButton("Button2", 320, 272, 195, 25) $List1 = GUICtrlCreateListView("First ", 64, 56, 185, 175) $List2 = GUICtrlCreateListView("Second", 312, 64, 185, 175) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $idItem1 = GUICtrlCreateListViewItem("item1", $List1) Local $idItem2 = GUICtrlCreateListViewItem("item2", $List1) Local $idItem3 = GUICtrlCreateListViewItem("item3", $List1) Local $idItem4 = GUICtrlCreateListViewItem("item4", $List1) Local $idItem5 = GUICtrlCreateListViewItem("item5", $List1) Local $idItem21 = GUICtrlCreateListViewItem("item1", $List2) Local $idItem22 = GUICtrlCreateListViewItem("item2", $List2) Local $idItem23 = GUICtrlCreateListViewItem("item3", $List2) Local $idItem24 = GUICtrlCreateListViewItem("item4", $List2) Local $idItem25 = GUICtrlCreateListViewItem("item5", $List2) Local $iIndex = _GUICtrlListView_GetSelectedIndices($List1) Local $iIndex2= _GUICtrlListView_GetSelectedIndices($List2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $iIndex ;MsgBox(0,"I","Button 1 ENable, Button2 Disable") GUISetState($Button1,$GUI_ENABLE) GUISetState($Button2,$GUI_DISABLE) Case $iIndex2 ;MsgBox(0,"I","Button 2 ENable, Button1 Disable") GUISetState($Button2,$GUI_ENABLE) GUISetState($Button1,$GUI_DISABLE) EndSwitch WEnd Edited June 15, 2021 by DannyJ
Solution Danyfirex Posted June 15, 2021 Solution Posted June 15, 2021 Hello, Maybe This. expandcollapse popupinclude <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 590, 399, 589, 289) $Button1 = GUICtrlCreateButton("Button1", 64, 272, 187, 25) $Button2 = GUICtrlCreateButton("Button2", 320, 272, 195, 25) $List1 = GUICtrlCreateListView("First ", 64, 56, 185, 175) $List2 = GUICtrlCreateListView("Second", 312, 64, 185, 175) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $idItem1 = GUICtrlCreateListViewItem("item1", $List1) Local $idItem2 = GUICtrlCreateListViewItem("item2", $List1) Local $idItem3 = GUICtrlCreateListViewItem("item3", $List1) Local $idItem4 = GUICtrlCreateListViewItem("item4", $List1) Local $idItem5 = GUICtrlCreateListViewItem("item5", $List1) Local $idItem21 = GUICtrlCreateListViewItem("item1", $List2) Local $idItem22 = GUICtrlCreateListViewItem("item2", $List2) Local $idItem23 = GUICtrlCreateListViewItem("item3", $List2) Local $idItem24 = GUICtrlCreateListViewItem("item4", $List2) Local $idItem25 = GUICtrlCreateListViewItem("item5", $List2) GUICtrlSetState($Button1, $GUI_DISABLE) GUICtrlSetState($Button2, $GUI_DISABLE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN Local $aInfo = GUIGetCursorInfo() If $aInfo[4] = $List1 Then ConsoleWrite("1" & @CRLF) GUICtrlSetState($Button1, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_DISABLE) EndIf If $aInfo[4] = $List2 Then ConsoleWrite("2" & @CRLF) GUICtrlSetState($Button1, $GUI_DISABLE) GUICtrlSetState($Button2, $GUI_ENABLE) EndIf EndSwitch WEnd Saludos DannyJ 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
DannyJ Posted June 15, 2021 Author Posted June 15, 2021 @Danyfirex thank you very much your help Have a nice day man!
Nine Posted June 15, 2021 Posted June 15, 2021 Another approach if you would like : expandcollapse popup#include <GUIConstants.au3> #include <StructureConstants.au3> GUICreate("Form1", 590, 399, 589, 289) Global $Button1 = GUICtrlCreateButton("Button1", 64, 272, 187, 25) GUICtrlSetState(-1, $GUI_DISABLE) Global $Button2 = GUICtrlCreateButton("Button2", 320, 272, 195, 25) GUICtrlSetState(-1, $GUI_DISABLE) Global $List1 = GUICtrlCreateListView("First ", 64, 56, 185, 175) Global $List2 = GUICtrlCreateListView("Second", 312, 64, 185, 175) GUISetState(@SW_SHOW) Local $idItem1 = GUICtrlCreateListViewItem("item1", $List1) Local $idItem2 = GUICtrlCreateListViewItem("item2", $List1) Local $idItem3 = GUICtrlCreateListViewItem("item3", $List1) Local $idItem4 = GUICtrlCreateListViewItem("item4", $List1) Local $idItem5 = GUICtrlCreateListViewItem("item5", $List1) Local $idItem21 = GUICtrlCreateListViewItem("item1", $List2) Local $idItem22 = GUICtrlCreateListViewItem("item2", $List2) Local $idItem23 = GUICtrlCreateListViewItem("item3", $List2) Local $idItem24 = GUICtrlCreateListViewItem("item4", $List2) Local $idItem25 = GUICtrlCreateListViewItem("item5", $List2) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If $tNMHDR.Code = $NM_CLICK Then Switch $tNMHDR.hwndFrom Case GUICtrlGetHandle($List1) ConsoleWrite("list 1" & @CRLF) GUICtrlSetState($Button1, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_DISABLE) Case GUICtrlGetHandle($List2) ConsoleWrite("list 2" & @CRLF) GUICtrlSetState($Button2, $GUI_ENABLE) GUICtrlSetState($Button1, $GUI_DISABLE) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now