找回密码
 加入
搜索
查看: 873|回复: 7

[AU3基础] [已解决]怎么正确读取输入框(Input)控件里的数值?

[复制链接]
发表于 2022-3-29 23:01:29 | 显示全部楼层 |阅读模式
本帖最后由 lxcai369 于 2022-4-2 10:24 编辑

我自己尝试做了一个激活工具,目的是在输入框输入一个数值选取active文本里的激活码进行系统激活
目前运行发现无法读取输入框的数值,且最终运行结果是:“错误,无法找到产品”。应该怎么改才能读到?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Windows Active 3.0 by Chun", 282, 176, 192, 124)
$Button1 = GUICtrlCreateButton("激活系统", 152, 88, 105, 65)
$Button2 = GUICtrlCreateButton("卸载激活", 18, 88, 105, 65)
$Input1 = GUICtrlCreateInput("0", 80, 16, 121, 40, $ES_NUMBER)
GUISetState(@SW_SHOW)
#EndRegi1n ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Form1
                Case $Form1
                Case $Form1
                Case $Form1
                Case $Input1
                        Local $lineNum = GUICtrlRead($Input1)
                Case $Button1
                        
                        $Key = FileReadLine("active.txt", $lineNum)
                        $kms = "kms.xspace.in"
                        RunWait(@ComSpec & ' /c ' & 'cscript //Nologo %windir%\system32\slmgr.vbs -upk', '', 0)
                        RunWait(@ComSpec & ' /c ' & 'cscript //Nologo %windir%\system32\slmgr.vbs /ipk ' & $Key, '', 0)
                        RunWait(@ComSpec & ' /c ' & 'cscript //Nologo %windir%\system32\slmgr.vbs /skms ' & $kms, '', 0)
                        RunWait(@ComSpec & ' /c ' & 'cscript //Nologo %windir%\system32\slmgr.vbs /ato > %SystemDrive%\KMS.log', '', 0)
                        RunWait(@ComSpec & ' /c ' & ' schtasks /delete /tn KMS_T /f', '', 0)
                        $ReturnKMS = FileRead(@HomeDrive & "\kms.log")
                        If StringInStr($ReturnKMS, "找不到产品") Then
                                MsgBox(64, "", "$key")
                        Else
                                MsgBox(64, "$key", "$key!请检查网络畅通或稍后再次尝试激活。")
                        EndIf
                        

                        
                Case $Button2
                        
                        RunWait(@ComSpec & ' /c ' & ' cscript //Nologo %windir%\system32\slmgr.vbs /upk', '', 0)
                        RunWait(@ComSpec & ' /c ' & ' cscript //Nologo %windir%\system32\slmgr.vbs /ckms', '', 0)
                        RunWait(@ComSpec & ' /c ' & ' cscript //Nologo %windir%\system32\slmgr.vbs /rearm', '', 0)
                        RunWait(@ComSpec & ' /c ' & ' schtasks /delete /tn KMS_T /f', '', 0)
                        RunWait(@ComSpec & ' /c ' & ' del /q /f ' & @WindowsDir & '\KMS.exe', '', 0)
                        MsgBox(0, "成功", "卸载服务成功。")
                        
                        
        EndSwitch
WEnd
发表于 2022-3-29 23:16:25 | 显示全部楼层
...
GUISetState(@SW_SHOW)
#EndRegi1n ### END Koda GUI section ###
Local $lineNum = 0
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                       
                Case $Input1
                        $lineNum = GUICtrlRead($Input1)
...
 楼主| 发表于 2022-3-29 23:36:21 | 显示全部楼层
afan 发表于 2022-3-29 23:16
...
GUISetState(@SW_SHOW)
#EndRegi1n ### END Koda GUI section ###

结果还是一样的:错误,找不到产品  ,为了测试,msbox这里显示的应该就是对应输入数值读取到的注册码
发表于 2022-3-29 23:39:20 | 显示全部楼层
lxcai369 发表于 2022-3-29 23:36
结果还是一样的:错误,找不到产品  ,为了测试,msbox这里显示的应该就是对应输入数值读取到的注册码

你的问题是“怎么正确读取输入框(Input)控件里的数值” 我已经帮你解决了。
其它的问题自查。
 楼主| 发表于 2022-3-30 01:08:05 | 显示全部楼层
$Key = FileReadLine(@ScriptDir & "\active.txt", $lineNum)         emm,一开始我以为是没有读取到输入框里面的数值。但后面测试发现这行代码完全是无效的,导致后面获取到的数据都是$Key   麻烦大佬告诉我应该怎么改才能实现例如输入8,$Key就是active文本里面对应第8行的值。一直纠结在这个位置,实在是想不出哪里错了
发表于 2022-3-30 12:26:45 | 显示全部楼层
激活需要手动的就是一败笔!
发表于 2022-3-30 14:00:10 | 显示全部楼层
lxcai369 发表于 2022-3-30 01:08
$Key = FileReadLine(@ScriptDir & "\active.txt", $lineNum)         emm,一开始我以为是没有读取到输入 ...

GUISetState(@SW_SHOW)
#EndRegi1n ### END Koda GUI section ###
Local $lineNum = 0
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit                    
                Case $Input1
                        $lineNum = GUICtrlRead($Input1)
        Key = FileReadLine("active.txt", $lineNum)
        EndSwitch
WEnd
 楼主| 发表于 2022-3-30 15:13:58 | 显示全部楼层
非常感谢大佬的提示,已经解决了。   新手刚上路,看了几篇源码,东拼西凑的搞了这个来练手用的,很多东西都还没搞明白。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-4 02:50 , Processed in 0.075605 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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