大神帮忙写几个代码,用于“笔录软件”的,想研究下。
本帖最后由 ysldx 于 2020-6-28 21:13 编辑主要问题就是:怎么把文本文件以“问”和“答”分开导入左侧的两个(文本)框中,双击框中的一段内容自动添加到右侧的框中。 左侧的问和答两编辑框都改用List控件,这样就可以方便双击加入右侧的操作了。 afan 发表于 2020-6-29 01:17
左侧的问和答两编辑框都改用List控件,这样就可以方便双击加入右侧的操作了。
谢谢了,我试下,刚学了三五天AUTOIT3,不会再问您啊{:1_174:} 弄不明白,有哪位帮写几个关键代码吗? 本帖最后由 yohoboy 于 2020-7-6 23:53 编辑
;1.編碼改為 65001 不然會亂碼;2. 還沒寫完,後面自行修改。
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiEdit.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <GuiButton.au3>
#include <File.au3>
#include <Array.au3>
Local $GUI_Form1 = GUICreate("筆錄軟體", 1190, 625, 226, 144)
GUICtrlCreateLabel("審問:", 10, 10, 40, 15)
Global $View1 = GUICtrlCreateListView("審問範例|回答1|回答2|回答3", 10, 30, 530, 300)
_GUICtrlListView_SetColumnWidth($View1, 0, 350)
GUICtrlCreateLabel("可選回答:", 10, 340, 60, 15)
Global $View2 = GUICtrlCreateListView("回答範例", 10, 360, 530, 130)
_GUICtrlListView_SetColumnWidth($View2, 0, 500)
GUICtrlCreateLabel("自行輸入:", 10,500, 60, 15)
Global $Edit1 = GUICtrlCreateEdit("$Edit1", 10, 520, 537, 97)
GUICtrlCreateLabel("審問筆錄:", 660,10, 60, 15)
Global $Edit2 = GUICtrlCreateEdit("", 660, 30, 520, 580)
GUICtrlSetData($Edit2, "$Edit2")
$Button1 = GUICtrlCreateButton("選擇文件", 560, 32, 65, 33)
$Button2 = GUICtrlCreateButton("加入右侧", 576, 408, 65, 33)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1 ;開啟樣板
Open_file()
EndSwitch
WEnd
Func Open_file() ;開啟舊檔
Local $a_cvs,$s_temp
_GUICtrlListView_DeleteAllItems($View1) ;刪除舊LIST資料
$s_Path = FileOpenDialog("Select CVS File", @ScriptDir, "All (*.csv)") ;開啟舊檔
If @error Then
MsgBox(4096, "", "未選擇檔案")
Else
_FileReadToArray($s_Path, $a_cvs) ;將檔案讀取到陣列
_ArrayDisplay($a_cvs)
For $i = 1 To UBound($a_cvs) - 1 ;以下兩行將cvs格式轉成listview格式並顯示
$s_temp = StringReplace($a_cvs[$i], ",", "|")
GUICtrlCreateListViewItem($s_temp, $View1)
Next
EndIf
EndFunc
看得云里雾里 楼主不要一来就做那么复杂的功能,先用AU做些辅助工具练练手比较好 tank 发表于 2020-7-9 11:37
楼主不要一来就做那么复杂的功能,先用AU做些辅助工具练练手比较好
书记员哪有这闲工夫
直接悬赏多好~~
:face (39): yohoboy 发表于 2020-7-6 02:09
;1.編碼改為 65001 不然會亂碼;2. 還沒寫完,後面自行修改。
#include
#include
多谢大神帮助啊,我再好好研究下。 本帖最后由 yohoboy 于 2020-7-20 23:40 编辑
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiEdit.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <GuiButton.au3>
#include <File.au3>
#include <Array.au3>
#include <WinAPISys.au3>
Global $text1, $text2, $text3, $temp
Local $GUI_Form1 = GUICreate("筆錄軟體", 1190, 625, 226, 144)
GUICtrlCreateLabel("審問:", 10, 10, 40, 15)
Global $GUI_ListView1 = GUICtrlCreateListView("審問範例|回答1|回答2|回答3", 10, 30, 530, 300)
_GUICtrlListView_SetColumnWidth($GUI_ListView1, 0, 350)
GUICtrlCreateLabel("可選回答:", 10, 340, 60, 15)
Global $GUI_ListView2 = GUICtrlCreateListView("回答範例", 10, 360, 530, 130)
_GUICtrlListView_SetColumnWidth($GUI_ListView2, 0, 500)
GUICtrlCreateLabel("自行輸入:", 10,500, 60, 15)
Global $Edit1 = GUICtrlCreateEdit("", 10, 520, 537, 97)
GUICtrlCreateLabel("審問筆錄:", 660,10, 60, 15)
Global $Edit2 = GUICtrlCreateEdit("", 660, 30, 520, 580)
GUICtrlSetData($Edit2, "")
$Button1 = GUICtrlCreateButton("選擇文件", 560, 32, 65, 33)
$Button2 = GUICtrlCreateButton("加入右侧", 565, 550, 65, 33)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;註冊滑鼠點擊狀態
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE ;關閉視窗
Exit
Case $Button1 ;開啟樣板
Open_file()
Case $Button2 ;帶入手動編輯
IfGUICtrlRead($Edit1) <> "" Then ;確保$Edit1是有文字輸入
$Index1 = _GUICtrlListView_GetSelectedIndices($GUI_ListView1)
If Not StringLen($Index1) Then;
MsgBox(0, "", "未選擇審問範例")
Else
$text1 = GUICtrlRead($Edit2)
$text2 = "問:" & _GUICtrlListView_GetItemText($GUI_ListView1, Number($Index1), 0) & @CRLF
$text3 = "答:" & GUICtrlRead($Edit1)& @CRLF
$text4 = $text1 & $text2 & $text3
GUICtrlSetData($Edit2, $text4)
EndIf
EndIf
EndSwitch
WEnd
Func Open_file() ;開啟樣檔
Local $a_cvs,$s_temp
_GUICtrlListView_DeleteAllItems($GUI_ListView1) ;刪除舊LIST資料
$s_Path = FileOpenDialog("Select CVS File", @ScriptDir, "All (*.csv)") ;開啟舊檔
If @error Then
MsgBox(4096, "", "未選擇檔案")
Else
_FileReadToArray($s_Path, $a_cvs) ;將檔案讀取到陣列
;_ArrayDisplay($a_cvs)
For $i = 1 To UBound($a_cvs) - 1 ;以下兩行將cvs格式轉成listview格式並顯示
$s_temp = StringReplace($a_cvs[$i], ",", "|")
GUICtrlCreateListViewItem($s_temp, $GUI_ListView1)
Next
EndIf
EndFunc
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom;选择产生事件的控件
Case $GUI_ListView1
Switch $Event; 選擇產生的事件
Case $NM_CLICK ; 左鍵
Case $NM_DBLCLK ; 左鍵雙擊
$Index1 = _GUICtrlListView_GetSelectedIndices($GUI_ListView1)
If Not StringLen($Index1) Then; 这里用以判断是否选定了ListViewItem
MsgBox(0, "", "未選擇")
Return
EndIf
_GUICtrlListView_DeleteAllItems($GUI_ListView2)
$text1 = "問:" & _GUICtrlListView_GetItemText($GUI_ListView1, Number($Index1), 0) & @CRLF
;MsgBox(0,"$text1",$text1)
GUICtrlCreateListViewItem(_GUICtrlListView_GetItemText($GUI_ListView1, Number($Index1), 1), $GUI_ListView2)
GUICtrlCreateListViewItem(_GUICtrlListView_GetItemText($GUI_ListView1, Number($Index1), 2), $GUI_ListView2)
GUICtrlCreateListViewItem(_GUICtrlListView_GetItemText($GUI_ListView1, Number($Index1), 3), $GUI_ListView2)
Case $NM_RCLICK ; 右鍵
EndSwitch
Case $GUI_ListView2
Switch $Event; 選擇產生的事件
Case $NM_CLICK ; 左鍵
Case $NM_DBLCLK ; 左鍵雙擊
$Index2 = _GUICtrlListView_GetSelectedIndices($GUI_ListView2)
If Not StringLen($Index2) Then; 这里用以判断是否选定了ListViewItem
MsgBox(0, "", "未選擇")
Return
EndIf
$text2 = $text1 & "答:" & _GUICtrlListView_GetItemText($GUI_ListView2, Number($Index2),0) & @CRLF
;MsgBox(0, "", $text2)
$text3 = GUICtrlRead($Edit2)
$text2 = $text3 & $text2
GUICtrlSetData($Edit2, $text2)
Case $NM_RCLICK ; 右鍵
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
yohoboy 发表于 2020-7-20 23:29
热心大哥,厉害~ 我都没有看明白楼主的需求~ LZ 还不结贴?
页:
[1]