找回密码
 加入
搜索
查看: 106|回复: 9

[AU3基础] windows安全中心 无法点击的问题

[复制链接]
发表于 6 天前 | 显示全部楼层 |阅读模式



这个窗口info信息能查到  高级(类名):[CLASS:Button; INSTANCE:2],用contrlclick 点击这个类名 居然不生效。。各位觉得是哪里的问题



>>>> 窗口 <<<<
标题:        Windows 安全中心
类名:        #32770
坐标:        651, 251
大小:        570, 242
样式:        0x96C80284
扩展样式:0x00010101
句柄:        0x00450690

>>>> 控件 <<<<
类名:        Button
实例:        2
类别名:        Button2
名称:       
高级(类名):[CLASS:Button; INSTANCE:2]
ID:       
文本:        不安装(&N)
坐标:        454, 118
大小:        90, 25
控件点击坐标:54, 9
样式:        0x50000001
扩展样式:0x00000000
句柄:        0x00070646

>>>> 鼠标 <<<<
坐标:        1167, 409
光标ID:        0
颜色:        0xC1E1E1

>>>> 状态栏 <<<<

>>>> 工具栏 <<<<

>>>> 可见文本 <<<<
安装(&I)
不安装(&N)
你应仅从可信的发布者安装驱动程序软件。<A HREF="mshelp://windows/?id=5622d7d6-531b-4e76-be48-0059d38339c4">我如何确定哪些设备软件可以安全安装?</A>


>>>> 隐藏文本 <<<<


本帖子中包含更多资源

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

×
发表于 6 天前 | 显示全部楼层
操控不了,禁止它弹窗试试。

;禁用《Windows 安全中心服务》 服务名《SecurityHealthService》(描述:Windows 安全中心服务处理统一的设备保护和运行状况信息)
        Local $SecurityHealthService = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService', 'Start')
        If $SecurityHealthService <> 4 Then
                RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance', 'Enabled', 'REG_DWORD', '0') ;关闭安全和维护通知
                Run('reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SecurityHealthService" /v "Start" /t REG_DWORD /d 4 /f', '', @SW_HIDE)
                Run('reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService" /v "Start" /t REG_DWORD /d 4 /f', '', @SW_HIDE)
        EndIf
发表于 6 天前 来自手机 | 显示全部楼层
fybhwsx 发表于 2026-5-4 16:02
操控不了,禁止它弹窗试试。

;禁用《Windows 安全中心服务》 服务名《SecurityHealthService》(描述:Win ...

这窗口可能牵扯到程序权限问题,可以提权后试一试。

至于弹出驱动签名信任对话框,可以导入证书避免。

在安装non-MS-WHQL-signed驱动程序时,会弹出Windows安全对话框:

如果想要禁止弹出此框,可以通过导入证书的方法解决。

1.首先通过手工点击【始终信任来自??的软件(A)】安装一次。

2.进入目录”%windir%\inf“,找到最新的oem??.inf文件,用记事本打开确认里面的内容是下次自动安装的驱动。

3.进入目录%windir%\system32\catroot\{ID},找到文件OEM??.CAT (与第二步的数字一样),右击“属性”-->”数字签名“-->选定”签名者姓名“,点击”详细信息“,出现下图。

4.点击”查看证书“-->"详细信息"-->"复制到文件...",证书格式默认即可,将证书保存到文件中。

5.应用该证书文件,在命令行模式下,执行命令:

certutil.exe -f -addstore "TrustedPublisher" %cer_name%

这样下次再安装时,就不会弹出安全对话框。
 楼主| 发表于 5 天前 | 显示全部楼层
gyp2000 发表于 2026-5-4 19:26
这窗口可能牵扯到程序权限问题,可以提权后试一试。

至于弹出驱动签名信任对话框,可以导入证书避免。

这样就偏离了 自动化的初衷了
 楼主| 发表于 5 天前 | 显示全部楼层
fybhwsx 发表于 2026-5-4 16:02
操控不了,禁止它弹窗试试。

;禁用《Windows 安全中心服务》 服务名《SecurityHealthService》(描述:Win ...

回头试试看
发表于 5 天前 来自手机 | 显示全部楼层
vud3d 发表于 2026-5-5 12:36
这样就偏离了 自动化的初衷了

你的目标是安装驱动,多几个备选方案哪里不好呢。
没必要死磕对话框不是嘛。
发表于 4 天前 | 显示全部楼层
不点击了 直接发送“I”进行安装
 楼主| 发表于 4 天前 | 显示全部楼层
aixi769776971 发表于 2026-5-6 12:03
不点击了 直接发送“I”进行安装

alt+i    enter  都试过了。感觉好像是系统层面的权限问题。手动alt+i就可以
发表于 4 天前 | 显示全部楼层
本帖最后由 gzh888666 于 2026-5-6 22:06 编辑

解决方法: 在脚本的最顶部添加一行:
#RequireAdmin

; 先激活窗口
WinActivate("Windows 安全中心")
WinWaitActive("Windows 安全中心")

; 获取控件相对坐标并点击
Local $pos = ControlGetPos("Windows 安全中心", "", "[CLASS:Button; INSTANCE:2]")
If Not @error Then
    ; 点击控件的中心位置
    MouseClick("left", $pos[0] + $pos[2]/2, $pos[1] + $pos[3]/2, 1, 0)
EndIf


ControlFocus("Windows 安全中心", "", "[CLASS:Button; INSTANCE:2]")
ControlSend("Windows 安全中心", "", "[CLASS:Button; INSTANCE:2]", "{SPACE}")

如果还不行就

Func _RunAsSYSTEM($sCmd)
    Local $hToken, $hNewToken, $si, $pi

    ; 常量
    Local Const $PROCESS_QUERY_INFORMATION = 0x0400
    Local Const $TOKEN_DUPLICATE = 0x0002
    Local Const $MAXIMUM_ALLOWED = 0x02000000
    Local Const $CREATE_NEW_CONSOLE = 0x0010

    ; 找 winlogon PID
    Local $aProc = ProcessList("winlogon.exe")
    If @error Or $aProc[0][0] = 0 Then Return False

    Local $hProc = DllCall("kernel32.dll", "handle", "OpenProcess",
        "dword", $PROCESS_QUERY_INFORMATION,
        "bool", False,
        "dword", $aProc[1][1])
    If Not $hProc[0] Then Return False

    ; 打开 Token
    DllCall("advapi32.dll", "bool", "OpenProcessToken",
        "handle", $hProc[0],
        "dword", $TOKEN_DUPLICATE,
        "ptr", VarPtr($hToken))
    If Not $hToken Then Return False

    ; 复制 Token
    DllCall("advapi32.dll", "bool", "DuplicateTokenEx",
        "handle", $hToken,
        "dword", $MAXIMUM_ALLOWED,
        "ptr", 0,
        "int", 2, ; SecurityImpersonation
        "int", 1, ; TokenPrimary
        "ptr", VarPtr($hNewToken))

    ; STARTUPINFO
    $si = DllStructCreate("dword cb;ptr lpReserved;ptr lpDesktop;" &
        "ptr lpTitle;dword dwX;dword dwY;dword dwXSize;dword dwYSize;" &
        "dword dwXCountChars;dword dwYCountChars;dword dwFillAttribute;" &
        "dword dwFlags;word wShowWindow;word cbReserved2;ptr lpReserved2;handle hStdInput;handle hStdOutput;handle hStdError")

    DllStructSetData($si, "cb", DllStructGetSize($si))

    ; PROCESS_INFORMATION
    $pi = DllStructCreate("handle hProcess;handle hThread;dword dwProcessId;dword dwThreadId")

    ; 创建进程
    DllCall("advapi32.dll", "bool", "CreateProcessAsUser",
        "handle", $hNewToken,
        "str", "",
        "str", $sCmd,
        "ptr", 0,
        "ptr", 0,
        "bool", False,
        "dword", $CREATE_NEW_CONSOLE,
        "ptr", 0,
        "str", "",
        "ptr", DllStructGetPtr($si),
        "ptr", DllStructGetPtr($pi))

    Return True
EndFunc

最后一招:

Func _RunAsTrustedInstaller($sCmd)
    Local $hToken, $hNewToken, $si, $pi

    Local Const $PROCESS_QUERY_INFORMATION = 0x0400
    Local Const $TOKEN_DUPLICATE = 0x0002
    Local Const $MAXIMUM_ALLOWED = 0x02000000
    Local Const $CREATE_NEW_CONSOLE = 0x0010

    ; 确保服务运行
    RunWait("sc start TrustedInstaller")

    Sleep(1000)

    ; 查找 TrustedInstaller
    Local $aProc = ProcessList("TrustedInstaller.exe")
    If @error Or $aProc[0][0] = 0 Then Return False

    Local $hProc = DllCall("kernel32.dll", "handle", "OpenProcess",
        "dword", $PROCESS_QUERY_INFORMATION,
        "bool", False,
        "dword", $aProc[1][1])

    If Not $hProc[0] Then Return False

    DllCall("advapi32.dll", "bool", "OpenProcessToken",
        "handle", $hProc[0],
        "dword", $TOKEN_DUPLICATE,
        "ptr", VarPtr($hToken))

    DllCall("advapi32.dll", "bool", "DuplicateTokenEx",
        "handle", $hToken,
        "dword", $MAXIMUM_ALLOWED,
        "ptr", 0,
        "int", 2,
        "int", 1,
        "ptr", VarPtr($hNewToken))

    $si = DllStructCreate("dword cb;ptr lpReserved;ptr lpDesktop;" &
        "ptr lpTitle;dword dwX;dword dwY;dword dwXSize;dword dwYSize;" &
        "dword dwXCountChars;dword dwYCountChars;dword dwFillAttribute;" &
        "dword dwFlags;word wShowWindow;word cbReserved2;ptr lpReserved2;handle hStdInput;handle hStdOutput;handle hStdError")

    DllStructSetData($si, "cb", DllStructGetSize($si))

    $pi = DllStructCreate("handle hProcess;handle hThread;dword dwProcessId;dword dwThreadId")

    DllCall("advapi32.dll", "bool", "CreateProcessAsUser",
        "handle", $hNewToken,
        "str", "",
        "str", $sCmd,
        "ptr", 0,
        "ptr", 0,
        "bool", False,
        "dword", $CREATE_NEW_CONSOLE,
        "ptr", 0,
        "str", "",
        "ptr", DllStructGetPtr($si),
        "ptr", DllStructGetPtr($pi))

    Return True
EndFunc


然后再执行点击


 楼主| 发表于 4 天前 | 显示全部楼层
gzh888666 发表于 2026-5-6 21:39
解决方法: 在脚本的最顶部添加一行:
#RequireAdmin

#RequireAdmin 这个早已试过。其他我来试试给您反馈。感谢大佬发了这么多方法
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2026-5-10 01:28 , Processed in 0.290767 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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