Leaderboard
Popular Content
Showing content with the highest reputation on 12/31/2020 in all areas
-
ATCmd.au3 UDF - Control AT Modems
FrancescoDiMuro reacted to Danyfirex for a topic
Hello!!! I want to share this UDF I've made with @mLipok, for some personal reason We stopped UDF development at 26-10-2020. So this can still be not fully operational. Donwload Link: https://www.autoitscript.com/forum/files/file/512-atcmdau3-udf/ Saludos1 point -
Questions about Autoit GUI
IcantCodeHelp reacted to mLipok for a topic
You should add your own ICON to the EXE file. I do this in this way: #AutoIt3Wrapper_Icon=z:\!!!_SVN_AU3\ICONS\work_magneta2.ico1 point -
1 point
-
Sure. A scripting.dictionary object is a "key=item" list (unique keys) so you need to build first a 2D array (1st column = keywords, 2nd column = links) using the data you want , and convert it to a SD which is muuuch faster to use in your kind of script Sure with a little correction in the _ReadString function. And BTW to ease this elephant you absolutely need to put a "brake" in the main While loop - see the code below #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> #include <StringConstants.au3> #include <TrayConstants.au3> #include <Array.au3> #include <ColorConstants.au3> #include <GuiRichEdit.au3> #include <GUIConstants.au3> HotKeySet("{F4}", "_Exit") SplashTextOn ("", "Loading ..." & @crlf & " ", 500, 55, -1, 400, 49, "", 10) Global $sdk = ObjCreate("Scripting.Dictionary") For $i = 1 to 25000 $sdk.Add ("key" & $i, "link" & $i) Next SplashOff() #cs ; check $a = _list($sdk) _ArrayDisplay($a) Func _list($dico) Local $keys = $dico.Keys Local $items = $dico.Items Local $count = $dico.Count Local $ret[$count+1][2] $ret[0][0] = $count For $i = 1 To $count $ret[$i][0] = $keys[$i-1] $ret[$i][1] = $items[$i-1] Next Return $ret EndFunc #ce Global $GUI3 Global $Tooltiptext = "" $GUI3 = GUICreate("Masque symptome", 900, 500) Global $hGuiLabelDrag = GUICtrlCreateLabel("", 50, 0, 650, 30, $SS_CENTER + $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG) GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetFont(-1, 14) ;=========================================================================== Global $Color_1 = 0xb2b4dc Global $Color_2 = 0xb1b8be Global $hSymptLabel01 = GUICtrlCreateLabel("OS du poste : ", 50, 100) Global $hRadio01 = GUICtrlCreateRadio("W7", 150, 95) Global $hRadio02 = GUICtrlCreateRadio("W10", 200, 95) Global $hRadio03 = GUICtrlCreateRadio("T.L. HP", 250, 95) Global $hRadio04 = GUICtrlCreateRadio("T.L. Wase", 310, 95) Global $hSymptLabel02 = GUICtrlCreateLabel("Nom du poste : ", 50, 140) Global $hInput01 = GUICtrlCreateInput("PP", 130, 135) Global $hSymptLabel03 = GUICtrlCreateLabel("Téléphone utilisateur : ", 250, 140) Global $hInput02 = GUICtrlCreateInput("0", 360, 135) Global $hRish = _GUICtrlRichEdit_Create($GUI3, "Symptôme(s) : " & @CRLF, _ 50, 180, 710, 240, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Global $OKGO = GUICtrlCreateButton("Go", 50, 450) WinSetOnTop($GUI3, "", 1) GUISetState(@SW_SHOW, $GUI3) ;~ GUISetState(@SW_HIDE, $GUI3) ;Unused state for this reproducer Func1000() Func Func1000() ;~ _CleanAndWait () ;Unused fonction for this reproducer ; GUISetState(@SW_SHOW, $GUI3) While 1 Local $hNMsg = GUIGetMsg($GUI3) Switch $hNMsg Case $OKGO WinSetOnTop($GUI3, "", 0) GUISetState(@SW_HIDE, $GUI3) ;~ ClipPut($hTexte) ;~ _SendAvSaPrPa ($hTexte) ;Unused fonction for this reproducer ;~ _RestorePP () ;Unused fonction for this reproducer ExitLoop Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $GUI3) ExitLoop EndSwitch ; IMPORTANT !! =============================<< If _GUICtrlRichEdit_IsModified($hRish) Then $hTexte = _GUICtrlRichEdit_GetText($hRish) _ReadString($hTexte, $sdk) _GUICtrlRichEdit_SetModified($hRish, false) EndIf Sleep(10) WEnd EndFunc ;==>Func1000 Func OpenLink() ;Nothing for now ConsoleWrite("+1" & @CRLF) EndFunc ;==>OpenLink Func _ReadString($TexteStringToCheck, $sd) local $sMsg For $kw In $sd ; If StringRegExp($TexteStringToCheck, '\b' & $kw & ' ') Then $sMsg &= $kw & " " If StringRegExp($TexteStringToCheck, '\b' & $kw & ' ') Then $sMsg &= $sd.item($kw) & " " Next _CreateThread1_ToolTip($sMsg) EndFunc Func _CreateThread1_ToolTip($sMsg) if $Tooltiptext <> $sMsg then ToolTip($sMsg, 1, 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sMsg = ' & $sMsg & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Tooltiptext = $sMsg EndIf EndFunc ;==>_CreateThread1_ToolTip Func _Exit() WinSetOnTop($GUI3, "", 0) Local $cExitYesNo = MsgBox($MB_YESNO, "Quitter?", "Voulez-vous quitter ?") If $cExitYesNo = "6" Then Exit Else WinSetOnTop($GUI3, "", 1) EndIf EndFunc ;==>_Exit1 point
-
OK... The best way I can think of would be to use a Scintilla control which is powerful and fast But you are on a Richedit... I tried a way to check 25,000 keywords (crazy...) , so here it is (raw) To test : type in the edit a word in the format "keyX" where X is a number between 1 and 25,000, followed by a space #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> #include <StringConstants.au3> #include <TrayConstants.au3> #include <Array.au3> #include <ColorConstants.au3> #include <GuiRichEdit.au3> #include <GUIConstants.au3> HotKeySet("{F4}", "_Exit") SplashTextOn ("", "Loading ..." & @crlf & " ", 500, 55, -1, 400, 49, "", 10) Global $sdk = ObjCreate("Scripting.Dictionary") For $i = 1 to 25000 $sdk.Add ("key" & $i, "link" & $i) Next SplashOff() #cs ; check $a = _list($sdk) _ArrayDisplay($a) Func _list($dico) Local $keys = $dico.Keys Local $items = $dico.Items Local $count = $dico.Count Local $ret[$count+1][2] $ret[0][0] = $count For $i = 1 To $count $ret[$i][0] = $keys[$i-1] $ret[$i][1] = $items[$i-1] Next Return $ret EndFunc #ce Global $GUI3 Global $Tooltiptext = "" $GUI3 = GUICreate("Masque symptome", 900, 500) Global $hGuiLabelDrag = GUICtrlCreateLabel("", 50, 0, 650, 30, $SS_CENTER + $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG) GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetFont(-1, 14) ;=========================================================================== Global $Color_1 = 0xb2b4dc Global $Color_2 = 0xb1b8be Global $hSymptLabel01 = GUICtrlCreateLabel("OS du poste : ", 50, 100) Global $hRadio01 = GUICtrlCreateRadio("W7", 150, 95) Global $hRadio02 = GUICtrlCreateRadio("W10", 200, 95) Global $hRadio03 = GUICtrlCreateRadio("T.L. HP", 250, 95) Global $hRadio04 = GUICtrlCreateRadio("T.L. Wase", 310, 95) Global $hSymptLabel02 = GUICtrlCreateLabel("Nom du poste : ", 50, 140) Global $hInput01 = GUICtrlCreateInput("PP", 130, 135) Global $hSymptLabel03 = GUICtrlCreateLabel("Téléphone utilisateur : ", 250, 140) Global $hInput02 = GUICtrlCreateInput("0", 360, 135) Global $hRish = _GUICtrlRichEdit_Create($GUI3, "Symptôme(s) : " & @CRLF, _ 50, 180, 710, 240, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Global $OKGO = GUICtrlCreateButton("Go", 50, 450) WinSetOnTop($GUI3, "", 1) GUISetState(@SW_SHOW, $GUI3) ;~ GUISetState(@SW_HIDE, $GUI3) ;Unused state for this reproducer Func1000() Func Func1000() ;~ _CleanAndWait () ;Unused fonction for this reproducer ; GUISetState(@SW_SHOW, $GUI3) While 1 Local $hNMsg = GUIGetMsg($GUI3) Switch $hNMsg Case $OKGO WinSetOnTop($GUI3, "", 0) GUISetState(@SW_HIDE, $GUI3) ;~ ClipPut($hTexte) ;~ _SendAvSaPrPa ($hTexte) ;Unused fonction for this reproducer ;~ _RestorePP () ;Unused fonction for this reproducer ExitLoop Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $GUI3) ExitLoop EndSwitch $hTexte = _GUICtrlRichEdit_GetText($hRish) _ReadString($hTexte, $sdk) Sleep(10) WEnd EndFunc ;==>Func1000 Func OpenLink() ;Nothing for now ConsoleWrite("+1" & @CRLF) EndFunc ;==>OpenLink Func _ReadString($TexteStringToCheck, $sd) local $sMsg For $kw In $sd If StringRegExp($TexteStringToCheck, '\b' & $kw & ' ') Then $sMsg &= $kw & " " Next _CreateThread1_ToolTip($sMsg) EndFunc Func _CreateThread1_ToolTip($sMsg) if $Tooltiptext <> $sMsg then ToolTip($sMsg, 1, 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sMsg = ' & $sMsg & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Tooltiptext = $sMsg EndIf EndFunc ;==>_CreateThread1_ToolTip Func _Exit() WinSetOnTop($GUI3, "", 0) Local $cExitYesNo = MsgBox($MB_YESNO, "Quitter?", "Voulez-vous quitter ?") If $cExitYesNo = "6" Then Exit Else WinSetOnTop($GUI3, "", 1) EndIf EndFunc ;==>_Exit1 point
-
Calling all RegEx Masters...
mikell reacted to AspirinJunkie for a topic
It is not - it is the end of 2020 - a year anyone tries hard to forget. So nothing happend right now 😉 Or you live in Australia - than you're right indeed.1 point -
That really doesn't make de design any better and doable! You are talking about 25000 word checks right? Why one earth would anybody want to do this at all? Either way: You have a go but don't come back crying for help when it doesn't perform!1 point
-
Ok... here is a possible solution to your requirements: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> #include <StringConstants.au3> #include <TrayConstants.au3> #include <Array.au3> #include <ColorConstants.au3> #include <GuiRichEdit.au3> #include <GUIConstants.au3> HotKeySet("{F4}", "_Exit") Global $GUI3 Global $Tooltiptext = "" $GUI3 = GUICreate("Masque symptome", 900, 500) Global $hGuiLabelDrag = GUICtrlCreateLabel("", 50, 0, 650, 30, $SS_CENTER + $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG) GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetFont(-1, 14) ;=========================================================================== Global $Color_1 = 0xb2b4dc Global $Color_2 = 0xb1b8be Global $hSymptLabel01 = GUICtrlCreateLabel("OS du poste : ", 50, 100) Global $hRadio01 = GUICtrlCreateRadio("W7", 150, 95) Global $hRadio02 = GUICtrlCreateRadio("W10", 200, 95) Global $hRadio03 = GUICtrlCreateRadio("T.L. HP", 250, 95) Global $hRadio04 = GUICtrlCreateRadio("T.L. Wase", 310, 95) Global $hSymptLabel02 = GUICtrlCreateLabel("Nom du poste : ", 50, 140) Global $hInput01 = GUICtrlCreateInput("PP", 130, 135) Global $hSymptLabel03 = GUICtrlCreateLabel("Téléphone utilisateur : ", 250, 140) Global $hInput02 = GUICtrlCreateInput("0", 360, 135) Global $hRish = _GUICtrlRichEdit_Create($GUI3, "Symptôme(s) : " & @CRLF, _ 50, 180, 710, 240, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Global $OKGO = GUICtrlCreateButton("Go", 50, 450) WinSetOnTop($GUI3, "", 1) GUISetState(@SW_SHOW, $GUI3) ;~ GUISetState(@SW_HIDE, $GUI3) ;Unused state for this reproducer Func1000() Func Func1000() ;~ _CleanAndWait () ;Unused fonction for this reproducer GUISetState(@SW_SHOW, $GUI3) While 1 Sleep(10) $hTexte = _GUICtrlRichEdit_GetText($hRish) _ReadString($hTexte, "big ip", "vpn", "allo") Local $hNMsg = GUIGetMsg($GUI3) Switch $hNMsg Case $OKGO WinSetOnTop($GUI3, "", 0) GUISetState(@SW_HIDE, $GUI3) ;~ ClipPut($hTexte) ;~ _SendAvSaPrPa ($hTexte) ;Unused fonction for this reproducer ;~ _RestorePP () ;Unused fonction for this reproducer ExitLoop Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $GUI3) ExitLoop EndSwitch WEnd EndFunc ;==>Func1000 Func OpenLink() ;Nothing for now ConsoleWrite("+1" & @CRLF) EndFunc ;==>OpenLink Func _ReadString($TexteStringToCheck = "", $String1 = Null, $String2 = Null, $String3 = Null, $String4 = Null, $String5 = Null, $String6 = Null, $String7 = Null) local $sMsg, $sp1, $sp2, $sp3,$sp4,$sp5,$sp6,$sp7 if $String1 <> Null then $sp1 = StringInStr($TexteStringToCheck, $String1) if $String2 <> Null then $sp2 = StringInStr($TexteStringToCheck, $String2) if $String3 <> Null then $sp3 = StringInStr($TexteStringToCheck, $String3) If $sp1 Then $sMsg &= "BIG IP" If $sp2 Then $sMsg &= " -Keywords2" If $sp3 Then $sMsg &= " -Keywords3" _CreateThread1_ToolTip($sMsg) EndFunc ;==>_ReadString Func _CreateThread1_ToolTip($sMsg) if $Tooltiptext <> $sMsg then ToolTip($sMsg, 1, 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sMsg = ' & $sMsg & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Tooltiptext = $sMsg EndIf EndFunc ;==>_CreateThread1_ToolTip Func _Exit() WinSetOnTop($GUI3, "", 0) Local $cExitYesNo = MsgBox($MB_YESNO, "Quitter?", "Voulez-vous quitter ?") If $cExitYesNo = "6" Then Exit Else WinSetOnTop($GUI3, "", 1) EndIf EndFunc ;==>_Exit Study that and see how you can adapt it to your needs. Jos1 point
-
Good to see you again active on the forum. As to ATCmd.au3 I must check it again and make some guideline how use them, as this is strongly related to the device you choose, and to GSM operator you have.1 point
-
Logic help
FrancescoDiMuro reacted to Jos for a topic
Well... try to think about this for a moment yourself first! What is the result of StringInstr() when and error is encountered and what is the content of @error ?1 point -
Not even going to try to have a detailed look at the code when it isn't runnable and showing the issue, but what are you expecting this quoted code to do?1 point
-
Hey, I usually use a timer for stuff I don't want to trigger as often as they would do. Do whatever to collect the data and only present it after a certain amount has passed. Another thing that comes to my mind is instead of multithreading, you could have another script that would check the contents of the richedit of the first script. And change first script to auto-start it perhaps.1 point
-
Calling all RegEx Masters...
JockoDundee reacted to AspirinJunkie for a topic
You don't understand because you modified the task. As jockodundee stated, the task in a large string is to shorten all 5-character words to 4-character words. You modify the task so that all single moves are already separated in an array. But that was not the task.1 point -
Calling all RegEx Masters...
FrancescoDiMuro reacted to JockoDundee for a topic
Why indeed? Maybe because this: $x = StringLeft($x, 4) cuts off the whole movelist except for the first, when used on the sample string: f4e5 d7d6 g1f3 d6e5 f3e5q f8d6 e5f3 g8f6 g2g3 f6g4 b1c3q h7h5 d2d4s h5h4 h1g1 b8c6 c1g5 f7f6 g5f4 h4g3 h2g3 g7g5 f4d6 to your point, currently I am doing something like $arrMoveList=StringSplit($sMoveList, " ",2) For $sMove In $arrMoveList $sFixedMoveList&=StringLeft($sMove,4) & " " Next but that's not quite the same, right? Anyway, I tried your test - there's good news and bad: Good news - You're the fastest - Bad news - your output is off: MoveList: f4e5 d7d6 g1f3 d6e5 f3e5q f8d6 e5f3 g8f6 g2g3 f6g4 b1c3q h7h5 d2d4s h5h4 h1g1 b8c6 c1g5 f7f6 g5f4 h4g3 h2g3 g7g5 f4d6 d8d6 d1d2 Solutions: 1: \b\w{4}\K\w 2: (?<=\w{4})\w 3: My Loop Code 4: StringLeft($txt, 4) Output: 1: f4e5 d7d6 g1f3 d6e5 f3e5 f8d6 e5f3 g8f6 g2g3 f6g4 b1c3 h7h5 d2d4 h5h4 h1g1 b8c6 c1g5 f7f6 g5f4 h4g3 h2g3 g7g5 f4d6 d8d6 d1d2 2: f4e5 d7d6 g1f3 d6e5 f3e5 f8d6 e5f3 g8f6 g2g3 f6g4 b1c3 h7h5 d2d4 h5h4 h1g1 b8c6 c1g5 f7f6 g5f4 h4g3 h2g3 g7g5 f4d6 d8d6 d1d2 3: f4e5 d7d6 g1f3 d6e5 f3e5 f8d6 e5f3 g8f6 g2g3 f6g4 b1c3 h7h5 d2d4 h5h4 h1g1 b8c6 c1g5 f7f6 g5f4 h4g3 h2g3 g7g5 f4d6 d8d6 d1d2 4: f4e5 Timings for 1000000: 1: 1000000 Runs 5.061 2: 1000000 Runs 6.291 3: 1000000 Runs 37.46 4: 1000000 Runs 1.145 Anyway, let me have the rest of the code you had in mind, and I can plug it in....1 point -
Tested on Win10 : ; adapted from DanyFirex and xMatz code #include <GuiConstants.au3> #include <Constants.au3> Global Const $S_OK = 0 Global Enum $eRender, $eCapture Global Enum $eConsole, $eMultimedia, $eCommunications Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr);" Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $tagIMMDevice = "Activate hresult(clsid;dword;variant*;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(ptr*);" & _ "GetState hresult(dword*);" Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" Global Const $tagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _ "GetMeteringChannelCount hresult(dword*);" & _ "GetChannelsPeakValues hresult(dword;float*);" & _ "QueryHardwareSupport hresult(dword*);" Global $oAudioMeterInformation = _MicVolObject() If Not IsObj($oAudioMeterInformation) Then Exit MsgBox ($MB_SYSTEMMODAL,"Error","Unable to mic audio meter") Global $hGUI = GUICreate("", 80, 300, -1, -1, $WS_BORDER + $WS_POPUP) Global $hControl = GUICtrlCreateProgress(20, 20, 40, 260, $PBS_VERTICAL) AdlibRegister("_LevelMeter", 45) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd AdlibUnRegister() Func _LevelMeter() Local $iPeak If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then $iCurrentRead = 100 * $iPeak GUICtrlSetData($hControl, $iCurrentRead) If $iCurrentRead Then ConsoleWrite($iCurrentRead & @CRLF) EndIf EndFunc ;==>_LevelMeter Func _MicVolObject() Local Const $CLSCTX_INPROC_SERVER = 0x1 Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator) If @error Then Return SetError(1, 0, 0) Local $pDefaultDevice $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eCapture, $eConsole, $pDefaultDevice) If Not $pDefaultDevice Then Return SetError(2, 0, 0) Local $oDefaultDevice = ObjCreateInterface($pDefaultDevice, $sIID_IMMDevice, $tagIMMDevice) If Not IsObj($oDefaultDevice) Then Return SetError(3, 0, 0) Local $pAudioMeterInformation $oDefaultDevice.Activate($sIID_IAudioMeterInformation, $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation) If Not $pAudioMeterInformation Then Return SetError(4, 0, 0) Return ObjCreateInterface($pAudioMeterInformation, $sIID_IAudioMeterInformation, $tagIAudioMeterInformation) EndFunc ;==>_MicVolObject1 point
-
Multiple cells. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ;#include <Array.au3> Opt( "MustDeclareVars", 1 ) Global $hGui, $hLV ; $aMarkedCells is used to store columns with marked cells. Line (index) in $aMarkedCells is stored in ItemParam. When all ; marks in a row are cleared the line in question in $aMarkedCells can be reused. Line (index) is stored in $aNotUsedLines. Global $iMarkedCells = 0, $aMarkedCells[10][4] ; Col 3 = number of marked cells per row Global $iNotUsedLines = 0, $aNotUsedLines[10] MainFunc() Func MainFunc() $hGui = GUICreate( "Mark Cells in Listview", 250, 222, 300, 300 ) Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", 2, 2, 250-4, 222-4 ), $idx $hLV = ControlGetHandle( $hGui, "", $idLV ) ; ItemParam will be used to keep track of marked cells ; Create rows with _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem ; (For rows created with GUICtrlCreateListViewItem ControlID is stored in ItemParam) For $i = 0 To 49 $idx = _GUICtrlListView_AddItem( $hLV, "Cell " & $i & ".0" ) _GUICtrlListView_AddSubItem( $hLV, $idx, "Cell " & $i & ".1", 1 ) _GUICtrlListView_AddSubItem( $hLV, $idx, "Cell " & $i & ".2", 2 ) ;GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV ) Next GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState() While 1 Switch GUIGetMsg() ;Case $GUI_EVENT_SECONDARYDOWN ; _ArrayDisplay( $aMarkedCells, "$aMarkedCells" ) ; _ArrayDisplay( $aNotUsedLines, "$aNotUsedLines" ) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $iParam, $aInfo $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam ) $iItem = DllStructGetData( $tNMLISTVIEW, "Item" ) $iParam = DllStructGetData( $tNMLISTVIEW, "Param" ) _GUICtrlListView_SetItemSelected( $hLV, $iItem, False ) $aInfo = GUIGetCursorInfo( $hGui ) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0]-2, $aInfo[1]-2 ) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If Not $iParam Then ; First mark in row Local $idxMarkedCells If $iNotUsedLines Then ; Unused lines in $aMarkedCells? $idxMarkedCells = $aNotUsedLines[$iNotUsedLines-1] $iNotUsedLines -= 1 Else ; Allocate a new line in $aMarkedCells? $idxMarkedCells = $iMarkedCells $iMarkedCells += 1 If Mod( $iMarkedCells, 10 ) = 0 Then _ ReDim $aMarkedCells[$iMarkedCells+10][4] EndIf $aMarkedCells[$idxMarkedCells][3] = 1 $aMarkedCells[$idxMarkedCells][$aInfo[1]] = 1 _GUICtrlListView_SetItemParam( $hLV, $iItem, $idxMarkedCells + 1 ) Else $iParam -= 1 If Not $aMarkedCells[$iParam][$aInfo[1]] Then ; Add mark in row $aMarkedCells[$iParam][$aInfo[1]] = 1 $aMarkedCells[$iParam][3] += 1 Else ; Del mark in row $aMarkedCells[$iParam][$aInfo[1]] = 0 $aMarkedCells[$iParam][3] -= 1 If Not $aMarkedCells[$iParam][3] Then _GUICtrlListView_SetItemParam( $hLV, $iItem, 0 ) ; When all marks in a row are cleared store the line (index) from $aMarkedCells in ; $aNotUsedLines. This line can be reused to store marks in another row in the LV. $aNotUsedLines[$iNotUsedLines] = $iParam $iNotUsedLines += 1 If Mod( $iNotUsedLines, 10 ) = 0 Then _ ReDim $aNotUsedLines[$iNotUsedLines+10] EndIf EndIf EndIf _GUICtrlListView_RedrawItems( $hLV, $iItem, $iItem ) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem Local $lItemlParam = DllStructGetData( $tNMLVCUSTOMDRAW, "lItemlParam" ) ; Item param Local $iSubItem = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem" ) ; Subitem index Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state If $lItemlParam Then ; Marked row If $aMarkedCells[$lItemlParam-1][$iSubItem] Then ; Marked column DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0x00FFFF ) ; Backcolor yellow, BGR Else DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xFFFF00 ) ; Backcolor cyan, BGR EndIf Else ; Other columns If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) ; Forecolor white DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) ; Backcolor dark blue, BGR Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) ; Backcolor white EndIf EndIf Else ; Other rows If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) EndIf EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc1 point