I have a problem. I use FileOpenDialog and I insert multiple groups that can be selected. I would like to know which one is chosen. I tried to bind the variable to _PathSplit, see the extension and associate multiple arrays in all possible extensions. The problem is that an element is in both arrays. So I can not use this approach. Is there a way to see WHICH choice is selected?
↧
FileOpenDialog
↧
Check user authentication to windows share
Hello everyone.
I'm trying to connect to a windows share (\\print) but if my authentication fails, for example, wrong username or password, how can i catch that error?
The problem is that when executing the script (exe. file), if i insert wrong credentials, the error message is from Autoit program and not the message i would like to pop up (code above) if there is some problem with the authentication.
Here is a sample of my code:
The values of $username and $password are filled from an Inputbox.
So, after that code i tried to catch the error like this:
And by the way, the error i got from the console is this one:
C:\Users\user\Desktop\test.au3 (33) : ==> The requested action with this object has failed.:
$WshNetwork.MapNetworkDrive( "","\\print",True, $username, $password)
$WshNetwork.MapNetworkDrive( "","\\print",True, $username, $password)^ ERROR
Well, the error is happening, but is there some way to catch the error from the code and send an alert (Msgbox)?
Thank you for your help and time,
Sardinha
I'm trying to connect to a windows share (\\print) but if my authentication fails, for example, wrong username or password, how can i catch that error?
The problem is that when executing the script (exe. file), if i insert wrong credentials, the error message is from Autoit program and not the message i would like to pop up (code above) if there is some problem with the authentication.
Here is a sample of my code:
[ autoit ]
The values of $username and $password are filled from an Inputbox.
So, after that code i tried to catch the error like this:
[ autoit ]
And by the way, the error i got from the console is this one:
C:\Users\user\Desktop\test.au3 (33) : ==> The requested action with this object has failed.:
$WshNetwork.MapNetworkDrive( "","\\print",True, $username, $password)
$WshNetwork.MapNetworkDrive( "","\\print",True, $username, $password)^ ERROR
Well, the error is happening, but is there some way to catch the error from the code and send an alert (Msgbox)?
Thank you for your help and time,
Sardinha
↧
↧
How to get the menu item and control the menu(BCGPToolBar)?(poor english..)
sorry my english is poor but i need some help about au3
i am develop a automatic test tool on a pdf reader software
i want to get the menu item title and use item name to click the menu item (just like click “File"> click "Open")
i find it so hard to use "controlgettext" or "wingettext" to get the item name !
the menu ctrl info is :(use window info tool)
-------------------------------------------------------------
class:BCGPToolBar:1300000:8:10003:10
interface:15
classname:BCGPToolBar:1300000:8:10003:1015
hi class:[CLASS:BCGPToolBar:1300000:8:10003:10; INSTANCE:15]
ID:59398
Text:Menu Bar
------------------------------------------------------------
can i use some winapi to get it done???
thank you very much!
i am develop a automatic test tool on a pdf reader software
i want to get the menu item title and use item name to click the menu item (just like click “File"> click "Open")
i find it so hard to use "controlgettext" or "wingettext" to get the item name !
the menu ctrl info is :(use window info tool)
-------------------------------------------------------------
class:BCGPToolBar:1300000:8:10003:10
interface:15
classname:BCGPToolBar:1300000:8:10003:1015
hi class:[CLASS:BCGPToolBar:1300000:8:10003:10; INSTANCE:15]
ID:59398
Text:Menu Bar
------------------------------------------------------------
can i use some winapi to get it done???
thank you very much!

↧
i need two .exe file
i need two exe in one exe file. (fileinstall) first run 1. exe file and , run 2. exe file. i need this code. please help me.
↧
"=" or "==", I don't understand...
↧
↧
AutoIt beginner few simple questions
As I stumbled upon one system I wanted to automatize AutoIt sounded perfect for doing so but now I stumbled upon several problems and along with that I have several questions so here it is.
This is code I wrote so far before I went into problems and had many questions.
Now basically when 2nd screen appear and 2nd while loop is executed it doesn't detect given pixel nor it move&click mouse to selected place after it detect that pixel. After leaving script to run for some time it gives error "NO RIGHT BRACKET".
Next questions:
If first while loop here find pixel in first execution (or any before 10th run) does it stop running or does it still keep looping. If it keep looping how can I stop it if pixel is found.
Will 2nd while loop start executing if 1st one is not done. I mean if question before had answer that it doesn't stop looping it means 2nd script would start after 30 seconds.
Is it possible to read from window bigger part than only pixel? Something like part of picture an so on, if so could you point me to such format
How to read something from outside file (I would like to make configuration file) and save it in variable. Lets say I have .txt file with accountName:password and now I want to take only accountName out of it and save it in variable, same this with password.
Can I use variables declared in other loops, I mean in this my code I used coord1 in 2nd while loop, is coord from first loop accessible by 2nd loop?
__________________________________________________________________________________________________________
Parts of my questions are covered in tutorials and questions already asked, but I questioned them here in way I haven't been able to understand them from Internet found references.
Thanks for your time reading my topic and taking time answering my noobish questions.
This is code I wrote so far before I went into problems and had many questions.
Run ( "Masked for privacy" ) $i = 0 While $i <= 10 $coord = PixelSearch(906, 579, 1067, 666, 0xA86A21) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf $i = $i + 1 Sleep(3000) WEnd $i1 = 0 While $i1 <= 10 $coord1 = PixelSearch(86, 658, 160, 706, 0xEE2E24) If Not @error Then $coord2 = (458, 311) MouseClick("primary", $coord2[0], $coord2[1], 2, 1) EndIf $i1 = $i1 + 1 Sleep(3000) WEnd
Now basically when 2nd screen appear and 2nd while loop is executed it doesn't detect given pixel nor it move&click mouse to selected place after it detect that pixel. After leaving script to run for some time it gives error "NO RIGHT BRACKET".
Next questions:
If first while loop here find pixel in first execution (or any before 10th run) does it stop running or does it still keep looping. If it keep looping how can I stop it if pixel is found.
Will 2nd while loop start executing if 1st one is not done. I mean if question before had answer that it doesn't stop looping it means 2nd script would start after 30 seconds.
Is it possible to read from window bigger part than only pixel? Something like part of picture an so on, if so could you point me to such format
How to read something from outside file (I would like to make configuration file) and save it in variable. Lets say I have .txt file with accountName:password and now I want to take only accountName out of it and save it in variable, same this with password.
Can I use variables declared in other loops, I mean in this my code I used coord1 in 2nd while loop, is coord from first loop accessible by 2nd loop?
__________________________________________________________________________________________________________
Parts of my questions are covered in tutorials and questions already asked, but I questioned them here in way I haven't been able to understand them from Internet found references.
Thanks for your time reading my topic and taking time answering my noobish questions.
↧
Issues sending characters to command line.
Hi All,
I've been wrestling with this for a few days now and would appreciate a bit of direction.
I'm trying to automate Adobe's AUSST, which syncs a local server with Adobe's updates, much like Microsoft's WSUS.
In their infinite wisdom, their AUSST tool is menu driven from the command line. No parameters exist... other than to specify the root directory. You have to type in a "2" and hit Enter, wait for the sync (could be quite long depending on the amount/size of updates available, no updates available still takes over a minute), then enter "4", hit ENTER to close.
So, here's what I've got currently (I've tried myriad other things)
I plan on doing a very long sleep in place of the msgbox, and then doing the "4" and {ENTER} to quit.
I tried ControlCommand things, and ran into some issues with ControlID (seems it changes for every launch).
if it helps, this is on a Windows2k8 r2 x64 server.
Thanks!
I've been wrestling with this for a few days now and would appreciate a bit of direction.
I'm trying to automate Adobe's AUSST, which syncs a local server with Adobe's updates, much like Microsoft's WSUS.
In their infinite wisdom, their AUSST tool is menu driven from the command line. No parameters exist... other than to specify the root directory. You have to type in a "2" and hit Enter, wait for the sync (could be quite long depending on the amount/size of updates available, no updates available still takes over a minute), then enter "4", hit ENTER to close.
So, here's what I've got currently (I've tried myriad other things)
AutoItSetOption("WinTitleMatchMode", 3) ;due to issues i had with necessary quotes in the launch parameter local $parm = " --root=""C:\inetpub\www2root\AdobeUpdate\oobee""" ;execution does work, so I'm good to this point ShellExecute('C:\inetpub\wwwroot\AdobeUpdate\AdobeUpdateServerSetupTool2.0.exe', $parm ) ;make sure it is ready for input sleep(4500) ;test for active if WinWaitActive("C:\inetpub\wwwroot\AdobeUpdate\AdobeUpdateServerSetupTool2.0.exe") Then ;send commands Send("2", 1) Send("{ENTER}",1) ;let me know an attempt was made msgbox (0, "sent", "sent") EndIf
I plan on doing a very long sleep in place of the msgbox, and then doing the "4" and {ENTER} to quit.
I tried ControlCommand things, and ran into some issues with ControlID (seems it changes for every launch).
if it helps, this is on a Windows2k8 r2 x64 server.
Thanks!
↧
good way to determine a filecopy is complete?
hello world!
i have seen other examples in the forum where people have come across filecopy's not completing so the next steps fail
i am also coming across this issue with this (doesnt always happen but the file ends up deleting - guess because its in the midst of being replaced then the shellexecute command is called so it interrupts the copy? - not sure)
im curious how other people might be addressing this issue - was thinking of approaching it this way...
thanks!
i have seen other examples in the forum where people have come across filecopy's not completing so the next steps fail
i am also coming across this issue with this (doesnt always happen but the file ends up deleting - guess because its in the midst of being replaced then the shellexecute command is called so it interrupts the copy? - not sure)
[ autoit ]
im curious how other people might be addressing this issue - was thinking of approaching it this way...
[ autoit ]
thanks!
↧
InputBox is black when executed with PsExec
Hi All
I am working on a script that will map a network share remotely. Since network shares are mapped under user context it will require the credentials of the user.
To avoid asking the user for these explicitly, I wrote a script that will prompt them for their Username and Password through InputBox (See Below.)
To keep the password as secret as possible I generate a random string and use _StringEncrypt() passing all info through an .ini file.
The script uses PsExec on the local machine to execute the InputBox script on the remote machine.
However, when the script is executed the prompts show up black. Information can still be typed in the boxes but you can't see anything. (See attachment)
I've searched through the forum a few times and found a couple of posts with similar problems but they were resolved using PsExec...since I am already doing that I am not sure where to go from here.
Any thoughts would be appreciated and any advice on better code is more than welcome.
Main code that will transfer the InputBox and execute the needed commands:
Code for the InputBox:
I am working on a script that will map a network share remotely. Since network shares are mapped under user context it will require the credentials of the user.
To avoid asking the user for these explicitly, I wrote a script that will prompt them for their Username and Password through InputBox (See Below.)
To keep the password as secret as possible I generate a random string and use _StringEncrypt() passing all info through an .ini file.
The script uses PsExec on the local machine to execute the InputBox script on the remote machine.
However, when the script is executed the prompts show up black. Information can still be typed in the boxes but you can't see anything. (See attachment)
I've searched through the forum a few times and found a couple of posts with similar problems but they were resolved using PsExec...since I am already doing that I am not sure where to go from here.
Any thoughts would be appreciated and any advice on better code is more than welcome.
Main code that will transfer the InputBox and execute the needed commands:
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=test\netdrive.exe #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <String.au3> $hname = InputBox("Hostname/Ip", "Please enter the Hostname or IP for the Machine: ") FileCopy("C:\netdrive_user.exe", "\\" & $hname & "\C$\") $pwd = "" Dim $aSpace[3] $digits = 15 For $i = 1 To $digits $aSpace[0] = Chr(Random(65, 90, 1)) ;A-Z $aSpace[1] = Chr(Random(97, 122, 1)) ;a-z $aSpace[2] = Chr(Random(48, 57, 1)) ;0-9 $pwd &= $aSpace[Random(0, 2, 1)] Next IniWrite("\\" & $hname & "\C$\netdrive.ini", "ePsswd", "ePass", $pwd) RunWait("C:\Windows\Support\PSExec.exe \\" & $hname & Chr(32) & "-i" & Chr(32) & "C:\netdrive_user.exe") ;RunWait("\\" & $hname & "\C$\netdrive_user.exe", "\\" & $hname & "\C$\") $pwssd = _StringEncrypt(0, IniRead("\\" & $hname & "\C$\netdrive.ini", "Password", "Password", "Not Found"), $pwd, 1) $uname = IniRead("\\" & $hname & "\C$\netdrive.ini", "Username", "UName", "Not Found")
Code for the InputBox:
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=..\..\..\..\..\netdrive_user.exe #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Misc.au3> #include <String.au3> $uname = InputBox("UserName", "Please Enter your Username: ") $psswd = InputBox("Password", "Please Enter your Password: ", "", "*") $ePsswd = _StringEncrypt(1, $psswd, IniRead("C:\netdrive.ini", "ePsswd", "ePass", "")) IniWrite("C:\netdrive.ini", "Username", "UName", $uname) IniWrite("C:\netdrive.ini", "Password", "Password", $ePsswd)
↧
↧
ProcessExists
i am trying to make a program to shutdown a specific game(metin2) if its process is detected so my nephew stops playing the game, i think it's a bad influence on him ![:)]()
the problem is that if hi gets the client of the game from a diferite private server it has diferite process names and hy can run it
can i insert a wildcard in the process name ? something like this
and how do i do that ?

the problem is that if hi gets the client of the game from a diferite private server it has diferite process names and hy can run it
can i insert a wildcard in the process name ? something like this
[ autoit ]
↧
Help translating a DLL function
that what i have got till now
Function Description:
Thanks in advance
Func OmPlrAttach($OM_HWND, $Pointer) ConsoleWrite($Pointer & @CRLF) $cResult = DllCall($hdll, "long:cdecl", "OmPlrAttach", "handle", $OM_HWND, "str", $Pointer, "UINT", 0, "UINT", 5) If $cResult[0] = 0 Then _ArrayDisplay($cResult) Return $cResult[2] Else ConsoleWrite("! Error Decimel Code = " & $cResult[0] & @CRLF) ConsoleWrite("! Error Verbal Description = " & OM_ReturnVerbalError($cResult[0]) & @CRLF) Return OM_ReturnVerbalError($cResult[0]) EndIf EndFunc ;==>OmPlrAttach
Function Description:
OmPlrAttach Description: Used to attach a clip to the timeline. Also used to create a new clip. OmPlrError OmPlrAttach( OmPlrHandle PlayerHandle, const TCHAR *pClipName, uint clipIn, uint clipOut, OmPlrClipHandle hPutBeforeThisClip, OmPlrShiftMode shift, OmPlrClipHandle *pClipAttachHandle); Parameters: Parameter Description: PlayerHandle: A numeric value used to reference this player. It was obtained using the function OmPlrOpen. pClipname: A pointer to anull-terminated string that gives the clip name. For non- Unicode builds, this is an 8-bit character string. For Unicode builds, this is a 16-bit character string. The clip name is case sensitive, so that “Harry” is not the same clip as “haRRy”. The argument can specify either a clip or the combination of an absolute path and a clip; see Clip Name as Function Argument for more details. The size of the argument is limited to 512. clipIn: A number that identifies the first frame of this clip to be shown (inclusive). The special value omPlrClipDefaultIn can be used; this value is defined in omplayerdefs.h. It means that the “Default In” frame value found in the stored version of the clip will be used for the clipIn value. clipOut: A number that identifies the frame after the last frame of this clip to be shown. The special value omPlrClipDefaultOut can be used; this value is defined in omplayerdefs.h. It means that the “Default Out” frame value found in the stored version of the clip will be used for the clipOut value. hPutBeforeThisClip: A numeric value that is 0 or is the OmPlrClipHandle of an already attached clip. Typically a clip will be attached at the end of the timeline after all clips that were previously attached. But you can also attach a clip in front of other clips that are already attached to the timeline. Use a value of 00 to attach at the end (i.e., to append). Use the OmPlrClipHandle value of the already attached clip if you want to attach this clip in front of the already attached clip.
Thanks in advance
↧
Com send and receive
I'm really hoping i'm not double posting but i have been looking around and have not found the answer. I have the Arduino Uno, and it communicates to the USB via COM port 3. however I'm trying to use auto IT in order to send and receive data from the unit. The format of the data I send is not important, string would probably be the easiest. However I can't find any information on how to communicate over COM port 3. If anybody has a snippet of code, or can point me in the right direction it would be appreciated.
↧
Paint Bot
I have a paint application where I can enter into a console a hex code to change the color. I'm trying to make it so that I can load an image and the bot will examine the pixels, create a unique array of all colors. Afterwards, loop over the image looking for each color and then paint the pixel in every location that the image has a pixel of that color.
What I've written will process the image and get the colors. Then, when looping over the unique color array, it will change the color using the console but often times doesn't paint any pixels. This behavior doesn't make since because it got the colors from the image originally. Therefore, it should be painting at least 1 pixel per color found...
Also, it occasionally switches/pulls a random screen from the background forwards and messes up even more.
Basically:
Shift + Alt + S sets the mouse offset for where the image should be drawn.
Shift + Alt + C sets the location to click within the console window
Alt + S pauses the painting loop
Here is the code:
Any idea what's goin' on and how I can fix it?
Thanks
What I've written will process the image and get the colors. Then, when looping over the unique color array, it will change the color using the console but often times doesn't paint any pixels. This behavior doesn't make since because it got the colors from the image originally. Therefore, it should be painting at least 1 pixel per color found...
Also, it occasionally switches/pulls a random screen from the background forwards and messes up even more.
Basically:
Shift + Alt + S sets the mouse offset for where the image should be drawn.
Shift + Alt + C sets the location to click within the console window
Alt + S pauses the painting loop
Here is the code:
[ autoit ]
;image control from memory coded by UEZ 2011 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <Array.au3> #Include <memory.au3> HotKeySet("!s", "ToggleRunning") HotKeySet("+!s", "SetOffset") HotKeySet("+!c", "SetConsoleBox") _GDIPlus_Startup() Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 Global $msg Global Const $hBmp = Load_BMP_From_Mem(InetRead("https://www.google.com/images/srpr/logo3w.png"), True) ;to load an image from the net Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) Global Const $iWidth = _GDIPlus_ImageGetWidth($hBitmap) Global Const $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Global Const $hGUI = GUICreate("Display PNG Image in picture control", $iWidth, $iHeight) Global Const $idPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)) GUISetState() Global $running = False Global $currX = 0 Global $currY = 0 Global $offset = 0 Global $consoleBox = 0 Global $colorArray[1] ; Color to skip, normally a background color ; you wish to be transparent $colorArray[0] = "#gggggg" ; Process the image For $row = 0 to $iHeight ConsoleWrite("Processing image... Row: " & $row & "/" & $iHeight & @LF) For $col = 0 to $iWidth $color = _GDIPlus_BitmapGetPixel($hBitmap, $row, $col) Local $iIndex = _ArraySearch($colorArray, $color, 0, 0, 0, 1) If @error Then _ArrayAdd( $colorArray, $color ) EndIf Next Next ConsoleWrite("Processing complete... Found " & UBound( $colorArray ) & " colors" & @LF) ; Main loop While True $msg = GUIGetMsg() Switch $msg Case $idPic MsgBox(0, "Information", "PNG image was clicked") Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndSwitch ; Drawing loop If Not ($offset == 0) And Not ($consoleBox == 0) And $running Then For $i = 1 to UBound( $colorArray ) - 1 MouseClick ( "left", $consoleBox[0], $consoleBox[1] ) Send("{#}" & $colorArray[ $i ]) Send("{Enter}") For $col = $currY to $iHeight For $row = $currX to $iWidth $color = _GDIPlus_BitmapGetPixel($hBitmap, $row, $col) If $colorArray[ $i ] = $color Then ConsoleWrite($colorArray[ $i ] & " :: " & $color & @LF) MouseClick ( "left", $offset[0] + $currX, $offset[1] + $currY ) Sleep ( 100 ) EndIf $currX += 1 Next $currY += 1 Next $currX = 0 $currY = 0 Sleep ( 3000 ) Next EndIf WEnd Func SetOffset() $offset = MouseGetPos(); EndFunc Func SetConsoleBox() $consoleBox = MouseGetPos(); EndFunc Func ToggleRunning() $running = Not $running; While Not ($running) Sleep( 1000 ) WEnd EndFunc ;====================================================================================== ; Function Name: Load_BMP_From_Mem ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap ; ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+ ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created ; ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown() ; ; Requirement(s): GDIPlus.au3, Memory.au3 and _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format), ; Error: 0 ; Error codes: 1: $bImage is not a binary string ; 2: unable to create stream on HGlobal ; 3: unable to create bitmap from stream ; ; Author(s): UEZ ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and ; Yashied for _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Version: v0.97 Build 2012-04-10 Beta ;======================================================================================= Func Load_BMP_From_Mem($bImage, $hHBITMAP = False) If Not IsBinary($bImage) Then Return SetError(1, 0, 0) Local $aResult Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary Local Const $len = BinaryLen($memBitmap) ;get length of image Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002) Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents If @error Then Return SetError(2, 0, 0) Local Const $hStream = $aResult[3] $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface If @error Then Return SetError(3, 0, 0) Local Const $hBitmap = $aResult[2] Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _ "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak $tMem = 0 $tVARIANT = 0 If $hHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>Load_BMP_From_Mem Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0 $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0) If (@error) Or ($Ret[0]) Then Return 0 $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) $pBits = DllStructGetData($tData, 'Scan0') If Not $pBits Then Return 0 $tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword') DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 2, $Ret[2]) DllStructSetData($tBIHDR, 3, $Ret[3]) DllStructSetData($tBIHDR, 4, 1) DllStructSetData($tBIHDR, 5, 32) DllStructSetData($tBIHDR, 6, 0) $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0) If (Not @error) And ($hResult[0]) Then DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0')) $hResult = $hResult[0] Else $hResult = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Return $hResult EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap ;The GetPixel method gets the color of a specified pixel in this bitmap. ;GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, ARGB *color) ; Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "#" & Hex(DllStructGetData($tArgb, "Argb"), 6) EndFunc
Any idea what's goin' on and how I can fix it?
Thanks
↧
↧
GDI Plus Image Histogram
Hi all,
I'm trying to better understand the excellent GDIP UDF by Authenticity
So I set myself a simple project to try and create a tonal histogram of an image; I use this in Photoshop a lot.
I started with an old example by Toady at the below link (Thank you Toady for getting me started)
http://www.autoitscript.com/forum/topic/44771-histogram-and-average-color/
Unfortunately 'PixelGetColor' seems very slow, so I wanted to see how fast GdipGetPixel would be.
So, starting with Toady's example, and using GdipGetPixel function by Vossen and ImageScale and Greyscale functions by Uez (Thank you to all) I have the script below...
However, the reason I'm posting in General Help and Support is I found two functions within GDIP v1.1 (Vista and above?) that may be exactly what I want.
two dllcalls instead of 2000
GdipBitmapGetHistogramSize and GdipBitmapGetHistogram
http://msdn.microsoft.com/en-us/library/windows/desktop/ms536307(v=vs.85).aspx
I know nothing about dllcalls but I've tried altering various examples in GDIP.au3 to see if I can get these to work.
After hours of trying on the 'GdipBitmapGetHistogramSize' I've realized I have no hope without a better understanding; I keep getting '0' as a result.
I would greatly appreciate anyone who comes across this post with the knowledge and time to show me how to call these functions.
Many thanks
Jardz
I'm trying to better understand the excellent GDIP UDF by Authenticity
So I set myself a simple project to try and create a tonal histogram of an image; I use this in Photoshop a lot.
I started with an old example by Toady at the below link (Thank you Toady for getting me started)
http://www.autoitscript.com/forum/topic/44771-histogram-and-average-color/
Unfortunately 'PixelGetColor' seems very slow, so I wanted to see how fast GdipGetPixel would be.
So, starting with Toady's example, and using GdipGetPixel function by Vossen and ImageScale and Greyscale functions by Uez (Thank you to all) I have the script below...
[ autoit ]
#include <GDIP.au3> #include <Array.au3> #include <GUIConstants.au3> Global $iSampleRate = 20000 ; Number of pixels read for histogram, the higher the more accurate but slower. Global $histos, $histo $gui = GUICreate("Histogram",278,200,-1,-1) $pen = GuiCtrlCreateGraphic(10,10, 258, 150) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlCreateLabel("Sample Rate:",20,160) $sample = GUICtrlCreateInput($iSampleRate,20,175,70,20) ;GUICtrlSetState(-1, $GUI_DISABLE) $BtnOpen= GUICtrlCreateButton("Open", 180, 165, 78, 30) GUISetState() While 1 Switch GUIGetMsg() Case $BtnOpen _main() Case $GUI_EVENT_CLOSE _GDIPlus_ShutDown() Exit EndSwitch WEnd Func _main() Local $tmp $iSampleRate = GUICtrlRead($sample) If $tmp < 1 and $tmp > 99999999 Then GUICtrlSetData($sample,10000) $iSampleRate = 10000 EndIf Local $sFile = FileOpenDialog("Open File", @WorkingDir, "All Picture Files (*.bmp;*.gif;*.jpg;*.jpeg;*.tif;*.tiff;*.png)", 3) Local $t = TimerInit() $aArrayHist = _Histogram($sFile, $iSampleRate) Local $d = Round(TimerDiff($t)/1000,2) ConsoleWrite("Time to build histogram = " & $d & @CRLF) RenderHistogram($aArrayHist) Local $d = Round(TimerDiff($t)/1000,2) ConsoleWrite("Total Time = " & $d & @CRLF) EndFunc Func RenderHistogram($a) Local $max = _ArrayMax($a,1,1) GuiCtrlDelete($pen) $pen=GuiCtrlCreateGraphic(10,10, 258, 150) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetState(-1, $GUI_DISABLE) For $i = 1 To UBound($a)-1 GUICtrlSetGraphic($pen,$GUI_GR_MOVE, $i,150) GUICtrlSetGraphic($pen,$GUI_GR_LINE, $i,150 - Round(140*($a[$i]/$max),0)) Next GUICtrlSetColor(-1,0x000000) EndFunc Func _Histogram($fImage, $iSampleRate) If $fImage = "" Then Return SetError(1, 0, 0) If Not FileExists($fImage) Then Return SetError(2, 0, 0) Local $fName = StringRegExpReplace($fImage, ".*\\(.*).{4}", "$1") Local $declared = True If Not $ghGDIPDll Then _GDIPlus_Startup() $declared = False EndIf Local $hImageFromFile = _GDIPlus_ImageLoadFromFile($fImage) Local $iWidth = _GDIPlus_ImageGetWidth($hImageFromFile) Local $iHeight = _GDIPlus_ImageGetHeight($hImageFromFile) Local $ratio If $iWidth*$iHeight > $iSampleRate Then $ratio = $iWidth/$iHeight $iW = Int(Sqrt($iSampleRate*$ratio)) $iH = Int(sqrt($iSampleRate/$ratio)) Else $iW = $iWidth $iH = $iHeight EndIf Local $hImageThumbnail = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) If @error Then Return SetError(3, 0, 0) $hImageThumbnail = $hImageThumbnail[6] Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hImageThumbnail) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", 7) _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImageFromFile, 0, 0, $iW, $iH) _GDIPlus_ImageDispose($hImageFromFile) _GDIPlus_GraphicsDispose($hBmpCtxt) ; If you don't want to transfer to greyscale then comment out below ;#CS $hImageContext = _GDIPlus_ImageGetGraphicsContext($hImageThumbnail) Local $tNegMatrix, $pNegMatrix $tNegMatrix = _GDIPlus_ColorMatrixCreateGrayScale() $pNegMatrix = DllStructGetPtr($tNegMatrix) $hIA = _GDIPlus_ImageAttributesCreate() _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $pNegMatrix) _GDIPlus_GraphicsDrawImageRectRectIA($hImageContext, $hImageThumbnail, 0, 0, $iW, $iH, 0, 0, $iW, $iH, $hIA) _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hImageContext) ;#CE $aHist = _BuildHistogramArray($hImageThumbnail) _GDIPlus_ImageDispose($hImageThumbnail) _GDIPlus_Shutdown() Return $aHist EndFunc Func _BuildHistogramArray($hBitmap) Local $tArgb, $pArgb, $aRet, $blue, $red, $green, $w, $h $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) Local $Hist[257] For $i = 0 To UBound($Hist) - 1 $Hist[$i] = 0 Next $w = _GDIPlus_ImageGetWidth($hBitmap) $h = _GDIPlus_ImageGetHeight($hBitmap) ConsoleWrite("Thumbnail W = " & $w & @CRLF & "Thumbnail H = " & $h & @CRLF) ;-------------Use the following if you've changed the bitmap thumbnail to greyscale otherwise comment out and use the next one---------- For $i = 1 To $h For $j = 1 To $w $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $j, "int", $i, "ptr", $pArgb) $Hist[Dec(Hex(DllStructGetData($tArgb, "Argb"),2))+1] +=1 $Hist[0] += 1 Next Next ;-------------If you're keeping bitmap as RGB and not Greyscale then use below to build Array for Histogram------------------------------ #cs For $i = 1 To $h For $j = 1 To $w $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $j, "int", $i, "ptr", $pArgb) $color_hex = "0x" & Hex(DllStructGetData($tArgb, "Argb") ,6) $Hist[Round((BitAND($color_hex,255) + BitShift(BitAND($color_hex,65280),0x08) + BitShift(BitAND($color_hex,16711680),0x10))/3,0)+1] += 1 $Hist[0] += 1 Next Next #ce $Hist[2] = ($Hist[1] + $Hist[3])/2 ConsoleWrite("Total Count = " & $Hist[0] & @CRLF) Return $Hist EndFunc Func ScaleImage($hImage, $iScaleW, $iScaleH, $iInterpolationMode = 7) ;coded by UEZ 2012 Local $iWidth = _GDIPlus_ImageGetWidth($hImage) * $iScaleW Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * $iScaleH Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) If @error Then Return SetError(3, 0, 0) $hBitmap = $hBitmap[6] Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode) _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iWidth, $iHeight) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc
However, the reason I'm posting in General Help and Support is I found two functions within GDIP v1.1 (Vista and above?) that may be exactly what I want.
two dllcalls instead of 2000
GdipBitmapGetHistogramSize and GdipBitmapGetHistogram
http://msdn.microsoft.com/en-us/library/windows/desktop/ms536307(v=vs.85).aspx
I know nothing about dllcalls but I've tried altering various examples in GDIP.au3 to see if I can get these to work.
After hours of trying on the 'GdipBitmapGetHistogramSize' I've realized I have no hope without a better understanding; I keep getting '0' as a result.
I would greatly appreciate anyone who comes across this post with the knowledge and time to show me how to call these functions.
Many thanks
Jardz
↧
mailto: character limit
I'm attempting to generate an email that has the subject and body already filled in. I want the "To" to be left blank for the user to fill in. The body of the message has the potential to be very long, and I'm running into the character limits if I do a ShellExecute(mailto:blah,blah,blah) command. Is there any way around this? We use Lotus Notes, but I would like to make it generically just open the user's default email client. Is there a way to pull this off?
↧
detect is mouse is really pressed
hi there, i got a question :
is there a way to make a check of the kind of ''_IsPressed'' but that wouldn't take care of the ''fake key pressed'' by that i mean like when you send a mouse click from autoit,
i have also tried with GetKeyState and GetAsyncKeyStat but both had the same result
so in small word's it would only check for the mouse click that the person pressed himself not the one send by the script, and if the person pressed then do the rest of the script
i have checked and haven't found a post for this, but i found ''_WinAPI_setWindowsHookEx'' i actually don't understand it, i also checked for it in the msnd but still haven't understand
help would be appreciated
**Sorry for my bad english**
is there a way to make a check of the kind of ''_IsPressed'' but that wouldn't take care of the ''fake key pressed'' by that i mean like when you send a mouse click from autoit,
i have also tried with GetKeyState and GetAsyncKeyStat but both had the same result
so in small word's it would only check for the mouse click that the person pressed himself not the one send by the script, and if the person pressed then do the rest of the script
i have checked and haven't found a post for this, but i found ''_WinAPI_setWindowsHookEx'' i actually don't understand it, i also checked for it in the msnd but still haven't understand
help would be appreciated
**Sorry for my bad english**
↧
Convert bash or powershell to AutoIT
I really want to use AutoIT to perform a search for lines beginning with a string and then replace the whole line with a substitute. (quickly for an entire file)
In powershell I do it like this:
$ComputerName = $env:COMPUTERNAME
$FilePath = "C:\scripts\data.txt"
$FindIT = "WorkstationID"
$ReplaceIT = ("WorkstationID=" + $ComputerName + "stuff")
#"----------------------"
(Get-Content ($FilePath)) |
Foreach-Object { $_ -replace ('^' + $FindIT + '.*$'), $ReplaceIT } |
Set-Content ($FilePath)
"cat the file to screen to see changes"
"-----------------------------------------------"
Get-Content ($FilePath) | foreach {Write-Output $_}
in bash I do it like this, yes it's Linux but I need to do this type of thing in Windows:
swap()
#------------------------ swap function ------------------------------------------
# this little function is for a find and replace of lines starting with a string
# first parameter is the file to be modified
# second parameter is the line that begins with the string provided (all occurances)
# third parameter is the entire line of data to insert in the place of second parameter
{
#echo first command line parameter (file name) is "$1"
#echo second parameter (search for) is "$2"
#echo third parameter (replace string) is "$3"
if [ ! -f $1 ]
then
echo "A find and replace command was attempted against $1 but the file could not be found!"
return
else
mv $1 $1"-temp1"
varFind="$2"
varReplace="$3"
cat $1"-temp1" | sed -e "s,^$varFind.*,$varReplace,g" >> $1
rm -f $1"-temp1"
echo "Modified $1 with $3"
fi
};
#-------------- end swap ------------------------------------------------------
How do I do this in AutoIT?
In powershell I do it like this:
$ComputerName = $env:COMPUTERNAME
$FilePath = "C:\scripts\data.txt"
$FindIT = "WorkstationID"
$ReplaceIT = ("WorkstationID=" + $ComputerName + "stuff")
#"----------------------"
(Get-Content ($FilePath)) |
Foreach-Object { $_ -replace ('^' + $FindIT + '.*$'), $ReplaceIT } |
Set-Content ($FilePath)
"cat the file to screen to see changes"
"-----------------------------------------------"
Get-Content ($FilePath) | foreach {Write-Output $_}
in bash I do it like this, yes it's Linux but I need to do this type of thing in Windows:
swap()
#------------------------ swap function ------------------------------------------
# this little function is for a find and replace of lines starting with a string
# first parameter is the file to be modified
# second parameter is the line that begins with the string provided (all occurances)
# third parameter is the entire line of data to insert in the place of second parameter
{
#echo first command line parameter (file name) is "$1"
#echo second parameter (search for) is "$2"
#echo third parameter (replace string) is "$3"
if [ ! -f $1 ]
then
echo "A find and replace command was attempted against $1 but the file could not be found!"
return
else
mv $1 $1"-temp1"
varFind="$2"
varReplace="$3"
cat $1"-temp1" | sed -e "s,^$varFind.*,$varReplace,g" >> $1
rm -f $1"-temp1"
echo "Modified $1 with $3"
fi
};
#-------------- end swap ------------------------------------------------------
How do I do this in AutoIT?
↧
↧
Import Random function to Autoit
Hello.
Time ago, looking examples in the forum, I wrote a little script that looks for the mp3 and wav files in @scriptsfolder and plays one of them randomly:
Later talking with a friends he said me that:
He asked me if I was able to port his code to my little Autoit script to generate random number, but my random number comes from the number of sound files found in the script's folder and his code comes from Guid.newGuid() and from GetHashCode() and always based on a number from 1 to 100.
Is there any way to implement his code into mine's?
Thanks in advance.
Greets from Barcelona
(Now I have to go to work, so I will edit the post later trying to be more polite)
Time ago, looking examples in the forum, I wrote a little script that looks for the mp3 and wav files in @scriptsfolder and plays one of them randomly:
[ autoit ]
#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <ButtonConstants.au3> #include <Sound.au3> #include <File.au3> GUICreate("PRESS ESCAPE TO CLOSE SOUND PLAYING", 560, 380, -1, -1) GUISetState(@SW_SHOW) GUICtrlCreateLabel("PRESS ESCAPE TO CLOSE SOUND PLAYING", 30, 40, 500, 300, $SS_CENTER) GUICtrlSetFont(-1, 50, 10, 0)AutoItSetOption ( "GUIOnEventMode", 1) GUISetOnEvent ( $GUI_EVENT_CLOSE, "On_Exit" ) Func On_Exit() Exit EndFunc ;==>On_ExitHotKeySet("{ESC}", "On_Exit") $folder = @ScriptDir$list = _FileListToArray($folder, "*.mp3|*.wav", 1) For $iX = 1 To $list[0] $song = _SoundOpen($folder & "\" & $list[$iX]) _SoundPlay($song) Do Sleep(100) Until _SoundStatus($song) = "stopped" _SoundClose($song) canciones() Next While 1 $nmsg = GUIGetMsg() Select Case $nmsg = $GUI_EVENT_CLOSE On_Exit() EndSelect WEnd Func canciones() For $iX = 1 To $list[0] $song = _SoundOpen($folder & "\" & $list[$iX]) _SoundPlay($song) Do Sleep(100) Until _SoundStatus($song) = "stopped" _SoundClose($song) canciones() NextEndFunc ;==>canciones
Later talking with a friends he said me that:
Quote
I found out that my random numbers I generate with my program are not THAT random, ... it's hard to explain, since it's all random there are no real facts, but only a feeling after lot's of testing.
And the feeling says that it's not totally random as in "the law of random", ... it's just had too many of the same random numbers.
Then I googled and found a solution which works now fine for me, ... when I create a random number it looks like this in C# code:
The fix which makes the randomness even more random is this:
I have exchanged every "new Random();" with that and now it "feels" much more random.
And the feeling says that it's not totally random as in "the law of random", ... it's just had too many of the same random numbers.
Then I googled and found a solution which works now fine for me, ... when I create a random number it looks like this in C# code:
Quote
Random randomNumber = new Random();
int newRandomNumber = randomNumber.Next(1, 101);
int newRandomNumber = randomNumber.Next(1, 101);
The fix which makes the randomness even more random is this:
Quote
Random randomNumber = new Random(Guid.NewGuid().GetHashCode());
int newRandomNumber = randomNumber.Next(1, 101);
int newRandomNumber = randomNumber.Next(1, 101);
I have exchanged every "new Random();" with that and now it "feels" much more random.
He asked me if I was able to port his code to my little Autoit script to generate random number, but my random number comes from the number of sound files found in the script's folder and his code comes from Guid.newGuid() and from GetHashCode() and always based on a number from 1 to 100.
Is there any way to implement his code into mine's?
Thanks in advance.
Greets from Barcelona
(Now I have to go to work, so I will edit the post later trying to be more polite)
↧
Error affter build error variable used without being declared
Hello everybody!
I have a broblem when build my code:
In code i can run but affter build it show error variable used without being declared.
I don't know this error, please help me!
I have a broblem when build my code:
In code i can run but affter build it show error variable used without being declared.
I don't know this error, please help me!
Attached Files
↧
Do I declare $vars multiple times?
Hey guys,
maybe some of you noticed that i posted some weeks ago a Topic about 'AutoIt causes memory leak?'. The Bug report got closed and I'm still working on this Script to find the mistake...
Now I've rebuilded the Script back without SQL, without Listviews, and without real .bat files. If the memory of this Script now still rise, it has to me my mistake maybe because I declare some $vars multiple times or I dont know, otherway it has to be a problem of AutoIt. Am I right?
So what I noticed is, I start around 11.600K RAM and after 18 hours I'm around 11.776K RAM ...
Some different Script without SQL, without Listviews, but with real .bat files startet around 11.724K RAM and after 18 hours 13.060K RAM.Thats my Script (w/o SQL, Listview, Batch):
Could you guys please take a look if I'm causing the memory leak or AutoIt?
Maybe some ohter Informations: I wrote Testscripts for Run, RunWait (and both with @ComSpec), ShellExecute,ShellExecuteWait (and both with CMD) and the only two commands where memory isnt rising is Run and RunWait without @ComSpec!Then I wrote some Testscript to check if my funktion write_log maybe causes a memory leak. Did the test 2 times, both with 100.000 times of writing, and closing file, memory stayed same.
I hope some of you can help me, working for 2 1/2 months on my real script now and dunno if it makes sense to try to finish it in AutoIt :/
Regards
maybe some of you noticed that i posted some weeks ago a Topic about 'AutoIt causes memory leak?'. The Bug report got closed and I'm still working on this Script to find the mistake...
Now I've rebuilded the Script back without SQL, without Listviews, and without real .bat files. If the memory of this Script now still rise, it has to me my mistake maybe because I declare some $vars multiple times or I dont know, otherway it has to be a problem of AutoIt. Am I right?
So what I noticed is, I start around 11.600K RAM and after 18 hours I'm around 11.776K RAM ...
Some different Script without SQL, without Listviews, but with real .bat files startet around 11.724K RAM and after 18 hours 13.060K RAM.Thats my Script (w/o SQL, Listview, Batch):
[ autoit ]
#include #include #include #include Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) OnAutoItExitRegister("_exit") Global $aQueue[1][3] Global $aTasks[5][2] Global $sScriptstatus Global $hGUI = GUICreate("Aufgabenliste", 250, 390) Global $iCounter_label = 0 Global $hCounter_label = GUICtrlCreateLabel("0", 50, 72, 200, 20) Global $hLoadBtn = GUICtrlCreateButton("Load", 140, 40, 100, 30) Global $hStartBtn = GUICtrlCreateButton("Start", 30, 5, 50, 30) Global $hStopBtn = GUICtrlCreateButton("Stop", 30, 40, 50, 30) GUISetState(@SW_SHOW, $hGUI) GUICtrlSetOnEvent($hLoadBtn, "_load") GUICtrlSetOnEvent($hStartBtn, "_check") GUICtrlSetOnEvent($hStopBtn, "_stop_working") GUISetOnEvent($GUI_EVENT_CLOSE, "_exit", $hGUI) While 1 Sleep(100) WEnd Func _load() $aQueue[0][0] = "0" $aQueue[0][1] = "18/01/2013 08:00:00" $aQueue[0][2] = "Test" EndFunc ;==>_load Func _check() $sScriptstatus = True AdlibRegister("_compare_datetimes", 1000) EndFunc ;==>_check Func _compare_datetimes() Local $aRow, $next_date, $aDate If UBound($aQueue) = 0 Then _stop_working() Return 0 EndIf $aRow = StringSplit($aQueue[0][1], " ") $next_date = $aRow[1] $aRow = StringSplit($aRow[2], ":") $aDate = StringSplit($next_date, "/") If $aDate[3] * 365 + $aDate[2] * 30 + $aDate[1] = @YEAR * 365 + @MON * 30 + @MDAY Then If $aRow[1] * 3600 + $aRow[2] * 60 = @HOUR * 3600 + @MIN * 60 + @SEC Or $aRow[1] * 3600 + $aRow[2] * 60 < @HOUR * 3600 + @MIN * 60 + @SEC Then $aRow = 0 $aDate = 0 _start() EndIf ElseIf $aDate[3] * 365 + $aDate[2] * 30 + $aDate[1] < @YEAR * 365 + @MON * 30 + @MDAY Then $aRow = 0 $aDate = 0 _start() EndIf $iCounter_label = $iCounter_label + 1 GUICtrlSetData($hCounter_label, $iCounter_label) $aRow = 0 $next_date = 0 $aDate = 0 EndFunc ;==>_compare_datetimes Func _start() Local $sError, $sStatus, $ShellExecute Local $aBatch[5][5] = [[1, 1, $aQueue[0][1], "Task 1", ""], _ [2, 2, $aQueue[0][1], "Task 2", ""], _ [3, 3, $aQueue[0][1], "Task 3", ""], _ [4, 4, $aQueue[0][1], "Task 4", ""], _ [5, 5, $aQueue[0][1], "_create_next_date", ""]] ReDim $aTasks[5][2] For $i = 0 To UBound($aBatch) - 1 $aTasks[$i][0] = $aBatch[$i][1] * 10 $aTasks[$i][1] = $aBatch[$i][3] Next For $i = 0 To UBound($aBatch) - 1 $sStatus = " ... started" If $aBatch[$i][4] = "" Then $sError = " " _write_log($sError, $aBatch[$i][4], $sStatus) $sError = "OK" $sStatus = " ... finished" _write_log($sError, $aBatch[$i][4], $sStatus) Else $sError = " " _write_log($sError, $aBatch[$i][4], $sStatus) $ShellExecute = Run($aBatch[$i][4], "c:", @SW_HIDE) If $ShellExecute <> 0 Then $sError = "FEHLER" $sStatus = " Something went wrong." Else $sError = "OK" $sStatus = " ... finished" EndIf _write_log($sError, $aBatch[$i][4], $sStatus) EndIf If UBound($aTasks) = 1 Then $aTasks[0][0] = "" $aTasks[0][1] = "" Else _ArrayDelete($aTasks, 0) EndIf Next Sleep(1000) If UBound($aQueue) = 1 Then $aQueue[0][0] = "" $aQueue[0][1] = "" $aQueue[0][2] = "" Else _ArrayDelete($aQueue, 0) EndIf $sError = 0 $sStatus = 0 $ShellExecute = 0 $aBatch = 0 _load() EndFunc ;==>_start Func _stop_working() AdlibUnRegister("_compare_datetimes") $sScriptstatus = False Return 0 EndFunc ;==>_stop_working Func _exit() Exit EndFunc ;==>_exit Func _write_log($sError, $sCommand, $sStatus) Local $hFile $hFile = FileOpen("log_woBATCHwoSQLwoLV.txt", 1) FileWriteLine($hFile, "[" & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "][" & $sError & "] " & $sCommand & " " & $sStatus) FileClose($hFile) EndFunc ;==>_write_log
Could you guys please take a look if I'm causing the memory leak or AutoIt?
Maybe some ohter Informations: I wrote Testscripts for Run, RunWait (and both with @ComSpec), ShellExecute,ShellExecuteWait (and both with CMD) and the only two commands where memory isnt rising is Run and RunWait without @ComSpec!Then I wrote some Testscript to check if my funktion write_log maybe causes a memory leak. Did the test 2 times, both with 100.000 times of writing, and closing file, memory stayed same.
I hope some of you can help me, working for 2 1/2 months on my real script now and dunno if it makes sense to try to finish it in AutoIt :/
Regards
↧