本帖最后由 smooth 于 2014-2-11 10:04 编辑
我脚本用先插入#include <WindowsConstants.au3>这个头文件,其中里面声明了4个变量:
Global Const $WM_COMMAND = 0x0111
Global Const $WM_MOVE = 0x0003
Global Const $WM_LBUTTONDOWN = 0x0201
Global Const $WM_RBUTTONDOWN = 0x0204
在WindowsConstants.au3的后面,还插入了GUIInputSetOnlyNumbers.au3这个头文件,其中声明了上述4个变量,不过声明的方式如下:
If Not IsDeclared("WM_COMMAND") Then Global Const $WM_COMMAND = 0x0111
If Not IsDeclared("WM_MOVE") Then Global Const $WM_MOVE = 0x0003
If Not IsDeclared("WM_LBUTTONDOWN") Then Global Const $WM_LBUTTONDOWN = 0x0201
If Not IsDeclared("WM_RBUTTONDOWN") Then Global Const $WM_RBUTTONDOWN = 0x0204
查了一下IsDeclared函数的作用,是检查某个变量是否已经声明过了,没声明过的话则声明某个变量。可是虽然如此,我的脚本还是无法执行,提示如下错误信息:D:\Program Files\autoit3\Include\GUIInputSetOnlyNumbers.au3(4,74) : ERROR: $WM_COMMAND previously declared as a 'Const'
If Not IsDeclared("WM_COMMAND") Then Global Const $WM_COMMAND = 0x0111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~^
D:\Program Files\autoit3\Include\GUIInputSetOnlyNumbers.au3(5,70) : ERROR: $WM_MOVE previously declared as a 'Const'
If Not IsDeclared("WM_MOVE") Then Global Const $WM_MOVE = 0x0003
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~^
D:\Program Files\autoit3\Include\GUIInputSetOnlyNumbers.au3(6,81) : ERROR: $WM_LBUTTONDOWN previously declared as a 'Const'
If Not IsDeclared("WM_LBUTTONDOWN") Then Global Const $WM_LBUTTONDOWN = 0x0201
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~^
D:\Program Files\autoit3\Include\GUIInputSetOnlyNumbers.au3(7,81) : ERROR: $WM_RBUTTONDOWN previously declared as a 'Const'
If Not IsDeclared("WM_RBUTTONDOWN") Then Global Const $WM_RBUTTONDOWN = 0x0204
这究竟是为什么呢?如果在插入头文件的顺序上,是先插入GUIInputSetOnlyNumbers.au3,再插入WindowsConstants.au3,那提示错误好像还好理解。
谢谢! |