找回密码
 加入
搜索
查看: 6528|回复: 22

[系统综合] 【已解決】【请问如何让 autoit 常驻在系统列 ???】

 火.. [复制链接]
发表于 2017-5-1 21:56:08 | 显示全部楼层 |阅读模式
本帖最后由 andyto202 于 2017-5-2 22:44 编辑

我有成功写出一个自动登入网页的 autoit
但是我希望它可以常驻在系统列
当开启特定要登入的网页时
它会自动填入帐号、密码

我想问
(1) 我本来是用
      Local $url = "http://localhost/xxx.php"
      Local $oIE = _IECreate($url, 1)
      自动登入的
      但是现在要如何侦测
      http://localhost/xxx.php 被开启
      才自动填入帐、密
      其它的网页不会动作??
 楼主| 发表于 2017-5-1 22:16:47 | 显示全部楼层
我刚才写个测试
WinWaitActive("[REGEXPTITLE:登入畫面.*Microsoft Edge]")
ConsoleWrite("ok")
发现当浏览器的标题符合上面那行时
的确会输出
OK
但是要怎么自动登入呢??
我要怎么抓到符合那个标题的 url
去带入到
Local $url = "符合那个标题的 url"
Local $oIE = _IECreate($url, 1)
上面的 $url 呢
发表于 2017-5-2 02:27:32 | 显示全部楼层
回复 2# andyto202

$Form1 = GUICreate("Form1", 225, 277,Default,Default,-1)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
   Switch $nMsg
              Case -3
                Exit
    EndSwitch
WEnd
发表于 2017-5-2 02:28:19 | 显示全部楼层
這樣不就常住在系統列了  再把你的東西  加入  While 1  的循環裡就好
 楼主| 发表于 2017-5-2 08:12:22 | 显示全部楼层
回复 4# kk_lee69

謝謝 kk_lee69 大
那我要如何偵測說
開啟的 url 是我要的那個呢??
我如果用
WinWaitActive("[REGEXPTITLE:登入畫面.*Microsoft Edge]")
去偵測
的確是可以
但是這樣子

#include <IE.au3>
Local $oUser, $oPass, $oSubmit
Local $sUser = "testUsername"
Local $sPass = "testPassword"
Local $url = "http://XXX/login.asp"
Local $oIE = _IECreate($url, 1)

上面的 $url 要怎麼把符合
WinWaitActive("[REGEXPTITLE:登入畫面.*Microsoft Edge]")
的填入到
Local $url 變數裡呢??
謝謝
发表于 2017-5-2 09:02:58 | 显示全部楼层
請貼出你的源碼
 楼主| 发表于 2017-5-2 09:18:05 | 显示全部楼层
kk_lee69 大 你好
我的源碼如下
#include <IE.au3>

Local $oUser, $oPass, $oSubmit
Local $sUser = "user"
Local $sPass = "pass"
Local $url = "http://localhost/member/login.php"
Local $oIE = _IECreate($url, 1)

_IELoadWait($oIE)

$oInputs = _IETagNameGetCollection($oIE, "input")
for $oInput in $oInputs
    if $oInput.type = "text" And $oInput.name = "username" Then $oUser = $oInput
    if $oInput.type = "password" And $oInput.name = "password" Then $oPass = $oInput
    if $oInput.type = "submit" And $oInput.value = "確定" Then $oSubmit = $oInput
    if isObj($oUser) And isObj($oPass) And isObj($oSubmit) then exitloop
Next

$oUser.value = $sUser
$oPass.value = $sPass
_IEAction($oSubmit, "click")

_IELoadWait($oIE)
上面的是可以自動登入網頁的
我現在想要做的是
如果讓 autoit 常駐在系統列偵測
當符合 title 是

登入畫面 - Internet Explorer

的時候

上面可以自動登入的帳號、密碼 自動帶入
謝謝
发表于 2017-5-2 09:35:15 | 显示全部楼层
回复 7# andyto202

試看看

#include <IE.au3>

$Form1 = GUICreate("Form1", 225, 277,Default,Default,-1)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
        Sleep(10)
        $HWnd=WinGetHandle("[REGEXPTITLE:登入畫面.*Microsoft Edge]")
        IF IsHWnd($HWnd)=1 Then
        WinClose($HWnd)
        _Lgoin()
        EndIf
   Switch $nMsg
              Case -3
                Exit
        EndSwitch
                        
WEnd

Func _Lgoin()
        
Local $oUser, $oPass, $oSubmit
Local $sUser = "user"
Local $sPass = "pass"
Local $url = "http://localhost/member/login.php"
Local $oIE = _IECreate($url, 1)

_IELoadWait($oIE)

$oInputs = _IETagNameGetCollection($oIE, "input")
for $oInput in $oInputs
    if $oInput.type = "text" And $oInput.name = "username" Then $oUser = $oInput
    if $oInput.type = "password" And $oInput.name = "password" Then $oPass = $oInput
    if $oInput.type = "submit" And $oInput.value = "確定" Then $oSubmit = $oInput
    if isObj($oUser) And isObj($oPass) And isObj($oSubmit) then exitloop
Next

$oUser.value = $sUser
$oPass.value = $sPass
_IEAction($oSubmit, "click")

_IELoadWait($oIE)

EndFunc
发表于 2017-5-2 09:42:03 | 显示全部楼层
或者用这个,检测窗口,激活窗口

WinWait(""[REGEXPTITLE:登入畫面.*Microsoft Edge]"")
WinActivate(""[REGEXPTITLE:登入畫面.*Microsoft Edge]") ;检查窗口并激活
 楼主| 发表于 2017-5-2 10:06:05 | 显示全部楼层
回复 8# kk_lee69

kk_lee69 大
您這段代碼是偵測到有關 title 為
登入畫面.*Microsoft Edge
然後關閉現有的視窗
再開新的視窗登入嗎???
有辦法用原視窗登入嗎??
发表于 2017-5-2 10:08:29 | 显示全部楼层
回复 10# andyto202

試看看

#include <IE.au3>

$Form1 = GUICreate("Form1", 225, 277,Default,Default,-1)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
        Sleep(10)
        $oIE = _IEAttach ("http://localhost/member/login.php","URL")
        IF @Error=0 Then
        _Lgoin()
        EndIf
   Switch $nMsg
              Case -3
                Exit
        EndSwitch
                        
WEnd


Func _Lgoin()
        
Local $oUser, $oPass, $oSubmit
Local $sUser = "user"
Local $sPass = "pass"
Local $url = "http://localhost/member/login.php"
;Local $oIE = _IECreate($url, 1)

_IELoadWait($oIE)

$oInputs = _IETagNameGetCollection($oIE, "input")
for $oInput in $oInputs
    if $oInput.type = "text" And $oInput.name = "username" Then $oUser = $oInput
    if $oInput.type = "password" And $oInput.name = "password" Then $oPass = $oInput
    if $oInput.type = "submit" And $oInput.value = "確定" Then $oSubmit = $oInput
    if isObj($oUser) And isObj($oPass) And isObj($oSubmit) then exitloop
Next

$oUser.value = $sUser
$oPass.value = $sPass
_IEAction($oSubmit, "click")

_IELoadWait($oIE)

EndFunc
 楼主| 发表于 2017-5-2 10:49:17 | 显示全部楼层
回复 11# kk_lee69

謝謝 kk_lee69 大
這樣子可以成功
另外請問 kk_lee69 大
Switch $nMsg
              Case -3
                Exit
        EndSwitch
這幾行的用意是什麼呢??
感覺不加這幾行好像也可以
发表于 2017-5-2 10:53:45 | 显示全部楼层
回复 12# andyto202

While 1     當 1的時候    表示永遠成立   死循環
    Switch $nMsg  切換到  $nMsg  接收消息
              Case -3      當消息=-3 代表 你按下了  右上角的X
                Exit                     離開
        EndSwitch    完成切換  跟 上面是一組的
WEnd  跟上面是一組的

也就是說 你省略了 當然可以  只是你的程式  沒有正常退出的管道而已
 楼主| 发表于 2017-5-2 11:04:54 | 显示全部楼层
回复 13# kk_lee69

kk_lee69 大
太感謝您了
您的熱心指導
讓我很快的能解決問題啊
真的很感謝
发表于 2017-5-2 11:39:16 | 显示全部楼层
回复 14# andyto202


    請注意板規
問題解決了 需要修改標題
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-25 08:44 , Processed in 0.081319 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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