MobaXterm、WindTerm、xshell、finalshell、soureCRT快捷指令工具cxtool-3.8.0
立即下载
资源介绍:
MobaXterm、WindTerm、xshell、finalshell、soureCRT的快捷指令工具
详细说明见:https://blog.csdn.net/bandaoyu/article/details/139336859
Private Counter As Integer
Private ReminderList As Collection
Private ReminderCfgFile As String
Private Const REMINDER_CFG_FILE_NAME = "Reminders.txt"
Private ToAdd As Boolean
Private ToModify As Boolean
Private ToModifyInedx As Long
Private Sub Form_Load()
' 设置 ListView 列宽
With ListView1
.View = lvwReport
.ColumnHeaders.add Text:="index", Width:=150
.ColumnHeaders.add Text:="Date", Width:=1200
.ColumnHeaders.add Text:="Time", Width:=1000
.ColumnHeaders.add Text:="Reminder", Width:=3400
.ColumnHeaders.add Text:="Repeat", Width:=750
.ColumnHeaders.add Text:="Command", Width:=5000
End With
' 设置 Combo1 选项
With Combo1
.AddItem "永不"
.AddItem "每天"
.AddItem "每月"
.AddItem "每年"
End With
' 初始化 Timer1
Timer1.Interval = 1000 * 1 ' 每秒触发一次
Timer1.Enabled = True
ReminderCfgFile = App.Path + "/" + REMINDER_CFG_FILE_NAME
' 加载提醒数据
LoadRemindersFromFile
SetEditingMode False
End Sub
Private Sub btnDelete_Click()
SetEditingMode True
' 删除选中的条目
If Not ListView1.selectedItem Is Nothing Then
ListView1.ListItems.Remove ListView1.selectedItem.Index
End If
If Not ListView1.selectedItem Is Nothing Then
' 选中第一个项目
End If
End Sub
Private Sub SetEditingMode(editing As Boolean)
btnSave.Visible = editing
btnCancel.Visible = editing
Text1.Enabled = editing
Text1.Locked = Not editing
Text2.Enabled = editing
Text2.Locked = Not editing
End Sub
Private Sub btnEditCfg_Click()
open_txt REMINDER_CFG_FILE_NAME
End Sub
Private Sub btnModify_Click()
SetEditingMode True
ToModify = True
For ToModifyInedx = 1 To ListView1.ListItems.Count
If ListView1.ListItems(ToModifyInedx).Selected Then
Exit For
End If
Next ToModifyInedx
End Sub
Private Sub btnAdd_Click()
Dim ReminderDate As Date
Dim ReminderTime As Date
Dim RepeatType As String
Dim ReminderText As String
Dim CommandText As String
SetEditingMode True
btnModify.Visible = False
btnDelete.Visible = False
btnEditCfg.Visible = False
btnAdd.Visible = False
' 清除输入框
DTPicker1.Value = Now
DTPicker2.Value = Now
Text1.Text = ""
Text2.Text = ""
ToAdd = True
End Sub
Private Sub btnCancel_Click()
ToAdd = False
ToModify = False
SetEditingMode False
btnModify.Visible = True
btnDelete.Visible = True
btnEditCfg.Visible = True
btnAdd.Visible = True
RefreshListView
End Sub
Private Sub ListView1_Click()
Dim ItemIndex As Long
' 获取选中项目的索引
For ItemIndex = 1 To ListView1.ListItems.Count
If ListView1.ListItems(ItemIndex).Selected Then
Exit For
End If
Next ItemIndex
If ItemIndex <= ListView1.ListItems.Count Then
DTPicker1.Value = CDate(ListView1.ListItems(ItemIndex).SubItems(1)) ' 显示日期
DTPicker2.Value = CDate(ListView1.ListItems(ItemIndex).SubItems(2)) ' 显示时间
Text1.Text = ListView1.ListItems(ItemIndex).SubItems(3) ' 显示提醒内容
Combo1.Text = ListView1.ListItems(ItemIndex).SubItems(4) ' 显示重复类型
Text2.Text = ListView1.ListItems(ItemIndex).SubItems(5) ' 显示命令
End If
End Sub
Private Sub btnSave_Click()
Dim FileName As String
Dim FileNum As Integer
Dim ListViewItem As ListItem
SetEditingMode False
btnModify.Visible = True
btnDelete.Visible = True
btnEditCfg.Visible = True
btnAdd.Visible = True
If ToAdd = True Then
' 获取输入数据
ReminderDate = DTPicker1.Value
ReminderTime = DTPicker2.Value
RepeatType = Combo1.Text
ReminderText = Text1.Text
CommandText = Text2.Text
' 更新 ListView
Dim newItem As ListItem
Set newItem = ListView1.ListItems.add(, , ListView1.ListItems.Count)
newItem.SubItems(1) = Format(ReminderDate, "yyyy/mm/dd")
newItem.SubItems(2) = Format(ReminderTime, "hh:mm:ss")
newItem.SubItems(3) = ReminderText
newItem.SubItems(4) = RepeatType
newItem.SubItems(5) = CommandText
ToAdd = False
End If
If ToModify = True Then
If ItemIndex <= ListView1.ListItems.Count Then
' 获取输入数据
ReminderDate = DTPicker1.Value
ReminderTime = DTPicker2.Value
RepeatType = Combo1.Text
ReminderText = Text1.Text
CommandText = Text2.Text
ListView1.ListItems(ToModifyInedx).SubItems(1) = ReminderDate
ListView1.ListItems(ToModifyInedx).SubItems(2) = Format(ReminderTime, "hh:mm")
ListView1.ListItems(ToModifyInedx).SubItems(3) = ReminderText
ListView1.ListItems(ToModifyInedx).SubItems(4) = RepeatType
ListView1.ListItems(ToModifyInedx).SubItems(5) = CommandText
End If
ToModify = False
End If
FileName = ReminderCfgFile
' 打开文件
FileNum = FreeFile()
Open FileName For Output As #FileNum
' 写入数据
For Each ListViewItem In ListView1.ListItems
' 获取子项
Dim SubItemsText As String
SubItemsText = ListViewItem.Text & vbTab & DateValue(ListViewItem.ListSubItems(1).Text) & vbTab & TimeValue(ListViewItem.ListSubItems(2).Text) & vbTab & ListViewItem.ListSubItems(3).Text & vbTab & ListViewItem.ListSubItems(4).Text & vbTab & ListViewItem.ListSubItems(5).Text
Print #FileNum, SubItemsText
Next ListViewItem
' 关闭文件
Close #FileNum
MsgBox "Reminders saved successfully.", vbInformation, "Save Reminders"
End Sub
Private Sub LoadRemindersFromFile()
Dim FileName As String
Dim FileNum As Integer
Dim LineData As String
Dim ItemIndex As Long
Dim ReminderDate As Date
Dim ReminderTime As Date
Dim ReminderText As String
Dim RepeatType As String
Dim CommandText As String
FileName = ReminderCfgFile
' 清空 ListView 和 ReminderList
ListView1.ListItems.Clear
' 打开文件
FileNum = FreeFile()
Open FileName For Input As #FileNum
' 读取数据
ItemIndex = 0
Do Until EOF(FileNum)
Line Input #FileNum, LineData
' 检查是否为注释行
If Left(LineData, 1) = "#" Then
' 跳过注释行
GoTo NextLine
End If
' 使用 Split 函数按制表符分隔字符串
Dim Fields() As String
Fields = Split(LineData, vbTab)
' 检查字段数量是否正确
If UBound(Fields) < 4 Then
' 如果字段数量不足,则跳过该行
GoTo NextLine
End If
ReminderDate = CDate(Fields(1))
ReminderTime = TimeValue(Fields(2)) ' 使用 TimeValue 函数转换为时间格式
ReminderText = Fields(3)
RepeatType = Fields(4)
CommandText = Fields(5)
' 更新 ListView 和 ReminderList
Dim SubItems() As Variant
ReDim SubItems(5)
SubItems(0) = ReminderDate
SubItems(1) = Format(ReminderTime, "hh:mm")
SubItems(2) = ReminderText
SubItems(3) = RepeatType
SubItems(4) = CommandText
If Remin