autoit3简要笔记

autoit3简要笔记
2011年02月11日
  
  1.autoit3 脚本参数
  $CmdLine[0] is number of parameters
  $CmdLine[1] is param 1 (after the script name)
  $CmdLine[2] is param 2 etc
  ...
  $CmdLine[$CmdLine[0]] is one way to get the last parameter...
  So if your script is run like this: AutoIt3.exe myscript.au3 param1 "this is another param" $CmdLine[0] equals... 2 $CmdLine[1] equals... param1 $CmdLine[2] equals... this is another param @ScriptName equals... myscript.au3 2.vista 的User Account Control (UAC). Vista 下,提示用户脚本运行的用户是否有administrators 的权限。 ; This script requires full Administrative rights
  #requireadmin
  MsgBox(0, "Info", "This script has admin rights! ") 3 windows handles A window handle is a special value that windows assigns to a window each time it is created.The advantage of using window handles is that if you have multiple copies of an application open - which have the same title/text - you can uniquely identify them when using handles. 4 autoit 快捷键
  !代表alt 键
  5 宏
  Autoit 中的宏是用@ 开头的,变量是以$ 开头的。
  6 循环
  除了for in next 与vbscript 中的for each next 不同外。其余几个语法一直。
  7 com 的调用
  使用oleviewer 查看当前机器上的com 组件。Most important is the "VersionIndependentProgID". This is the name to be used in an ObjCreate, ObjGet or ObjEvent function 。AutoIt uses the IDispatch interface for automation 。Right-click on the name IDispatch and choose "View..." from the context menu. Then click the "View TypeInfo..." button
  8.autoit3 GUI GUI上的control id The control ID is a positive number (that is, a number greater than 0) Each control ID is unique - even when there are multiple windows The control ID is actually the same value as the Control ID that the AutoIt Window Info Tool shows GUI 具有两种模式,1.消息驱动模式 2.事件驱动模式 1. 消息驱动模式
  GUI 将不停的循环,使用GUIGetMsg()来获取GUI上的事件,例如点击Button,关闭GUI。 While 1
  $msg = GUIGetMsg()
  ...
  ...
  WEnd Remark:注意,不要在GUI中尝试添加Sleep函数,这会导致GUI无法响应用户,不用担心LOOP会过分消耗CPU,GUIGetMsg已经帮你考虑到这点了。 GUIGetMsg() 将返回三种结果: . No Event 返回为0
  . Control Event 返回CONTROL ID
  System Event 返回负值 $GUI_EVENT_CLOSE
  $GUI_EVENT_MINIMIZE
  $GUI_EVENT_RESTORE
  $GUI_EVENT_MAXIMIZE
  $GUI_EVENT_PRIMARYDOWN
  $GUI_EVENT_PRIMARYUP
  $GUI_EVENT_SECONDARYDOWN
  $GUI_EVENT_SECONDARYUP
  $GUI_EVENT_MOUSEMOVE
  $GUI_EVENT_RESIZED
  $GUI_EVENT_DROPPED Control id 是独一无二的,但System Event 在多窗口的情况下就需要再指明是哪个窗口的事件了。因此使用带参数的GUIGetMsg 方法。
  $msg = GUIGetMsg(1) When called with the 1 parameter instead of returning an event value an array will be returned, the array contains the event ( in $array[0] ) and extra information such as the window handle ( in $array[1] ) The first major change is the GUISwitch function call - when a new window is created it becomes the "default" window for future GUI operations (including control creation). 使用GUISwitch($mainwindow)来切换活动窗口。
  2. 事件驱动模式 The default mode is the MessageLoop mode so before using the OnEvent mode we must use Opt("GUIOnEventMode", 1) . 9 .autoit3 函数 9.1环境管理
  clipGet 获取剪切板中内容
  Clipput 设置剪切板中内容
  EnvGet 获取环境变量 $var=EnvGet("PATH")
  EnvSet 设置环境变量EnvSet("MYENV","this is a test")
  MemGetStats ( ) 获取内存状态。返回七个元素的数组。
  9.2 文件,目录,磁盘管理
  Autoit3有类似vbs的文件目录磁盘函数,另外,autoit3能够对.ini文件直接读写。便于操作这种键值对应的文件。
  10 autoit3 网络编程
  10.1 网络下载文件 ; Advanced example - downloading in the background
  Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files /beta/update.dat", @TempDir & "\update.dat", 1, 1)
  Do
  Sleep(250)
  Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
  Local $nBytes = InetGetInfo($hDownload, 0)
  InetClose($hDownload) ; Close the handle to release resourcs.
  MsgBox(0, "", "Bytes read: " & $nBytes) 10.2 socket 编程 Step1: TCPStartup ( ) Step2: TCPListen ( IPAddr, port [, MaxPendingConnection] ) Step3:服务器端TCPAccept ( mainsocket ),客户端TCPConnect ( IPAddr, port )
  Step4:客户端TCPSend ( mainsocket, data ),
  服务端TCPRecv ( mainsocket, maxlen [, flag] )
  Step5: TCPCloseSocket ( socket )关闭TCPListen和TCPAccept建立的socket连接。
  Step6: TCPShutdown ( ) ; To stop TCP services
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值