找回密码
 加入
搜索
查看: 1251|回复: 3

[AU3基础] 请教哈 该如何运行从数据库中读出的代码?【已解决】

[复制链接]
发表于 2020-6-3 10:45:46 | 显示全部楼层 |阅读模式
本帖最后由 qsy666888 于 2020-6-5 23:02 编辑

保存在数据库中的代码  现在点击后只能读取  我想点击后运行这段代码   该如何写呢? 亲爱的大佬们
<font color="deepskyblue">#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#Include <GuiListView.au3>

    $SQLite_Data_Path = "MySQLite.db"
    $Table = "textTable"
_SQLite_Startup ()

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 542, 267, 339, 297)
$ListView1 = GUICtrlCreateListView("id|text1|", 8, 8, 522, 246)
 _GUICtrlListView_SetColumn($ListView1, 1, "text1", 300, -1)
tuqushuju()
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
#EndRegion ### END Koda GUI section ###



Func tuqushuju()
                _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))        
            Local $aRow, $hQuery,$i = 0        
                    _SQLite_Open ($SQLite_Data_Path)
        If _SQLite_Query(-1, "SELECT * FROM " & $Table & ";", $hQuery) = $SQLITE_OK Then 
                   
                    While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
                                _GUICtrlListView_AddItem($ListView1, $aRow[0], 0)
                            _GUICtrlListView_AddSubItem($ListView1, $i, BinaryToString($aRow[1]), 1)
                            $i+=1
                    WEnd
                _SQLite_Close()        
                EndIf 
        
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
        Local $tNMHDR, $hWndFrom, $iCode

        $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
        $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom')
        $iCode = DllStructGetData($tNMHDR, 'Code')

        Switch $iCode
                Case $NM_CLICK 
                        $aItemIndex = _GUICtrlListView_GetSelectedIndices($ListView1, True)
                        If $aItemIndex[0] Then
                                $iCurIndex = $aItemIndex[1]
                                $text = _GUICtrlListView_GetItemText($ListView1, $iCurIndex, 1)
                                MsgBox(0,0,$text)
                        EndIf                                        
        EndSwitch
        EndFunc   ;==>WM_NOTIFY</font>

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2020-6-3 12:50:04 | 显示全部楼层
读取的代码写入文件,然后使用宏@AutoItExe去执行
发表于 2020-6-5 13:20:17 | 显示全部楼层
Execute ('MsgBox(0, 0, "代码被执行。")')
 楼主| 发表于 2020-6-5 23:01:42 | 显示全部楼层
本帖最后由 qsy666888 于 2020-6-5 23:03 编辑
水木子 发表于 2020-6-5 13:20
Execute ('MsgBox(0, 0, "代码被执行。")')

感谢感谢,用过这个Execute代码,计算器上就要用到这个代码   没有想到居然还可以这样用。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-18 15:28 , Processed in 0.074578 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表