eignxing
Active Members-
Posts
28 -
Joined
-
Last visited
Recent Profile Visitors
215 profile views
eignxing's Achievements
Seeker (1/7)
1
Reputation
-
I'm trying to write a script that will select text in notepad. Someone asked me to write a program that would work like the "Find" function in notepad. Everything works great except I can't figure out how to set the caret position and select text in the window. Can anyone point me in the right direction?
-
Skitty reacted to a post in a topic: autoit icon file
-
I created a script to monitor process memory usage over time and another script to graph that. I not really motivated to do any more work on it, but I thought someone might be able to use or improve on it. The script checks processes and memory used every minute and records it to log files. You have to run the process monitor for a little while before there is any data to plot with the graph script. Thanks to andybiochem for The attachment below is a modified version to include text. modified gdiplus udf and scripts: GraphGDIPlus.au3 process monitor.au3 process graph.au3 process monitor script: #Include <Array.au3> Global $process_file, $t_diff2 = 0 $data_dir = @WorkingDir&"/Data" $t_init2 = TimerInit() $t_init = TimerInit() $x = 1 While $t_diff2/1000/60/60 <= 24 $processlist_ar = ProcessList() $tCur = String(@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC) Sleep(10000) $t_diff2 = TimerDiff($t_init2) If TimerDiff($t_init) >= 60000 Then $t_init = TimerInit() $i = 1 Do $processstats_ar = ProcessGetStats($processlist_ar[$i][1], 0) If IsArray($processstats_ar) Then $processstats_ar[0] = $processstats_ar[0]/1024 $processstats_ar[1] = $processstats_ar[1]/1024 If FileExists($data_dir&"/"&$processlist_ar[$i][0]&".log") = 0 Then $process_file = FileOpen($data_dir&"/"&$processlist_ar[$i][0]&".log", 2) Else $process_file = FileOpen($data_dir&"/"&$processlist_ar[$i][0]&".log", 1) EndIf FileWriteLine($process_file, $processlist_ar[$i][0]&"<>"&$processstats_ar[0]&"<>"&$tCur) FileClose($process_file) EndIf $i = $i + 1 Until $i = $processlist_ar[0][0] EndIf $x = $x + 1 WEnd process graph script: #include <GraphGDIPlus.au3> #Include <File.au3> #Include <Array.au3> #Include <Date.au3> Opt("GUIOnEventMode", 1) $desktopW = @DesktopWidth-20 $desktopH = @DesktopHeight-60 $GUI = GUICreate("",$desktopW,$desktopH, -1, 0) GUISetBkColor(0x000000) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem3 = GUICtrlCreateMenuItem("Zoom In", $MenuItem1) GUICtrlSetOnEvent(-1, "_zoomin") $MenuItem2 = GUICtrlCreateMenuItem("Zoom Out", $MenuItem1) GUICtrlSetOnEvent(-1, "_zoomout") $separator1 = GUICtrlCreateMenuItem("", $MenuItem1, 2) $MenuItem11 = GUICtrlCreateMenuItem("30 Minutes", $MenuItem1) GUICtrlSetOnEvent(-1, "_30min") $MenuItem10 = GUICtrlCreateMenuItem("2 Hours", $MenuItem1) GUICtrlSetOnEvent(-1, "_120min") $MenuItem4 = GUICtrlCreateMenuItem("12 Hours", $MenuItem1) GUICtrlSetOnEvent(-1, "_12hrs") $MenuItem5 = GUICtrlCreateMenuItem("24 Hours", $MenuItem1) GUICtrlSetOnEvent(-1, "_24hrs") $MenuItem6 = GUICtrlCreateMenuItem("3 Days", $MenuItem1) GUICtrlSetOnEvent(-1, "_3days") $MenuItem7 = GUICtrlCreateMenuItem("1 Week", $MenuItem1) GUICtrlSetOnEvent(-1, "_1week") $MenuItem8 = GUICtrlCreateMenuItem("1 Month", $MenuItem1) GUICtrlSetOnEvent(-1, "_1mnth") $MenuItem9 = GUICtrlCreateMenuItem("3 Months", $MenuItem1) GUICtrlSetOnEvent(-1, "_3mnth") $MenuItem9 = GUICtrlCreateMenuItem("6 Months", $MenuItem1) GUICtrlSetOnEvent(-1, "_6mnth") GUISetOnEvent(-3,"_Exit") GUISetState() $data_dir = @WorkingDir&"/Data" $date_now = String(@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC) ;----- Create Graph area ----- Global $hMem = 100000, $xticks = 24, $xlabels = 24, $tick_every = 1, $xtimeframe = 24*60*60 $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Set_GridX($Graph,1,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) Func _zoomin() _GraphGDIPlus_Delete($GUI,$Graph) $hMem = Round($hMem*.5, 0) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _zoomout() _GraphGDIPlus_Delete($GUI,$Graph) $hMem = Round($hMem*1.5, 0) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _30min() $xtimeframe = 60*30 $xticks = 30 $xlabels = 30 $tick_every = 5 _GraphGDIPlus_Delete($GUI,$Graph) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _120min() $xtimeframe = 120*60 $xticks = 120 $xlabels = 15 $tick_every = 4 _GraphGDIPlus_Delete($GUI,$Graph) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _12hrs() $xtimeframe = 12*60*60 $xticks = 12 $xlabels = 12 $tick_every = 1 _GraphGDIPlus_Delete($GUI,$Graph) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _24hrs() $xtimeframe = 24*60*60 $xticks = 24 $xlabels = 24 $tick_every = 1 _GraphGDIPlus_Delete($GUI,$Graph) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _3days() $xtimeframe = 36*60*60 $xticks = 36 $xlabels = 12 $tick_every = 1 _GraphGDIPlus_Delete($GUI,$Graph) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _1week() $xtimeframe = 168*60*60 $xticks = 168 $xlabels = 12 $tick_every = 4 _GraphGDIPlus_Delete($GUI,$Graph) $Graph = _GraphGDIPlus_Create($GUI,60,20,$desktopW*.93,$desktopH*.9,0xFF3F3F3F,0xFF000000) _GraphGDIPlus_Set_RangeX($Graph,0,$xticks ,$xlabels,1,0) _GraphGDIPlus_Set_RangeY($Graph,0,$hMem,20,1,0) _GraphGDIPlus_Refresh($Graph) _GraphGDIPlus_Set_GridX($Graph,$tick_every,0xFF3F3F3F) _GraphGDIPlus_Set_GridY($Graph,$hMem*.10,0xFF3F3F3F) _Draw_Graph() EndFunc Func _1mnth() EndFunc Func _3mnth() EndFunc Func _6mnth() EndFunc ;----- Draw the graph ----- _Draw_Graph() While 1 Sleep(100) WEnd Func _Draw_Graph() $filelist_ar = _FileListToArray($data_dir, "*.log", 1) Dim $fileinfo_ar[$filelist_ar[0]][4] ;processname, color, max_memory_index, max memory index time $i = 1 Do $fileinfo_ar[$i][1] = _RandClr() $process_file = FileOpen($data_dir&"/"&$filelist_ar[$i], 0) $n = _FileCountLines($data_dir&"/"&$filelist_ar[$i]) _GraphGDIPlus_Set_PenColor($Graph, $fileinfo_ar[$i][1]) _GraphGDIPlus_Set_PenSize($Graph,2) $lineread = FileReadLine($process_file) $div1 = StringInStr($lineread, "<>", 0, 1) $fileinfo_ar[$i][0] = StringLeft($lineread, $div1-1) $div2 = StringInStr($lineread, "<>", 0, 2) $memory_point = StringMid($lineread, $div1+2, $div2-$div1-2) ;memory $timestamp = StringRight($lineread, StringLen($lineread)-$div2-1) ;timestamp $date_diff = _DateDiff("s", $timestamp, $date_now) $fileinfo_ar[$i][3] = 0 _GraphGDIPlus_Plot_Start($Graph,(($xtimeframe-$date_diff)/$xtimeframe)*$xticks,$memory_point) $j = 2 Do $lineread = FileReadLine($process_file) $div1 = StringInStr($lineread, "<>", 0, 1) $div2 = StringInStr($lineread, "<>", 0, 2) $memory_point = StringMid($lineread, $div1+2, $div2-$div1-2) ;memory $timestamp = StringRight($lineread, StringLen($lineread)-$div2-1) ;timestamp $date_diff = _DateDiff("s", $timestamp, $date_now) ;FileSetPos ($process_file, -StringLen($lineread)*2, 1) If $memory_point <> 0 Then If $memory_point < $hMem Then If $date_diff < $xtimeframe Then If $memory_point > $fileinfo_ar[$i][2] Then $fileinfo_ar[$i][2] = $memory_point $fileinfo_ar[$i][3] = $date_diff EndIf If $n = 1 Then _GraphGDIPlus_Plot_Dot($Graph,(($xtimeframe-$date_diff)/$xtimeframe)*$xticks,$memory_point) Else $timestamp2 = StringRight(FileReadLine($process_file), StringLen($lineread)-$div2-1) ;timestamp $internal_dif = _DateDiff("s", $timestamp, $timestamp2) If $internal_dif <= 63 Then _GraphGDIPlus_Plot_Line($Graph,(($xtimeframe-$date_diff)/$xtimeframe)*$xticks,$memory_point) Else _GraphGDIPlus_Plot_Start($Graph,(($xtimeframe-$date_diff+$internal_dif)/$xtimeframe)*$xticks,$memory_point) EndIf EndIf Else _GraphGDIPlus_Plot_Start($Graph,(($xtimeframe-$date_diff)/$xtimeframe)*$xticks,$memory_point) EndIf Else _GraphGDIPlus_Plot_Start($Graph,(($xtimeframe-$date_diff)/$xtimeframe)*$xticks,$memory_point) EndIf EndIf $j = $j + 1 Until $j >= $n FileClose($process_file) _GraphGDIPlus_Refresh($Graph) IF $fileinfo_ar[$i][3] = 0 Then $fileinfo_ar[$i][3] = Random(0, $xtimeframe-20, 1) EndIf $i = $i + 1 Until $i = $filelist_ar[0] $i = 1 Do If $fileinfo_ar[$i][2] < $hMem And $fileinfo_ar[$i][3] <> 0 And $fileinfo_ar[$i][2] <> 0 Then If ($xtimeframe-$fileinfo_ar[$i][3])/$xtimeframe*$xticks < 5 Then _GraphGIDPlus_Plot_Text($Graph, Random(5, 10, 1), $fileinfo_ar[$i][2], $fileinfo_ar[$i][0], $fileinfo_ar[$i][1], 8, "Arial") ;$aGraphArray, $iX, $iY, $iText, $iColor) Else _GraphGIDPlus_Plot_Text($Graph, (($xtimeframe-$fileinfo_ar[$i][3])/$xtimeframe)*$xticks, $fileinfo_ar[$i][2], $fileinfo_ar[$i][0], $fileinfo_ar[$i][1], 8, "Arial") ;$aGraphArray, $iX, $iY, $iText, $iColor) EndIf ;MsgBox(0, "($xtimeframe-$fileinfo_ar[$i][3])/$xtimeframe)*$xticks", ($xtimeframe-$fileinfo_ar[$i][3])/$xtimeframe*$xticks) EndIf $i = $i + 1 Until $i = $filelist_ar[0] EndFunc Func _RandClr() Return "0xFF" & Hex(Random(0, 16777215, 1), 6) EndFunc Func _Exit() ;----- close down GDI+ and clear graphic ----- _GraphGDIPlus_Delete($GUI,$Graph) Exit EndFunc
-
_ArrayCombinations function is erroring
eignxing replied to eignxing's topic in AutoIt General Help and Support
Thanks all, works great now. Never had time to take a look for myself. -
Hey guys, while testing a program using this function I am getting an error when using the following parameters: _ArrayCombinations($array, 3, ",") Where the size of $array is 8. The strange thing is that it seems to work with sizes 7 and below and sizes 9 and greater. I don't have time to look at it this morning, but I'll come back later and see if I can figure it out.
-
I'm having trouble getting the window info necessary to close the IE pop-up. Is there a simple way to do this? I searched everywhere on the forums but couldn't implement any of the ideas. You can see an example of the popup here: www.samisite.com/test-csb2nf/id108.htm I just want to click okay, ideally without using pixel searching or coordinates.
-
Thanks all for the input, it's working perfectly now.
-
I have a folder named "AutoIt" on the desktop. I open the folder so it's visible. I run the script with the line above and it executes without closing the window or throwing any warnings/errors.
-
For some reason I can't get the following line of code to work. I'm using v3.3.1.2 (beta). WinClose("AutoIt") That command seems to work with any other window title name besides AutoIt. Why?
-
I wasn't sure where else to post this. Original design by weaponx. Thanks weaponx. icon.ico
-
Close any window open only from a certain drive
eignxing replied to eignxing's topic in AutoIt General Help and Support
I solved the problem. Thanks to Nahuel for the code here: http://www.autoitscript.com/forum/index.php?showtopic=86825&st=0&p=623064&hl=get%20window%20path&fromsearch=1&#entry623064 $ExWin = "[REGEXPCLASS:(Cabinet|Explore)WClass]" $AddBar = "[CLASS:Edit; INSTANCE:1]" $Explorers = WinList($ExWin) Dim $DirsOp[$Explorers[0][0]] For $i=1 To $Explorers[0][0] $DirsOp[$i-1] = ControlGetText($Explorers[$i][1],"",$AddBar) If StringInStr($DirsOp[$i-1], "F:\") <> 0 Then WinClose($Explorers[$i][1]) EndIf Next -
Close any window open only from a certain drive
eignxing replied to eignxing's topic in AutoIt General Help and Support
Thanks, I've found how to remove the device automatically and safely while clearing the memory (there is a post on the forum which works well somewhere), but it won't work unless all the processes are closed. I guess what I'm really after is a way to get the path of a target window or process. Actually I just need the path of a target window. -
I have a removable drive with a file located at F:\testdir\subdir\file.txt I need a script to close an open window if there is one opened on the removable drive so I can safely remove it without problems. I've tried using If winexists("Removable Drive (F:)") then winclose("Removable Drive (F:)") but that only works if the open window is the root removable drive... there could be other windows with say "subdir" open on the parent drive that should not automatically be closed. Just to be clear, say I have a window open with the path F:\testdir\subdir\ and I also have a window open with the path C:\subdir\. They both have the same window title, but only the window open on F:\ should be closed. Does anyone know of a way to do this? I'm just having a hard time thinking of how to solve this right now.
-
Thanks, you can edit the text by double clicking. I added a simple marker option on right-click to show completed or not (updated in post). I don't think I will add levels of completion though. Thanks for the ideas.
-
Thanks, you should be able to sort by clicking the column headers
-
Here is a ToDo List that is simple and easy to use. Thanks to a lot of people on the forums that I borrowed code from- namely the ones who posted about listview inline edit and color for the rows. It was good to learn from. Add entries by pressing enter delete entries by right clicking double click to edit entries closing saves the list comments welcome, enjoy! EDIT: added multiple listview selection new option for right click to add/remove marker added delete button #include <GuiConstants.au3> #include <GuiEdit.au3> #include <Date.au3> #include <File.au3> #include <GUIListView.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <Misc.au3> Opt("TrayIconHide", 1) $dll = DllOpen("user32.dll") Global $hEdit, $hDC, $hBrush, $Item = -1, $SubItem = 0 Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT) Global $iLastItem = -1, $iLastsubitemNR = -1 Global $timestart = TimerInit() $version = "1.3" If WinExists("ToDo v"&$version) <> 0 Then WinActivate("ToDo v"&$version) Exit EndIf $main_form = GUICreate("ToDo v"&$version, 585, 345, 235, 193) $filemenu = GUICtrlCreateMenu("&File") $menu_options = GUICtrlCreateMenuItem("Options", $filemenu) $MenuItem1 = GUICtrlCreateMenuItem("", $filemenu) $menu_exit = GUICtrlCreateMenuItem("Exit", $filemenu) $listview = GUICtrlCreateListView("No.|ToDo Items|Time Created", 8, 8, 568, 265, $LVS_REPORT) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 30) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 390) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 144) $add_input = GUICtrlCreateInput("", 8, 288, 329, 21) $add_button = GUICtrlCreateButton("Add", 352, 288, 46, 25, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP)) $exit_button = GUICtrlCreateButton("Exit", 477, 288, 98, 25, $WS_GROUP) $delete_button = GUICtrlCreateButton("Delete", 408, 288, 59, 25, $WS_GROUP) GUISetState(@SW_SHOW) $hListView = GUICtrlGetHandle($listview) $working_dir = @WorkingDir Local $aFontBold = DllCall("gdi32.dll", "int", "CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 700, _ "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _ "dword", 0, "str", "") Local $aFontItalic = DllCall("gdi32.dll", "int", "CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 400, _ "dword", 1, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _ "dword", 0, "str", "") GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() $options_form = GUICreate("Options", 312, 170, 273, 259) $arrangebytime_cb = GUICtrlCreateCheckbox("Right click deletes items", 16, 16, 217, 17) ;GUICtrlSetState(-1, $GUI_DISABLE) $usecolors_cb = GUICtrlCreateCheckbox("Use colors (experimental)", 16, 48, 257, 17) $clearcomplete_cb = GUICtrlCreateCheckbox("Option 3", 16, 80, 273, 17) GUICtrlSetState(-1, $GUI_DISABLE) $done_button = GUICtrlCreateButton("Done", 16, 128, 75, 25, $WS_GROUP) $cancel_button = GUICtrlCreateButton("Cancel", 112, 128, 75, 25, $WS_GROUP) GUISetState(@SW_HIDE) $settingsarray = _readsettings() ;3 settings to read If FileExists($working_dir & "\todolist.ini") = 1 Then $todolist_file = FileOpen($working_dir & "\todolist.ini", 0) $todolist_lines = _FileCountLines($working_dir & "\todolist.ini") GUICtrlSetData($listview, "No.|ToDo Items: ("&$todolist_lines&")|Time Created") If $todolist_lines <> 0 Then Dim $todo_ar[$todolist_lines][3] Else Dim $todo_ar[1][3] EndIf If $todolist_lines >= 1 Then $i = 1 Do $divider1 = StringInStr(FileReadLine($todolist_file, $i), "¥") $divider2 = StringInStr(FileReadLine($todolist_file, $i), "§") $date = StringMid(FileReadLine($todolist_file, $i), $divider1 + 1, 19) $color = 0 $memoitem = StringLeft(FileReadLine($todolist_file, $i), $divider1 - 1) $todo_ar[$i - 1][0] = $memoitem $todo_ar[$i - 1][1] = $date $todo_ar[$i - 1][2] = $color GUICtrlCreateListViewItem($i & "|" & $memoitem & "|" & $date, $listview) $i = $i + 1 Until $i = $todolist_lines + 1 _GUICtrlListView_EnsureVisible($hListView, $todolist_lines-1) EndIf FileClose($todolist_file) Else $todolist_file = FileOpen($working_dir & "\todolist.ini", 2) Dim $todo_ar[1][3] FileClose($todolist_file) EndIf $todo_ar = _constructcolors() _WinAPI_RedrawWindow($hListView) _GUICtrlListView_RegisterSortCallBack($hListView) _GUICtrlListView_SortItems($hListView, 2) GUICtrlSetState($add_input, $GUI_FOCUS) While 1 $nMsg = GUIGetMsg() If _IsPressed("2E", $dll) Then _GUICtrlListView_DeleteItemsSelected($hListView) ;GUICtrlSetState($add_input, $GUI_FOCUS) EndIf Switch $nMsg Case $GUI_EVENT_CLOSE If WinGetState("Options") <> 15 Then _exit() Else GUISetState(@SW_HIDE, "Options") _readsettings() EndIf Case $menu_exit _exit() Case $menu_options _readsettings() GUISetState(@SW_SHOW, "Options") Case $cancel_button GUISetState(@SW_HIDE, "Options") _readsettings() Case $delete_button ; $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) ;_GUICtrlListView_DeleteItem($hListView, DllStructGetData($tInfo, "Index")) _GUICtrlListView_DeleteItemsSelected($hListView) GUICtrlSetData($listview, "No.|ToDo Items ("&_GUICtrlListView_GetItemCount($listview)&")|Time Created") Case $done_button _writesettings() GUISetState(@SW_HIDE, "Options") Case $add_button If GUICtrlRead($add_input) = "" Then Else $stamp = @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC $addnum = _GUICtrlListView_GetItemCount($listview) _GUICtrlListView_AddItem($hListView, $addnum+1, 0) _GUICtrlListView_AddSubItem($hListView, $addnum, GUICtrlRead($add_input), 1, 1) _GUICtrlListView_AddSubItem($hListView, $addnum, $stamp, 2, 1) _GUICtrlListView_EnsureVisible($hListView, $addnum) GUICtrlSetData($listview, "No.|ToDo Items: ("&_GUICtrlListView_GetItemCount($listview)&")|Time Created") GUICtrlSetData($add_input, "") GUICtrlSetState($add_input, $GUI_FOCUS) EndIf Case $exit_button _exit() EndSwitch WEnd Func _exit() FileClose($todolist_file) If _GUICtrlListView_GetItemCount($listview) <> 0 Then FileOpen($working_dir & "\todolist.ini", 2) $l = 0 Do FileWriteLine($working_dir & "\todolist.ini", _GUICtrlListView_GetItemText($hListView, $l, 1) & "¥" & _GUICtrlListView_GetItemText($hListView, $l, 2) & "§Color") $l = $l + 1 Until $l = _GUICtrlListView_GetItemCount($listview) FileClose($working_dir & "\todolist.ini") Else FileDelete($working_dir & "\todolist.ini") EndIf _GUICtrlListView_UnRegisterSortCallBack($listview) DllClose($dll) GUIDelete() Exit EndFunc ;==>_exit Func _readsettings() Dim $settings_ar[3] If FileExists($working_dir & "\settings.ini") = 1 Then $settings_file = FileOpen($working_dir & "\settings.ini", 0) If StringInStr(FileReadLine($settings_file, 1), "arrangebytime_cb=0") <> 0 Then GUICtrlSetState($arrangebytime_cb, 4) $settings_ar[0] = 4 Else GUICtrlSetState($arrangebytime_cb, 1) $settings_ar[0] = 1 EndIf If StringInStr(FileReadLine($settings_file, 2), "usecolors_cb=0") <> 0 Then GUICtrlSetState($usecolors_cb, 4) $settings_ar[1] = 4 Else GUICtrlSetState($usecolors_cb, 1) $settings_ar[1] = 1 EndIf If StringInStr(FileReadLine($settings_file, 3), "clearcomplete_cb=0") <> 0 Then GUICtrlSetState($clearcomplete_cb, 4) $settings_ar[2] = 4 Else GUICtrlSetState($clearcomplete_cb, 1) $settings_ar[2] = 1 EndIf FileClose($settings_file) Else $settings_file = FileOpen($working_dir & "\settings.ini", 2) FileWriteLine($settings_file, "arrangebytime_cb=0") GUICtrlSetState($arrangebytime_cb, 4) $settings_ar[0] = 4 FileWriteLine($settings_file, "usecolors_cb=0") GUICtrlSetState($usecolors_cb, 4) $settings_ar[1] = 4 FileWriteLine($settings_file, "clearcomplete_cb=0") GUICtrlSetState($clearcomplete_cb, 4) $settings_ar[2] = 4 FileClose($settings_file) EndIf Return $settings_ar EndFunc ;==>_readsettings Func _writesettings() $settings_file = FileOpen($working_dir & "\settings.ini", 2) If GUICtrlRead($arrangebytime_cb) = 4 Then FileWriteLine($settings_file, "arrangebytime_cb=0") Else FileWriteLine($settings_file, "arrangebytime_cb=1") EndIf If GUICtrlRead($usecolors_cb) = 4 Then FileWriteLine($settings_file, "usecolors_cb=0") _WinAPI_RedrawWindow($hListView) Else FileWriteLine($settings_file, "usecolors_cb=1") _WinAPI_RedrawWindow($hListView) EndIf If GUICtrlRead($clearcomplete_cb) = 4 Then FileWriteLine($settings_file, "clearcomplete_cb=0") Else FileWriteLine($settings_file, "clearcomplete_cb=1") EndIf FileClose($settings_file) EndFunc ;==>_writesettings Func _constructcolors() _ArraySort($todo_ar, 1, 0, 0, 1) ;most recent to oldest times $diff = _DateDiff('s', $todo_ar[UBound($todo_ar) - 1][1], $todo_ar[0][1]) $colorperc = ($diff / UBound($todo_ar)) / $diff $j = 0 Do $tmp = 0 & ";" & (UBound($todo_ar) + 1 - $j) * (200 * $colorperc) & ";" & 0 $nRGB = _ColorSwitch($tmp) $todo_ar[$j][2] = $nRGB $j = $j + 1 Until $j = UBound($todo_ar) Return ($todo_ar) EndFunc ;==>_constructcolors Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CUSTOMDRAW If GUICtrlRead($usecolors_cb) <> 4 Then If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;' & _ 'dword DrawStage;hwnd hdc;long rect[4];dword ItemSpec;int ItemState;dword Itemlparam;' & _ 'dword clrText;dword clrTextBk;int SubItem;dword ItemType;dword clrFace;int IconEffect;' & _ 'int IconPhase;int PartID;int StateID;long rectText[4];int Align', _;winxp or later $ilParam) Local $iDrawStage, $iItem, $iSubitem, $hDC, $iColor1, $iColor2, $iColor3 $iDrawStage = DllStructGetData($tCustDraw, 'DrawStage') If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW;request custom drawing of items If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW;request drawing each cell separately If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT $iItem = DllStructGetData($tCustDraw, 'ItemSpec') Dim $avArray[1] For $i = 1 To _GUICtrlListView_GetItemCount($hListView) _ArrayAdd($avArray, $i) Next $iIndex = _ArrayToString($avArray, "|") & "|" $color2 = "0xFFFFFF" If $iIndex = -1 Then Return $CDRF_NEWFONT Switch $iItem Case 0 To UBound($todo_ar) DllStructSetData($tCustDraw, 'clrTextBk', _color($iItem)) DllStructSetData($tCustDraw, 'clrText', $color2) EndSwitch Return $CDRF_NEWFONT EndIf Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem")) Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $aRect Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) If ($aHit[0] <> -1) And ($aHit[1] = 0) Then $Item = $aHit[0] $SubItem = 0 $aRect = _GUICtrlListView_GetItemRect($hListView, $Item) ElseIf ($aHit[0] <> -1) And ($aHit[1] > 0) Then $Item = $aHit[0] $SubItem = $aHit[1] $aRect = _GUICtrlListView_GetSubItemRect($hListView, $Item, $SubItem) Else Return $GUI_RUNDEFMSG EndIf Local $iItemText = _GUICtrlListView_GetItemText($hListView, $Item, $SubItem) If $SubItem = 1 Then Local $iLen = 377 Else Local $iLen = 131 EndIf Local $aPos = ControlGetPos($main_form, "", $hListView) Local $iX = $aPos[0] + $aRect[0] + 5 Local $iY = $aPos[1] + $aRect[1] + 2 Global $hEdit = _GUICtrlEdit_Create($main_form, $iItemText, $iX, $iY, $iLen + 10, 17, $Style) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0x000000) FrameRect($hDC, 0, 0, $iLen + 10, 17, $hBrush) Case $NM_RCLICK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) If GUICtrlRead($arrangebytime_cb) <> 4 Then _GUICtrlListView_DeleteItem($hListView, DllStructGetData($tInfo, "Index")) GUICtrlSetData($listview, "No.|ToDo Items: ("&_GUICtrlListView_GetItemCount($listview)&")|Time Created") Else $striketxt = _GUICtrlListView_GetItemText($hListView, DllStructGetData($tInfo, "Index"), 1) If StringInStr($striketxt, Chr(149)&" ") <> 0 Then $striketxt = StringReplace($striketxt, Chr(149)&""&Chr(149)&" ", "") _GUICtrlListView_SetItemText($hListView, DllStructGetData($tInfo, "Index"), $striketxt, 1) Else _GUICtrlListView_SetItemText($hListView, DllStructGetData($tInfo, "Index"), Chr(149)&""&Chr(149)&" "&$striketxt, 1) EndIf EndIf Case $LVN_HOTTRACK ;future tooltip implementation ;If GUICtrlGetState($hListView) = $GUI_FOCUS Then ;~ Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ;~ Local $iItem = DllStructGetData($tInfo, "Item") ;~ Local $subitemNR = DllStructGetData($tInfo, "SubItem") ;~ ; if no cell change return without doing anything ;~ If $iLastItem = $iItem And $iLastsubitemNR = $subitemNR Then Return 0 ;~ $iLastItem = $iItem ;~ $iLastsubitemNR = $subitemNR ;~ If TimerDiff($timestart) >= 1000 Then ;~ Local $sToolTipData = _GUICtrlListView_GetItemText($hListView, $iItem,$subitemNR) ;~ $Mypos = StringInStr ( $sToolTipData, @CRLF ) ;~ ToolTip($sToolTipData, MouseGetPos(0) + 20, MouseGetPos(1) + 20) ;~ ConsoleWrite("R" & $iItem & "C" & $iLastsubitemNR & " No tip" & @CR) ;~ $timestart = TimerInit() ;~ EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF) EndFunc ;==>RGB2BGR Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) EndFunc ;==>FrameRect Func _color($var) $iIt_date = _GUICtrlListView_GetItemText($hListView, $var, 2) ;0 index on lv $todate = _ArraySearch($todo_ar, $iIt_date, 0, 0, 0, 1, 1, 1) If $todate <> -1 Then Return $todo_ar[$todate][2] Else Global $color2 = "0x000000" Return "0xFFFFFF" EndIf EndFunc ;==>_color Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg Local $hWndFrom, $iIDFrom, $hWndEdit, $iCode ; Local $iCode = BitShift($wParam, 16) If Not IsHWnd($hEdit) Then $hWndEdit = GUICtrlGetHandle($hEdit) $hWndFrom = $lParam $iIDFrom = _WinAPI_LoWord($wParam) $iCode = _WinAPI_HiWord($wParam) If _IsPressed("0D", $dll) Then GUICtrlSetState($add_input, $GUI_FOCUS) EndIf Switch $lParam Case $hEdit, $hWndEdit Switch $iCode Case $EN_KILLFOCUS Local $iText = _GUICtrlEdit_GetText($hEdit) _GUICtrlListView_SetItemText($hListView, $Item, $iText, $SubItem) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) $Item = -1 $SubItem = 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _ColorSwitch($ccode) $Symbol = "0x" $ccode = StringReplace($ccode, "0x", "") $ccode = StringReplace($ccode, "#", "") $tCode = StringSplit($ccode, ";") If IsArray($tCode) Then $1 = Hex(Int($tCode[1]), 2) $2 = Hex(Int($tCode[2]), 2) $3 = Hex(Int($tCode[3]), 2) Return $Symbol & $1 & $2 & $3 Else SetError(1) Return -1 EndIf EndFunc ;==>_ColorSwitch