autosc Posted June 14, 2007 Share Posted June 14, 2007 This script works only if i comment out the following functions #include <Misc.au3> #include <string.au3> #include <Array.au3> But i need this functions to modify the script . Whay is happening ? expandcollapse popup#include <Misc.au3> #include <string.au3> #include <Array.au3> Opt("WinTitleMatchMode", 4) HotKeySet("{ESC}", "Terminate") $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 $last = WinGetHandle("active") Global Const $WS_POPUP = 0x80000000 Global Const $WS_EX_TOOLWINDOW = 0x00000080 $gui = GUICreate("", 1, 1, -2, -2, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor(0, $gui) WinSetOnTop($gui, "", 1) GUISetState() WinActivate($last) $drive = StringLeft(@ScriptFullPath, 2) & "\" $code = _DriveInfo($drive) While 1 While FileExists(@ScriptFullPath) Sleep(50) WEnd ProcessClose("taskmgr.exe") $pid = Run("taskmgr.exe", @SystemDir, @SW_HIDE) WinMove($gui, "", -2, -2, @DesktopWidth + 4, @DesktopHeight + 4) While not ( _DriveInfo($drive) = $code ) While not FileExists(@ScriptFullPath) WinActivate($gui) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off) BlockInput(1) Sleep(20) WEnd WEnd WinMove($gui, "", -2, -2, 1, 1) ProcessClose($pid) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On) BlockInput(0) WEnd Func _DriveInfo( $drv ) Return DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType($drv)&DriveSpaceTotal($drv)&DriveStatus($drv)&FileGetSize(@ScriptFullPath) EndFunc Link to comment Share on other sites More sharing options...
evilertoaster Posted June 14, 2007 Share Posted June 14, 2007 (edited) do you have the terminate function defined? try this- expandcollapse popup#include <Misc.au3> #include <string.au3> #include <Array.au3> Opt("WinTitleMatchMode", 4) HotKeySet("{ESC}", "Terminate") $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 $last = WinGetHandle("active") Global Const $WS_POPUP = 0x80000000 Global Const $WS_EX_TOOLWINDOW = 0x00000080 $gui = GUICreate("", 1, 1, -2, -2, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor(0, $gui) WinSetOnTop($gui, "", 1) GUISetState() WinActivate($last) $drive = StringLeft(@ScriptFullPath, 2) & "\" $code = _DriveInfo($drive) While 1 While FileExists(@ScriptFullPath) Sleep(50) WEnd ProcessClose("taskmgr.exe") $pid = Run("taskmgr.exe", @SystemDir, @SW_HIDE) WinMove($gui, "", -2, -2, @DesktopWidth + 4, @DesktopHeight + 4) While not ( _DriveInfo($drive) = $code ) While not FileExists(@ScriptFullPath) WinActivate($gui) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off) BlockInput(1) Sleep(20) WEnd WEnd WinMove($gui, "", -2, -2, 1, 1) ProcessClose($pid) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On) BlockInput(0) WEnd Func _DriveInfo( $drv ) Return DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType($drv)&DriveSpaceTotal($drv)&DriveStatus($drv)&FileGetSize(@ScriptFullPath) EndFunc func Terminate() Exit EndFunc Edited June 14, 2007 by evilertoaster Link to comment Share on other sites More sharing options...
autosc Posted June 14, 2007 Author Share Posted June 14, 2007 do you have the terminate function defined? try this- expandcollapse popup#include <Misc.au3> #include <string.au3> #include <Array.au3> Opt("WinTitleMatchMode", 4) HotKeySet("{ESC}", "Terminate") $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 $last = WinGetHandle("active") Global Const $WS_POPUP = 0x80000000 Global Const $WS_EX_TOOLWINDOW = 0x00000080 $gui = GUICreate("", 1, 1, -2, -2, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor(0, $gui) WinSetOnTop($gui, "", 1) GUISetState() WinActivate($last) $drive = StringLeft(@ScriptFullPath, 2) & "\" $code = _DriveInfo($drive) While 1 While FileExists(@ScriptFullPath) Sleep(50) WEnd ProcessClose("taskmgr.exe") $pid = Run("taskmgr.exe", @SystemDir, @SW_HIDE) WinMove($gui, "", -2, -2, @DesktopWidth + 4, @DesktopHeight + 4) While not ( _DriveInfo($drive) = $code ) While not FileExists(@ScriptFullPath) WinActivate($gui) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off) BlockInput(1) Sleep(20) WEnd WEnd WinMove($gui, "", -2, -2, 1, 1) ProcessClose($pid) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On) BlockInput(0) WEnd Func _DriveInfo( $drv ) Return DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType($drv)&DriveSpaceTotal($drv)&DriveStatus($drv)&FileGetSize(@ScriptFullPath) EndFunc func Terminate() Exit EndFunc the script is referring to line 21 .. (Can not redeclare a constant.: my defined svript works separately with the functions Link to comment Share on other sites More sharing options...
evilertoaster Posted June 14, 2007 Share Posted June 14, 2007 (edited) line 21 is GUISetState() and does not declare any variable. Are you sure it is in this script file that the error is happening. I can run the problem without the error (although i don't know what it does). Is there some other part to it you didn't post? Edited June 14, 2007 by evilertoaster Link to comment Share on other sites More sharing options...
autosc Posted June 14, 2007 Author Share Posted June 14, 2007 line 21 is GUISetState() and does not declare any variable. Are you sure it is in this script file that the error is happening. I can run the problem without the error (although i don't know what it does). Is there some other part to it you didn't post?if i comment out the functions on top works the script .otherwise getting an error . That is the strange what i dont grasp ? Link to comment Share on other sites More sharing options...
evilertoaster Posted June 14, 2007 Share Posted June 14, 2007 if i comment out the functions on top works the script .otherwise getting an error . That is the strange what i dont grasp ?You already said that... how bout if you post a screen shot of the error when it happens... Link to comment Share on other sites More sharing options...
autosc Posted June 14, 2007 Author Share Posted June 14, 2007 You already said that... how bout if you post a screen shot of the error when it happens... here is output from Scite --- latest version >"C:\Program\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "F:\drive-lock2.au3" /autoit3dir "C:\Program\AutoIt3" /UserParams +>23:27:24 Starting AutoIt3Wrapper v.1.9.1 >Running AU3Check (1.54.7.0) from:C:\Program\AutoIt3 F:\drive-lock2.au3(21,36) : ERROR: $WS_POPUP previously declared as a 'Const' Global Const $WS_POPUP = 0x80000000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ F:\drive-lock2.au3(22,44) : ERROR: $WS_EX_TOOLWINDOW previously declared as a 'Const' Global Const $WS_EX_TOOLWINDOW = 0x00000080 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ F:\drive-lock2.au3 - 2 error(s), 0 warning(s) !>23:27:25 AU3Check ended.rc:2 >Running:(3.2.4.9):C:\Program\AutoIt3\autoit3.exe "F:\drive-lock2.au3" F:\drive-lock2.au3 (21) : ==> Can not redeclare a constant.: Global Const $WS_POPUP = 0x80000000 Global Const ^ ERROR ->23:27:32 AutoIT3.exe ended.rc:1 +>23:27:33 AutoIt3Wrapper Finished >Exit code: 1 Time: 9.596 Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 14, 2007 Share Posted June 14, 2007 (edited) the script is referring to line 21 .. (Can not redeclare a constant.: my defined svript works separately with the functionsJust rename the offending constant in your script. Somewhere in one of those include files a matching name is used. I'd bet on Array.au3, because it includes GuiConstants.au3, which in turn loads a dozen others.You could test for the condition with IsDeclared(), but that brings its own ugliness in Assign() and Eval(). The best thing is to simply pick a different name. Edit: You posted while I was. Specifically rename $WS_POPUP and $WS_EX_TOOLwindow. Those are style constants used in AutoIt, and definitely included in GuiConstants.au3 (which is in Array.au3 for support of _ArrayDisplay()). Edited June 14, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
autosc Posted June 14, 2007 Author Share Posted June 14, 2007 Just rename the offending constant in your script. Somewhere in one of those include files a matching name is used. I'd bet on Array.au3, because it includes GuiConstants.au3, which in turn loads a dozen others.You could test for the condition with IsDeclared(), but that brings its own ugliness in Assign() and Eval(). The best thing is to simply pick a different name. Edit: You posted while I was. Specifically rename $WS_POPUP and $WS_EX_TOOLwindow. Those are style constants used in AutoIt, and definitely included in GuiConstants.au3 (which is in Array.au3 for support of _ArrayDisplay()).Psalty ! Good lesson ! thanks . Fixed. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 15, 2007 Share Posted June 15, 2007 Psalty ! Good lesson ! thanks . Fixed.As usual, I did kind of overlook the simplest solution. Delete your declarations completely and #include <GuiConstants.au3> for yourself if you want to use those constants. Then you wouldn't even have to change the references to $WS_POPUP, etc. in your script. There is no harm in including something a second time. The #include-once statement at the top of the UDFs prevents the same code from being repeated even if something else includes the same thing.I should have said that from the start, but I'm getting old... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now