找回密码
 加入
搜索
查看: 2166|回复: 12

[AU3基础] [已解决] 如何读取控件并修改控件文字

[复制链接]
发表于 2019-8-29 21:30:05 | 显示全部楼层 |阅读模式
本帖最后由 chishingchan 于 2019-8-30 09:54 编辑

最近想汉化 Snapshot 软件,遇到难题!
请问如果读取和修改红色框的控件文字?谢谢!


Snapshot

本帖子中包含更多资源

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

×
 楼主| 发表于 2019-8-29 21:31:54 | 显示全部楼层
本帖最后由 chishingchan 于 2019-8-30 00:18 编辑
$sTitle = "Snapshot - Select the Volumes you want to save"
WinActivate($sTitle)
$sSysListView321 = ControlListView($sTitle, "", "[CLASS:SysListView32; Instance:1]", "GetText",3,2)
MsgBox(0, "$sSysListView321", $sSysListView321)
上面的代码也没能查询

还有最下面带色块的那行,窗口信息没法读取,不知有何办法修改?
发表于 2019-8-30 01:54:19 | 显示全部楼层
#AutoIt3Wrapper_UseX64=n
#RequireAdmin
#include <GuiListView.au3>
#include <WinAPISysWin.au3>

Local $sTitle = "Snapshot - Select the Volumes you want to save"

Local $hWnd = _WinAPI_EnumChildWindows(WinGetHandle($sTitle))

For $i = 0 To UBound($hWnd)
        If $hWnd[$i][1] = 'SysListView32' Then
                $hWnd = $hWnd[$i][0]
                ExitLoop
        EndIf
Next

Local $sArray, $sColumnTitle, $sColumn = _GUICtrlListView_GetColumnCount($hWnd)

For $i = 0 To $sColumn
        $sArray = _GUICtrlListView_GetColumn($hWnd, $i)
        $sColumnTitle &= $sArray[5] & '|'
Next

Local $sCount = _GUICtrlListView_GetItemCount($hWnd)

Local $aListView[0][$sColumn]

For $i = 0 To $sCount
        _ArrayAdd($aListView, _GUICtrlListView_GetItemTextString($hWnd, $i))
Next

For $i = 0 To $sColumn
        _GUICtrlListView_SetColumn($hWnd, $i, $i)
Next

_ArrayDisplay($aListView, _WinAPI_GetWindowText($hWnd) & ' ' & $hWnd, '', 64, '', StringTrimRight($sColumnTitle, 1))

评分

参与人数 1威望 +2 金钱 +200 贡献 +10 收起 理由
chishingchan + 2 + 200 + 10 很给力!

查看全部评分

 楼主| 发表于 2019-8-30 10:42:49 | 显示全部楼层
本帖最后由 chishingchan 于 2019-8-30 14:08 编辑

[已解决] 不知为何,翻译字符串还需加上空格,否则显示不全:
#RequireAdmin
#include <GuiListView.au3>
#include <WinAPISysWin.au3>
;窗口标题
Local $sTitle = "Snapshot - Select the Volumes you want to save"
WinActivate($sTitle)
;获取子窗口句柄
Local $hWnd = _WinAPI_EnumChildWindows(WinGetHandle($sTitle))        ;<WinAPISysWin.au3>
;获取 SysListView32 行句柄
For $i = 0 To UBound($hWnd)
        If $hWnd[$i][1] = 'SysListView32' Then
                $hWnd = $hWnd[$i][0]
                ExitLoop
        EndIf
Next

;定义翻译字符串
Local $sSysListView32 = StringSplit("驱动|HD|分区号|分区开始|分区大小|标签|文件系统|大小|已用|可用", "|", 2)
;设置翻译字符串
For $i = 0 To UBound($sSysListView32)
        _GUICtrlListView_SetUnicodeFormat($hWnd, True)
        _GUICtrlListView_SetColumn($hWnd, $i, $sSysListView32[$i])        ;<GuiListView.au3>
Next

发表于 2019-8-30 11:13:22 | 显示全部楼层
chishingchan 发表于 2019-8-30 10:42
不知为何,翻译字符串还需加上空格,否则显示不全:
_GUICtrlListView_SetUnicodeFormat($hWnd, True)

评分

参与人数 1金钱 +100 收起 理由
chishingchan + 100 很给力!

查看全部评分

 楼主| 发表于 2019-8-30 13:55:15 | 显示全部楼层

再次请教:
如何将第3列 (PartNo) 的 Pri 或 Log 写入(主分区 或 逻辑分区)翻译字符串?谢谢!
发表于 2019-8-30 15:33:53 | 显示全部楼层
For $i = 0 To _GUICtrlListView_GetItemCount($hWnd)
        Local $sPartNo = _GUICtrlListView_GetItemText($hWnd, $i, 2)

        If StringInStr($sPartNo, 'Pri') Then
                _GUICtrlListView_SetItemText($hWnd, $i, '主分区' & StringTrimLeft($sPartNo, 3), 2)
        EndIf

        If StringInStr($sPartNo, 'Log') Then
                _GUICtrlListView_SetItemText($hWnd, $i, '逻辑分区' & StringTrimLeft($sPartNo, 3), 2)
        EndIf
Next

评分

参与人数 1威望 +2 金钱 +100 贡献 +6 收起 理由
chishingchan + 2 + 100 + 6 很给力!

查看全部评分

 楼主| 发表于 2019-8-30 18:17:12 | 显示全部楼层
发表于 2019-9-1 19:23:06 | 显示全部楼层
处理64bitSnapshot时,sSysListView32这项会导致Snapshot结束进程
发表于 2019-9-6 16:17:44 | 显示全部楼层
无法打开包含文件 <WinAPISysWin.au3>?
 楼主| 发表于 2019-9-24 23:43:15 | 显示全部楼层

老大,我还有一个类似的难题想请教您:
在顶楼的软件中,主界面 -> Backup Disk To File -> Next -> Browse
在保存类型中有两项字符(ComboBox3):
1、Snapshot Files (*.SNA)
2、All (*.*)
请问如何更改此两个字符?谢谢!
 楼主| 发表于 2019-9-25 08:21:37 | 显示全部楼层

以下语句没效果!!!
#RequireAdmin
#include <GuiComboBox.au3>
#include <WinAPISysWin.au3>

$Title = "Select Destination File for C:"
$hWnd = WinGetHandle($Title)
Local $Wnd = _WinAPI_EnumChildWindows($hWnd)
Local $j = 0
For $i = 0 To UBound($Wnd) - 1
        If $Wnd[$i][1] = 'ComboBox' Then
                $j += 1
                If $j = 3 Then
                        $Wnd = $Wnd[$i][0]
                        ExitLoop
                EndIf
        EndIf
Next
_GUICtrlComboBox_BeginUpdate($Wnd)
_GUICtrlComboBox_SetEditText($Wnd, "Snapshot 文件(*.SNA)|所有(*.*)")
_GUICtrlComboBox_EndUpdate($Wnd)
发表于 2019-9-25 17:37:26 | 显示全部楼层
chishingchan 发表于 2019-9-25 08:21
以下语句没效果!!!
#RequireAdmin
#include <WinAPISysWin.au3>
#include <GuiComboBox.au3>

$Title = "Select Destination File for C:"
Local $hWnd = WinGetHandle($Title)
Local $Wnd = _WinAPI_EnumChildWindows($hWnd, False)

For $i = UBound($Wnd) - 1 To 0 Step - 1
        If $Wnd[$i][1] = 'ComboBox' Then
                Local $idCombo = $Wnd[$i][0]
                ExitLoop
        EndIf
Next

_GUICtrlComboBox_InsertString($idCombo, 'Snapshot 文件(*.SNA)', 0)
_GUICtrlComboBox_DeleteString($idCombo, 1)
_GUICtrlComboBox_InsertString($idCombo, '所有(*.*)', 1)
_GUICtrlComboBox_DeleteString($idCombo, 2)
_GUICtrlComboBox_SetCurSel($idCombo, 0)

评分

参与人数 1威望 +6 金钱 +150 贡献 +40 收起 理由
chishingchan + 6 + 150 + 40 很给力!

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 11:06 , Processed in 0.097084 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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