zoukankan      html  css  js  c++  java
  • autoit 脚本开发踩坑点

    原文

    1. 获取不到点击 <input type='file'/> 后弹出的window

    根本原因是 _IEAction 阻塞,见第4点
    解决办法:

    ;bad code
    $oIE = _IE_Example("form")
    $oT = _IEGetObjById($oIE, 'fileExample')
    _IEAction($oT,"click")
    WinWait("Choose File to Upload") ;等待不到弹出
    $hChoose = WinGetHandle("Choose File to Upload")
    
    ;good code
    $oIE = _IE_Example("form")
    $oT = _IEGetObjById($oIE, 'fileExample')
    MouseMove(_IEPropertyGet($oT, "screenx") + _IEPropertyGet($oT, "width") - 10, _
              _IEPropertyGet($oT, "screeny") + _IEPropertyGet($oT, "height")/2)
    MouseClick("left")
    WinWait("Choose File to Upload")
    

    2. send 需要切换英文输入法

    如果没有切换英文输入法,会出现中文输入法候选框
    如果能用ControlSend,就不推荐用send,如果非要用send,可以切换输入法为英文再send.

    ;设置指定窗口为英文输入法
    $hWnd = WinGetHandle("[ACTIVE]");$hWnd 为目标窗口句柄,这里设置的是当前活动窗口
    $ret = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", "08040804", "int", 1 + 0)
    DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", 0x50, "int", 1, "int", $ret[0])        
    Send('nh')
    

    3. 有时 IE对象 需要重新获取,以便刷新一下值,否则为null

    原因未知

    4. _IEAction($btnsave,"click") 会阻塞,直到事件完成

    所以使用 _IEAction 触发事件时,如果事件里有 alert 之类的弹窗,程序会一直停留在这一句,导致无法继续。所以即便在后面写了 WinWait 等待弹窗的句子,也无济于事。

    推荐使用鼠标光标去点击这个按钮,再 WinWait弹窗

    5. 日志中的不解之谜

    程序运行时日志里,常有下面的 COM Error ,但没有显示异常的行数。结合前后逻辑也没能分析出问题。

    另外 scriptline 总是显示 -1 的原因竟然是,编译成exe后,脚本获取不到行数。行数scriptline只会在开发时使用 f5 调试中有效 。(出自链接1连接2

    2021-06-30 14:53:03:AutoItCOM Test , We intercepted a COM Error !
    2021-06-30 14:53:03:err.description is: 	
    2021-06-30 14:53:03:err.windescription:	发生意外。
    2021-06-30 14:53:03:err.number is: 	80020009
    2021-06-30 14:53:03:err.lastdllerror is: 	0
    2021-06-30 14:53:03:err.scriptline is: 	-1
    2021-06-30 14:53:03:err.source is: 	
    2021-06-30 14:53:03:err.helpfile is: 	
    2021-06-30 14:53:03:err.helpcontext is: 	0
    2021-06-30 14:53:03:AutoItCOM Test , We intercepted a COM Error !
    2021-06-30 14:53:03:err.description is: 	
    2021-06-30 14:53:03:err.windescription:	发生意外。
    2021-06-30 14:53:03:err.number is: 	80020009
    2021-06-30 14:53:03:err.lastdllerror is: 	0
    2021-06-30 14:53:03:err.scriptline is: 	-1
    2021-06-30 14:53:03:err.source is: 	
    2021-06-30 14:53:03:err.helpfile is: 	
    2021-06-30 14:53:03:err.helpcontext is: 	0
    
  • 相关阅读:
    aodquery,clientdataset数据控件之间的速度区别
    centos防火墙相关
    centos安装jdk,精简
    delphi 操作excel复制区域功能呢
    centos安装redis,最靠谱的教程
    图像识别,借助百度云,上传图片实现逻辑
    LinkedHashmap和HashMap对比以及说明
    Windows环境下Zookeeper安装和使用
    你不知道的JavaScript--Item1 严格模式
    jQuery学习之旅 Item2 选择器【二】
  • 原文地址:https://www.cnblogs.com/ohzxc/p/15759343.html
Copyright © 2011-2022 走看看