Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/25/2015 in all areas

  1. As many of you may not be aware, of much about AutoIt's humble beginnings, and aspects related to the first GUI version of AutoIt, I thought it might be nice to create a historical reference here for all the many GUI creators that have been created by various people over the years. NOTE - While one could argue, that this topic might be better placed in one of the Chat forums, I would argue, that it links to heaps of good code. While much may be redundant in that code, it is still interesting and forms a great perspective. Many are bound to find useful elements at the very least. Koda, is no doubt the most well-known GUI creator now, but there was a time, when CyberSlug's legendary GUIBuilder (first known as AutoBuilder) ruled the roost, and AutoIt coder's saw it as a Godsend. AutoIt coding was much simpler back then of course. Below, will be a timeline, of any AutoIt GUI creators listed in forum pages. It will be added to by myself as I find them or as others here find them and place a link in a subsequent post ... PLEASE HELP! Comments welcome too. (Also note, that this is also intended to include updates, branches etc by others) Apr 20 2004 - AutoBuilder by CyberSlug. Sep 27 2004 - An interesting topic, where CyberSlug talks about the future of AutoBuilder (etc) and renaming to GUIBuilder and you see the first mentions and links to updates by others (including myself & livewire). Nov 05 2004 - A topic where lookfar is working on a SciTE replacement, talks about starting a Form Designer. Aug 10 2005 - GuiBuilder first update by TheSaint. Sep 26 2005 - GUIBuilder updates by livewire (he also talks about transferring his efforts to Koda). Nov 02 2005 - KODA FormDesigner v1.3 by lookfar Nov 03 2005 - Seemingly interesting topic about forms by tonedeaf Dec 26 2005 - AutoIt Studio(beta) by BillLuvsU Jan 09 2006 - AutoBuilder update (or branch) by _^__darkbytez (livewire also posts). Feb 19 2006 - Koda v1.5 by lookfar Sep 07 2006 - Koda v1.7.3.0 by Lazycat Jan 07 2007 - Form/GUI Builder by FlintBrenick Jun 10 2007 - Gorganizer by _Kurt (more of an assister than actual GUI maker) Jun 27 2007 - Basic GUI Designer by Mast3rpyr0 May 03 2008 - Autoit Programmer's Desktop (APD) by Ealric Jul 11 2008 - Gui Designer by Alek Aug 11 2008 - Gorganizer update by _Kurt Jun 19 2009 - Easy GUI by Mat Aug 13 2009 - GUI Script Creator by Pandemic (not sure this qualifies, but it made me think of templates) Aug 16 2010 - Creation Gui by AZJIO Jan 22 2012 - ISN AutoIt Studio by ISI360 (includes ISN Form Studio 2, a GUI editor) Mar 19 2012 - Arduino GUI Programmer by nikosliapis (creates a specific type of GUI) Aug 01 2012 - GuiBuilder Resurrected update/branch to GUIBuilder by baroquebob Dec 01 2012 - Form Builder beta (v1.0.6) by BuckMaster Jan 12 2015 - GUIBuilderNxt update by jaberwacky of GUIBuilder v0.8 (as a new prototype, modified to work with latest AutoIt) (not a update to the Resurrected version) Aug 12 2016 - The GuiBuilder Return by DFerrato as an update to GUIBuilder, Jan 17 2017 - GUIBuilder Project by TheSaint (a work in progress based on CyberSlug's original ... and later versions, updated by Roy, TheSaint & others). May 29 2019 - The GuiBuilder Return by DFerrato as an update to GUIBuilder, His new and improved version. May 9 2022 - GuiBuilderPlus by kurtykurtyboy as an update to GUIBuilder. A new an improved version with more to come. There are a significant number of creators/designers that have been started and never completed. +++++ STILL UNDER CONSTRUCTION +++++ P.S. Well that's it from me tonight. I know of at least one other major creator, but cannot recall it's name or the name of the coder, though I think it starts with 'L'. Bound to be a few I've missed, and some I cannot seem to find their first appearance here (Koda, Form Builder, etc), but there may be an obvious reason for that. Will probably rely on feedback from others now that I've got the ball rolling. NOTE - If anyone wants to discuss any of these programs above or give some background history, then by all means do so. I will cross-reference (link to) any important comments.
    2 points
  2. CodeCrypter enables you to encrypt scripts without placing the key inside the script. This is because this key is extracted from the user environment at runtime by, for example: password user query any macro (e.g., @username) any AutoIt function call any UDF call some permanent environment variable on a specific machine (and not created by your script) a server response a device response anything else you can think of, as long as it's not stored in the script any combination of the above You need several scripts to get this to work, and they are scattered over several threads, so here's a single bundle that contains them all (including a patched version of Ward's AES.au3; with many thanks to Ward for allowing me to include this script here): Latest version: 3.4 (3 Dec 2021): please follow this link. Note: if you experience issues under Win8/8.1 (as some users have reported), please upgrade to Win10 (or use Win7) if you can; as far as I can tell, the scripts in the bundle all work under Win7 & Win10 (and XP). Moreover, I have no access to a Win8 box, so these issues will not be fixed, at least not by yours truly. How the bits and pieces fit together: CodeCrypter is a front-end for the MCF UDF library (you need version 1.3 or later). Its thread is here: '?do=embed' frameborder='0' data-embedContent>> The MCF package (also contained in the CodeScannerCrypter bundle) contains MCF.au3 (the library itself) plus a little include file called MCFinclude.au3. The latter you have to include in any script you wish to encrypt. Any code preceding it will not be encrypted, any code following it will be encrypted. You define the dynamic key inside MCFinclude.au3, in the UDF: _MCFCC_Init(). From the same post you can download an MCF Tutorial which I heartily recommend, because encrypting a script requires a number of steps in the right order, namely: In MCFinclude.au3, define and/or choose your dynamic key(s) (skip this step = use default setting) include MCFinclude.au3 in your target script Run CodeScanner (version 2.3+) on your target script, with setting WriteMetaCode=True (see '?do=embed' frameborder='0' data-embedContent>>), then close CodeScanner. Start CodeCrypter press the Source button to load your target file enable Write MCF0 (tick the first option in Main Settings) Enable "Encrypt" (last option in the Main Settings) Go to the Tab Encrypt and set up the encryption the way you want (skip this = use default settings) Return to Main Tab and press "Run" if all goes well, a new script called MCF0test.au3 is created in the same directory as your target. It has no includes and no redundant parts. Please check that it works as normal. (see Remarks if not) It all sounds far more complicated than it is, really. Not convinced? Check out: a simple HowTo Guide: HowToCodeCrypt.pdf an updated and extended Q & A pdf (FAQ, also included in the bundle) to help you get started:CodeCrypterFAQ.pdf For additional explanations/examples in response to specific questions by forum members (how it works, what it can/cannot do), see elsewhere in this thread, notably: Simple analogy of how it works: post #53, second part General Explanation and HowTo: post #9, 51, 75, 185/187, 196, 207, 270, 280 (this gets a bit repetitive) BackTranslation: post #179 Obfuscation: post #36 (general), 49 (selective obfuscation) Specific features and fixes: post #3 (security), 84 (redefining the expected runtime response), 169 (Curl Enum fix), 185/187 (using license keys), 194 (replacing Ward's AES UDF with different encryption/decryption calls), 251 (AV detection issue), 262 (extract key contents to USB on different target machine prior to encryption) Limitations: post #26 (@error/@extended), 149 (FileInstall), 191 (AES.au3 on x64) Not recommended: post #46/249 (static encryption), 102 (programme logic error), 237 (parsing password via cmdline) Technical notes: BackTranslation is a test to check that the MetaCode translation worked. Skip it at your peril. It also turns your multi-include composite script into a single portable file without redundant parts (you can opt to leave the redundant parts in, if you want). CodeCrypter can also obfuscate (vars and UDF names) and replace strings, variable names and UDF names with anything else you provide, for example, for language translation). After CodeScanner separates your target's structure from its contents, CodeCrypter (actually MCF, under the hood) can change any part, and then generate a new script from whichever pieces you define. See the MCF Tutorial for more explanation and examples. Encryption currently relies on Ward's excellent AES UDF and TheXman's sophisticated CryptoNG bundle. You can replace these with any other algorithm you like (but this is not trivial to do: edit MCFinclude.au3 UDF _MCFCC(), and MCF.au3 UDF _EncryptEntry(), see post #194 in this thread). AES by Ward, and CryptoNG by TheXman are also included in the bundle (with many thanks to Ward and TheXman for graciously allowing me to republish their outstanding work). Going to lie down now... RT
    1 point
  3. LAST VERSION - 1.0 25-Jan-15 This is my way to use the API ReadDirectoryChangesW in AutoIt. The problem is that to use this function will not work fully without creating thread. To solve this problem, I wrote the simple DLL that provides work with threads. As a result, the AutoIt script only receives and processes the appropriate data from thread. To evaluate all features of the library, please see the full example with GUI for monitoring directories. For more information, see description for each function within the library. The following are the main features of the RDC UDF library. Creating multiple threads (unlimited) for monitoring different directories.Support for hot (unsafe) unplugging of removable devices such as USB flash drive, etc.Support for network drives.Support for 32- and 64-bit processes (RDC.dll and RDC_x64.dll).Easy to use functions from the library.Full examples, including GUI. Available functions RDC UDF Library v1.0 (x86 and x64) Previous downloads: 17 RDC.zip Examples Simple (Notification mode) Advanced GUI
    1 point
  4. LockFile allows you to lock a file to the current process. This is useful if you want to interact with a specific file but wish to avoid the accidental deletion by another process or worse still a user. Examples have been provided and any advice for improvements is much appreciated. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: Lock_File ; AutoIt Version : v3.3.10.0 or higher ; Language ......: English ; Description ...: Lock a file to the current process only. Any attempts to interact with the file by another process will fail ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: The locked file handle must be closed with the Lock_Unlock() function after use ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <WinAPI.au3> ; #GLOBAL VARIABLES# ================================================================================================= ; None ; #CURRENT# ===================================================================================================================== ; Lock_Erase: Erase the contents of a locked file ; Lock_File: Lock a file to the current process only ; Lock_Read: Read data from a locked file ; Lock_Reduce: Reduce the locked file by a certain percentage ; Lock_Write: Write data to a locked file ; Lock_Unlock: Unlock a file so other processes can interact with it ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; None ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Erase ; Description ...: Erase the contents of a locked file ; Syntax ........: Lock_Erase($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; Return values .: Success - True ; Failure - False, use _WinAPI_GetLastError() to get additional details ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Erase($hFile) _WinAPI_SetFilePointer($hFile, $FILE_BEGIN) Return _WinAPI_SetEndOfFile($hFile) EndFunc ;==>Lock_Erase ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_File ; Description ...: Lock a file to the current process only ; Syntax ........: Lock_File($sFilePath[, $bCreateNotExist = False]) ; Parameters ....: $sFilePath - Filepath of the file to lock ; $bCreateNotExist - [optional] Create the file if it doesn't exist (True) or don't create (False). Default is False ; Return values .: Success - Handle of the locked file ; Failure - Zero and sets @error to non-zero. Call _WinAPI_GetLastError() to get extended error information ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_File($sFilePath, $bCreateNotExist = False) Return _WinAPI_CreateFile($sFilePath, BitOR($CREATE_ALWAYS, (IsBool($bCreateNotExist) And $bCreateNotExist ? $CREATE_NEW : 0)), BitOR($FILE_SHARE_WRITE, $FILE_SHARE_DELETE), 0, 0, 0) ; Creation = 2, Access = 2 + 4, Sharing = 0, Attributes = 0, Security = 0 EndFunc ;==>Lock_File ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Read ; Description ...: Read data from a locked file ; Syntax ........: Lock_Read($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $iBinaryFlag - [optional] Flag value to pass to BinaryToString(). Default is $SB_UTF8. See BinaryToString() documentation for more details ; Return values .: Success - Data read from the file ; Failure - Empty string and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Read($hFile, $iBinaryFlag = $SB_UTF8) Local $iFileSize = _WinAPI_GetFileSizeEx($hFile) + 1, _ $sText = '' Local $tBuffer = DllStructCreate('byte buffer[' & $iFileSize & ']') _WinAPI_SetFilePointer($hFile, $FILE_BEGIN) _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $iFileSize, $sText) Return SetError(@error, 0, BinaryToString(DllStructGetData($tBuffer, 'buffer'), $iBinaryFlag)) EndFunc ;==>Lock_Read ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Reduce ; Description ...: Reduce the locked file by a certain percentage ; Syntax ........: Lock_Reduce($hFile, $iPercentage) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $iPercentage - A percentage value to reduce the file by ; Return values .: Success - True ; Failure - False. Use _WinAPI_GetLastError() to get additional details ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Reduce($hFile, $iPercentage) If Not IsInt($iPercentage) Then $iPercentage = Int($iPercentage) If $iPercentage > 0 And $iPercentage < 100 Then Local $iFileSize = _WinAPI_GetFileSizeEx($hFile) * ($iPercentage / 100) _WinAPI_SetFilePointer($hFile, $iFileSize) Return _WinAPI_SetEndOfFile($hFile) EndIf Return Lock_Erase($hFile) EndFunc ;==>Lock_Reduce ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Write ; Description ...: Write data to a locked file ; Syntax ........: Lock_Write($hFile, $sText) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $sText - Data to be written to the locked file ; Return values .: Success - Number of bytes written to the file ; Failure - 0 and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Write($hFile, $sText) Local $iFileSize = _WinAPI_GetFileSizeEx($hFile), _ $iLength = StringLen($sText) Local $tBuffer = DllStructCreate('byte buffer[' & $iLength & ']') DllStructSetData($tBuffer, 'buffer', $sText) _WinAPI_SetFilePointer($hFile, $iFileSize) Local $iWritten = 0 _WinAPI_WriteFile($hFile, DllStructGetPtr($tBuffer), $iLength, $iWritten) Return SetError(@error, @extended, $iWritten) ; Number of bytes written EndFunc ;==>Lock_Write ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Unlock ; Description ...: Unlock a file so other applications can interact with it ; Syntax ........: Lock_Unlock($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Unlock($hFile) Return _WinAPI_CloseHandle($hFile) EndFunc ;==>Lock_Unlock Example 1: (with LockFile) #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> ; Include the LockFile.au3 UDF #include 'LockFile.au3' ; LockFile by guinness Example_1() Func Example_1() ; Path of the locked file Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; Lock the file to this process and create it if not already done so Local $hLock = Lock_File($sFilePath, True) ; Erase the contents of the locked file Lock_Erase($hLock) ; Write random data to the locked file For $i = 1 To 5 Lock_Write($hLock, RandomText(10) & @CRLF) Next ; Read the locked file Local $sRead = Lock_Read($hLock) ; Display the contents of the locked file that was just read MsgBox($MB_SYSTEMMODAL, '', $sRead) ; Display the current file size of the locked file. For example 60 bytes MsgBox($MB_SYSTEMMODAL, '', ByteSuffix(_WinAPI_GetFileSizeEx($hLock))) ; Reduce the file size by 50% Lock_Reduce($hLock, 50) ; Display the reduced size. This will be 50% less than before. For example 30 bytes MsgBox($MB_SYSTEMMODAL, '', ByteSuffix(_WinAPI_GetFileSizeEx($hLock))) ; Delete the locked file. As this is locked the deletion will fail MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 0, as the file is currently locked).') ; Unlock the locked file Lock_Unlock($hLock) ; Delete the file as it is now unlocked MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 1, as the file is unlocked).') EndFunc ;==>Example_1 ; Convert a boolean datatype to an integer representation Func BooleanToInteger($bValue) Return $bValue ? 1 : 0 EndFunc ;==>BooleanToInteger ; Append the largest byte suffix to a value Func ByteSuffix($iBytes, $iRound = 2) ; By Spiff59 Local Const $aArray = [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB'] Local $iIndex = 0 While $iBytes > 1023 And $iIndex < UBound($aArray) $iIndex += 1 $iBytes /= 1024 WEnd Return Round($iBytes, Int($iRound)) & $aArray[$iIndex] EndFunc ;==>ByteSuffix ; Generate random text Func RandomText($iLength) Local $iRandom = 0, _ $sData = '' For $i = 1 To $iLength $iRandom = Random(55, 116, 1) $sData &= Chr($iRandom + 6 * BooleanToInteger($iRandom > 90) - 7 * BooleanToInteger($iRandom < 65)) Next Return $sData EndFunc ;==>RandomText Example 2: (without LockFile) #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <WinAPIFiles.au3> ; Traditional approach to reading and writing to a file. Due to the nature of AutoIt, the file isn't locked, thus allowing other processes to interact with the file Example_2() Func Example_2() ; Path of the locked file Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; Lock the file to this process and create it if not already done so This is writing mode Local $hLock = FileOpen($sFilePath, $FO_OVERWRITE) ; Erase the contents of the locked file FileWrite($hLock, '') ; Write random data to the locked file For $i = 1 To 5 FileWrite($hLock, RandomText(10) & @CRLF) Next ; Close the file handle and create another handle to read the file contents FileClose($hLock) $hLock = FileOpen($sFilePath, $FO_READ) ; Read the locked file Local $sRead = FileRead($hLock) ; Display the contents of the locked file that was just read MsgBox($MB_SYSTEMMODAL, '', $sRead) ; Delete the locked file. As this is not locked by AutoIt the file will be deleted MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 1, as the file is''t locked by AutoIt due to safety measures in place).') ; Unlock the locked file (though not really locked) FileClose($hLock) EndFunc ;==>Example_2 ; Convert a boolean datatype to an integer representation Func BooleanToInteger($bValue) Return $bValue ? 1 : 0 EndFunc ;==>BooleanToInteger ; Generate random text Func RandomText($iLength) Local $iRandom = 0, _ $sData = '' For $i = 1 To $iLength $iRandom = Random(55, 116, 1) $sData &= Chr($iRandom + 6 * BooleanToInteger($iRandom > 90) - 7 * BooleanToInteger($iRandom < 65)) Next Return $sData EndFunc ;==>RandomText All of the above has been included in a ZIP file. Previous download: 866+ LockFile.zip
    1 point
  5. I have already published a lot of AutoIt UDF about algorithm, but all of them only support 32 bits or so called X86 system. Recently I got a computer with Windows 7 64 bits, so I finally added X64 support to most of my old projects. Besides, I also added some new. For example, some compression algorithm and SHA3 Candidates. Following are the algorithms list: Checksum CRC16 CRC32 ADLER32 Compression FastLZ LZF LZMA LZMAT MiniLZO QuickLZ Encode Base64 ARC4 XXTEA DES AES Hash Checksums (CRC16/CRC32/ADLER32) MD2 MD4 MD5 SHA1 SHA2 (SHA224/256/384/512) SHA3 Candidates BLAKE BMW (Blue Midnight Wish) CUBEHASH ECHO SHABAL SKEIN Some points to mention: All of the subroutines have one or more examples to demonstrate the usage. Since the function and usage of subroutine are easy to understand. A complete subroutines and parameters list are unavailability now. Sorry for my lazy. All of the subroutines here invoked by Lazycat's method (through CallWindowProc API). My MemoryDLL UDF is not necessary this time. Although MemoryFuncCall (part of MemoryDLL) is still good, but inevitably, it is slower than CallWindowProc. Some subroutines have the same name with my old machine code version UDF. But for some reason, I rearrange the position of the parameters. Please not mix up. If you notice, yes, checksums are duplicated. But they receive different parameters. One is the old style, and another use the same interface as other hashes. Choose what you like, but don't use them in the same time. Some algorithm already supported by the standard UDF "Encryption.au3". But I still provide them, because some system lack of the full support of Windows Crypt Library. If you are looking for only one hash algorithm, for example, used in encryption, I suggested "SHABAL_TINY.au3". Although it is a bit slower then SHABAL, but it is smaller, and it supports different size of output (from 32 to 512 bits).AutoIt Machine Code Algorithm Collection.zip
    1 point
  6. I tidied the code from a post made by KaFu. The code is fully working in both x32 & x64. I also used _CmdLineRaw() to parse $CmdLineRaw to an Array. Function: Version 11 (20/07/2014) #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Global Const $tagCOPYDATASTRUCT = 'ulong_ptr dwData;' & _ 'dword cbData;' & _ 'ptr lpData' Global $IPC_GUID = 'E23D443E-F0E1-11E3-9E5C-90580B9E45A7' Global Enum $IPC_AUTOITID, _ $IPC_CLIENTWND, $IPC_CLIENTID, _ $IPC_GLOBALID, _ $IPC_ID, $IPC_ISMONITORING, _ $IPC_MONITORID, _ $IPC_SERVERWND, $IPC_SERVERID, _ $IPC_MAX Global Enum $IPC_CONTROLID, _ $IPC_RECEIVEDDATA, $IPC_RECEIVEDWND, $IPC_RECEIVEDMSG, _ $IPC__MAX Global $IPC[$IPC__MAX] ; Internal array for the interprocess communication functions. $IPC[$IPC_CONTROLID] = 0 #Region Example ; Display only if compiled. If @Compiled Then Example() Else MsgBox($MB_SYSTEMMODAL, '', 'Please compile the example before running.') EndIf Func Example() Local $hIPC = _InterProcess('F23B0E88-ED9F-11E3-8179-82ADECBA0006', Default) ; Start the interprocess communication. _InterProcess_Monitor($hIPC) If _InterProcess_IsServerExists($hIPC) And Not _InterProcess_SendToServer($hIPC, 'This is a sample string') Then ; Send a sample string if there is a main process already running. MsgBox($MB_SYSTEMMODAL, 'Second Instance: ' & @AutoItPID, _ 'Seems there was an error sending the IPC message, but more than likely the string was blank.') EndIf Local $hWnd = 0, _ $iMsg = 0, _ $sMsg = '' Local Const $SERVER_CLOSE_PROCESS = 1001 While 1 Switch GUIGetMsg() Case _InterProcess_GetMonitorID($hIPC) ; The monitoring id used to notify when an IPC message is received. ; If the process is an server i.e. the first instance, then read the data sent by a client and ; respond that the IPC message was received If _InterProcess_IsThisServer($hIPC) Then If _InterProcess_GetData($hIPC, $hWnd, $sMsg, $iMsg) Then MsgBox($MB_SYSTEMMODAL, 'First Instance: ' & @AutoItPID, _ 'hWnd: ' & $hWnd & @CRLF & _ 'Data: ' & $sMsg & @CRLF & _ 'Message: ' & $iMsg & @CRLF) ; Parse the relevant handle and data from the message. If $iMsg = $SERVER_CLOSE_PROCESS Then ; Check the $iMsg parameter doesn't contain the message to close this instance. ExitLoop ; If the $iMsg parameter is equal to $IPC_CLOSE_PROCESS (1001) the close the first instance. Else _InterProcess_SendToClient($hIPC, $hWnd, 'The data was successfully received by the first instance (server). This second instance (client) will now close. Thanks.') EndIf EndIf ; If the process is not the first instance also known as a client, then wait for the server to send a reply that it ; successfully recived the IPC message. ElseIf _InterProcess_IsThisClient($hIPC) Then If _InterProcess_GetData($hIPC, $hWnd, $sMsg, $iMsg) Then MsgBox($MB_SYSTEMMODAL, 'Second Instance: ' & @AutoItPID, _ 'hWnd: ' & $hWnd & @CRLF & _ 'Data: ' & $sMsg & @CRLF & _ 'Message: ' & $iMsg & @CRLF) ; Parse the relevant handle and data from the message. _InterProcess_SendToServer($hIPC, 'The second instance (client) recieved the message to close their instance so this instance (server) will close too.', $SERVER_CLOSE_PROCESS) ExitLoop EndIf EndIf EndSwitch WEnd _InterProcess_Destroy($hIPC) EndFunc ;==>Example #EndRegion Example Func _InterProcess($sGUID, $hWnd) Local $aIPC[$IPC_MAX] $aIPC[$IPC_ID] = $IPC_GUID $aIPC[$IPC_AUTOITID] = AutoItWinGetTitle() $aIPC[$IPC_ISMONITORING] = False If StringRegExp($sGUID, '^(?:\{){0,1}[[:xdigit:]]{8}-(?:[[:xdigit:]]{4}-){3}[[:xdigit:]]{12}(?:\}){0,1}$') Then ; Is GUID. $aIPC[$IPC_GLOBALID] = StringUpper($sGUID) Else $aIPC[$IPC_GLOBALID] = 'IPC_' & $IPC_GUID EndIf $aIPC[$IPC_CLIENTWND] = $hWnd $aIPC[$IPC_CLIENTID] = $aIPC[$IPC_GLOBALID] & '_CLIENT' $aIPC[$IPC_SERVERWND] = 0 $aIPC[$IPC_SERVERID] = $aIPC[$IPC_GLOBALID] & '_SERVER' $hWnd = WinGetHandle($aIPC[$IPC_SERVERID]) If @error Or Not $hWnd Then ; No interprocess communication server exists. $aIPC[$IPC_SERVERWND] = 0 Else Local Const $hControl = ControlGetHandle($hWnd, '', 'Edit1') $aIPC[$IPC_SERVERWND] = HWnd( _ StringRegExp('|' & ControlGetText($hWnd, '', $hControl) & '|IPC_WND:0x00000000|', _ '\|IPC_WND:(0[xX][[:xdigit:]]+)\|', _ $STR_REGEXPARRAYGLOBALMATCH)[0] _ ) ; Retrieve the server communication handle. EndIf Return $aIPC EndFunc ;==>_InterProcess Func _InterProcess_Destroy(ByRef $aIPC) Local $bReturn = False If __InterProcess_IsAPI($aIPC) Then $bReturn = True Local $hAutoItWnd = 0 If _InterProcess_IsThisServer($aIPC) Then $hAutoItWnd = WinGetHandle($aIPC[$IPC_SERVERID]) ElseIf _InterProcess_IsThisClient($aIPC) And _InterProcess_IsClientExists($aIPC) Then $hAutoItWnd = WinGetHandle($aIPC[$IPC_CLIENTID]) EndIf If IsHWnd($hAutoItWnd) Then Local Const $hControl = ControlGetHandle($hAutoItWnd, '', 'Edit1') ControlSetText($hAutoItWnd, '', $hControl, _ StringRegExpReplace(ControlGetText($hAutoItWnd, '', $hControl), _ '(?<=\n)\|IPC_(?:WND|PID):\V+\R', _ '')) ; Destroy the communication handle and PID. ; Destroy the associated GUI. GUIRegisterMsg($WM_COPYDATA, '') If $aIPC[$IPC_MONITORID] > 0 Then GUICtrlDelete($aIPC[$IPC_MONITORID]) EndIf If IsHWnd($aIPC[$IPC_CLIENTWND]) Then GUIDelete($aIPC[$IPC_CLIENTWND]) EndIf EndIf _InterProcess_Destroy_Monitor($aIPC) AutoItWinSetTitle($aIPC[$IPC_AUTOITID]) EndIf $aIPC = Null ; Destroy the contents of the API. Return $bReturn EndFunc ;==>_InterProcess_Destroy Func _InterProcess_Destroy_Monitor(ByRef $aIPC) Local $bReturn = False If __InterProcess_IsAPI($aIPC) And $aIPC[$IPC_ISMONITORING] Then $IPC[$IPC_CONTROLID] = 0 $aIPC[$IPC_ISMONITORING] = False $bReturn = True EndIf Return $bReturn EndFunc ;==>_InterProcess_Destroy_Monitor Func _InterProcess_GetClientID(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) ? $aIPC[$IPC_CLIENTID] : Null EndFunc ;==>_InterProcess_GetClientID Func _InterProcess_GetGlobalID(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) ? $aIPC[$IPC_GLOBALID] : Null EndFunc ;==>_InterProcess_GetGlobalID Func _InterProcess_GetMonitorID(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) ? $aIPC[$IPC_MONITORID] : 0 EndFunc ;==>_InterProcess_GetMonitorID Func _InterProcess_GetServerID(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) ? $aIPC[$IPC_SERVERID] : Null EndFunc ;==>_InterProcess_GetServerID Func _InterProcess_GetData(ByRef $aIPC, ByRef $hWnd, ByRef $sMsg, ByRef $iMsg) $hWnd = 0 $iMsg = 0 $sMsg = '' Local $bReturn = False If __InterProcess_IsAPI($aIPC) And ($IPC[$IPC_RECEIVEDDATA] Or $IPC[$IPC_RECEIVEDMSG]) Then $bReturn = True $hWnd = (IsHWnd($IPC[$IPC_RECEIVEDWND]) ? $IPC[$IPC_RECEIVEDWND] : Null) ; hWnd. $iMsg = Int($IPC[$IPC_RECEIVEDMSG]) $sMsg = $IPC[$IPC_RECEIVEDDATA] ; Data EndIf $IPC[$IPC_RECEIVEDDATA] = '' $IPC[$IPC_RECEIVEDWND] = 0 $IPC[$IPC_RECEIVEDMSG] = 0 Return $bReturn EndFunc ;==>_InterProcess_GetData Func _InterProcess_GetClientWnd(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) ? $aIPC[$IPC_CLIENTWND] : Null EndFunc ;==>_InterProcess_GetClientWnd Func _InterProcess_GetServerWnd(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) ? (_InterProcess_IsThisServer($aIPC) ? $aIPC[$IPC_CLIENTWND] : $aIPC[$IPC_SERVERWND]) : Null EndFunc ;==>_InterProcess_GetServerWnd Func _InterProcess_IsClientExists(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) And IsHWnd($aIPC[$IPC_CLIENTWND]) And $aIPC[$IPC_MONITORID] > 0 EndFunc ;==>_InterProcess_IsClientExists Func _InterProcess_IsMonitoring(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) And $aIPC[$IPC_ISMONITORING] EndFunc ;==>_InterProcess_IsMonitoring Func _InterProcess_IsServerExists(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) And IsHWnd($aIPC[$IPC_SERVERWND]) EndFunc ;==>_InterProcess_IsServerExists Func _InterProcess_IsThisServer(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) And Not IsHWnd($aIPC[$IPC_SERVERWND]) EndFunc ;==>_InterProcess_IsThisServer Func _InterProcess_IsThisClient(ByRef $aIPC) Return __InterProcess_IsAPI($aIPC) And Not _InterProcess_IsThisServer($aIPC) EndFunc ;==>_InterProcess_IsThisClient Func _InterProcess_Monitor(ByRef $aIPC) Local $bReturn = False If __InterProcess_IsAPI($aIPC) And Not $aIPC[$IPC_ISMONITORING] Then $aIPC[$IPC_ISMONITORING] = True If _InterProcess_IsThisServer($aIPC) And Not _InterProcess_IsClientExists($aIPC) Then __InterProcess_Create($aIPC[$IPC_CLIENTWND], $aIPC[$IPC_MONITORID], $aIPC[$IPC_SERVERID]) ElseIf _InterProcess_IsThisClient($aIPC) And Not _InterProcess_IsClientExists($aIPC) Then __InterProcess_Create($aIPC[$IPC_CLIENTWND], $aIPC[$IPC_MONITORID], $aIPC[$IPC_CLIENTID]) EndIf $IPC[$IPC_CONTROLID] = $aIPC[$IPC_MONITORID] $bReturn = True EndIf Return $bReturn EndFunc ;==>_InterProcess_Monitor Func _InterProcess_SendToServer(ByRef $aIPC, $sMsg, $iMsg = Default) Return __InterProcess_IsAPI($aIPC) And __InterProcess_Send($aIPC[$IPC_CLIENTWND], $aIPC[$IPC_SERVERWND], $iMsg, $sMsg) EndFunc ;==>_InterProcess_SendToServer Func _InterProcess_SendToClient(ByRef $aIPC, $hWnd, $sMsg, $iMsg = Default) Return __InterProcess_IsAPI($aIPC) And __InterProcess_Send($aIPC[$IPC_CLIENTWND], $hWnd, $iMsg, $sMsg) EndFunc ;==>_InterProcess_SendToClient Func _InterProcess_SetGUID($sGUID) $IPC_GUID = $sGUID Return True EndFunc ;==>_InterProcess_SetGUID Func __InterProcess_Create(ByRef $hWnd, ByRef $iControl, $sID) If Not IsHWnd($hWnd) Or $hWnd = Default Then $hWnd = GUICreate('', 0, 0, -99, -99, $GUI_SS_DEFAULT_GUI, $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOWNOACTIVATE, $hWnd) EndIf If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hWnd, $WM_COPYDATA, $MSGFLT_ALLOW) EndIf If Not $iControl Then $iControl = GUICtrlCreateDummy() EndIf GUIRegisterMsg($WM_COPYDATA, WM_COPYDATA) AutoItWinSetTitle($sID) Local Const $hAutoItWnd = WinGetHandle($sID) Local Const $hControl = ControlGetHandle($hAutoItWnd, '', 'Edit1') ControlSetText($hAutoItWnd, '', $hControl, ControlGetText($hAutoItWnd, '', $hControl) & @CRLF & _ '|IPC_WND:' & $hWnd & '|IPC_PID:' & @AutoItPID & @CRLF) ; Set the communication handle and PID. Return True EndFunc ;==>__InterProcess_Create Func __InterProcess_IsAPI(ByRef $aIPC) Return UBound($aIPC) = $IPC_MAX And $aIPC[$IPC_ID] = $IPC_GUID EndFunc ;==>__InterProcess_IsAPI Func __InterProcess_Send($hSender, $hReciever, $iMsg, $sMsg) If Not IsHWnd($hReciever) Then Return SetError(1, 0, False) EndIf If StringStripWS($sMsg, $STR_STRIPALL) = '' Then Return SetError(2, 0, False) EndIf If Not IsInt($iMsg) Then $iMsg = 0 EndIf $sMsg = $IPC_GUID & $sMsg Local Const $tBuffer = DllStructCreate('wchar cdata[' & StringLen($sMsg) + 1 & ']') DllStructSetData($tBuffer, 'cdata', $sMsg) Local Const $tCOPYDATASTRUCT = DllStructCreate($tagCOPYDATASTRUCT) DllStructSetData($tCOPYDATASTRUCT, 'dwData', $iMsg) DllStructSetData($tCOPYDATASTRUCT, 'cbData', DllStructGetSize($tBuffer)) DllStructSetData($tCOPYDATASTRUCT, 'lpData', DllStructGetPtr($tBuffer)) _SendMessage($hReciever, _ $WM_COPYDATA, _ $hSender, _ DllStructGetPtr($tCOPYDATASTRUCT)) Return Not @error EndFunc ;==>__InterProcess_Send Func WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local Const $tCOPYDATASTRUCT = DllStructCreate($tagCOPYDATASTRUCT, $lParam) Local Const $tBuffer = DllStructCreate('wchar cdata[' & DllStructGetData($tCOPYDATASTRUCT, 'cbData') / 2 & ']', DllStructGetData($tCOPYDATASTRUCT, 'lpData')) $IPC[$IPC_RECEIVEDDATA] = StringRegExpReplace(DllStructGetData($tBuffer, 'cdata'), '^' & $IPC_GUID, '') ; Data. If @extended > 0 Then $IPC[$IPC_RECEIVEDWND] = $wParam ; hWnd. $IPC[$IPC_RECEIVEDMSG] = DllStructGetData($tCOPYDATASTRUCT, 'dwData') ; Message. If $IPC[$IPC_CONTROLID] > 0 Then GUICtrlSendToDummy($IPC[$IPC_CONTROLID]) ; Send to the control. EndIf Else $IPC[$IPC_RECEIVEDDATA] = '' EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COPYDATA
    1 point
  7. qwert

    Simplest Gradient

    This was a bit of a puzzle for me, but with Yashied’s help, I figured it out. I’d been investigating the use of _WinAPI_GradientFill, but found the first couple of rungs of the ladder missing. By that, I mean that the explanations and examples I found were unclear about how to do the simplest gradient of all. It didn’t help that terms like “vertex” and “logical units” were involved. Anyone who had already worked with color fills obviously knew what they meant. I didn’t. So, here’s a modification of one of the very first examples from 2009. It produces a simple 200x600 linear gradient (from one color to another color), as well as the original 400x400 blended gradient (of multiple colors). Note the subtle differences in the DC processing, related to the use of _WinAPI_GetDC(), I believe. (BTW, if anyone sees a way for further simplification, please submit a working replacement example.) Also, I went ahead and made the original gradient frameless and draggable, but only as a way of showing some variety. #Include <GUIConstantsEx.au3> #include <GuiConstants.au3> #Include <WinAPIEx.au3> Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 ;======== ; basic 2-color gradient ================ Dim $aVertex[2][3] = [[0, 0, 0x00FFAA], [200, 600, 0x00AA44]] ; blue/green to different blue/green $hDC = _WinAPI_CreateCompatibleDC(0) ; create the bitmap $hBitmap = _WinAPI_CreateBitmap(200, 600, 1, 32) $hSv = _WinAPI_SelectObject($hDC, $hBitmap) _WinAPI_GradientFill($hDC, $aVertex, 0, 1) ; actual fill _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) $hForm = GUICreate('MyGUI', 200, 600, 300, 100) ; create a GUI for the bitmap GUICtrlCreatePic('', 0, 0, 200, 600) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSendMsg(-1, $STM_SETIMAGE, 0, $hBitmap) GUISetState() ;======== somewhat more complex gradient + draggable =========== Dim $aVertex[6][3] = [[0, 0, 0xFF0000],[400, 400, 0x00FF00],[0, 400, 0x0000FF],[0, 0, 0xFF0000],[400, 0, 0xFFFF00],[400, 400, 0x00FF00]] $hColors = GUICreate('Color Wheel', 400, 400, 600, 200, $WS_POPUP) ; Create square GUI $idPic = GUICtrlCreatePic('', 0, 0, 400, 400, -1, $GUI_WS_EX_PARENTDRAG) $hPic = GUICtrlGetHandle($idPic) $hDC = _WinAPI_GetDC($hPic) ; Create 6-point gradient $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 400, 400) $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap) _WinAPI_GradientFill($hDestDC, $aVertex, 0, 2) _WinAPI_GradientFill($hDestDC, $aVertex, 3, 5) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_DeleteDC($hDestDC) _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) ; Set gradient to control Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) GUISetState() GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $hColors) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc
    1 point
  8. I like GuiBuilderNxt. That's nice. I think maybe Prototype 1.0? If you do the chronological thing then when you get to this latest version, I think I might like to add a little info about how the code works to ease future updates. I think another update will follow shortly. I decided to go back to working on this. I get a little discouraged sometimes. =O Edit: Seems I still can't edit my first post. Just pretend that the name of this thread is now GuiBuilderNxt!
    1 point
  9. I have one too. Look at WM_COPYDATS in my signature.
    1 point
  10. gil900, Good luck with debugging that code in the future! M23
    1 point
  11. Func _htmlraw_TableToArray($sTable) If Not StringLen($sTable) Then Return SetError(1, 0, 0) EndIf Local $aRows = _htmlraw_GetTableRows($sTable) If Not IsArray($aRows) Then Return SetError(2, 0, 0) EndIf Local $iUBRow = UBound($aRows) Local $aRet[$iUBRow][1] Local $aCols, $iEnum = 0, $iUBCol Local $aRowSpan Local Const $sRowSpanPatt = "(?is)<\s*(?:td|th)\h+rowspan=" & _ "(?:\x22|\x27)(\d+)(?:\x22|\x27)\s*>" Local Const $sRemoveTagPatt = "^(?is)\h*<(?:th|td).*?(?<!>)>" & _ "\s*|(?:\s*<\h*/\h*(?:th|td)\h*>\h*)$" Local $iRowCount = -1, $aTmp For $i = 0 To $iUBRow - 1 $aCols = _htmlraw_GetTableCols($aRows[$i]) $iUBCol = UBound($aCols) If Not $iUBCol Then ContinueLoop ; take care of rowspan If $iRowCount > -1 Then Dim $aTmp[$iUBCol + 1] For $j = 0 To $iUBCol - 1 $aTmp[$j + 1] = $aCols[$j] Next $aCols = $aTmp $iUBCol = UBound($aCols) $iRowCount -= 1 EndIf If $iUBCol > UBound($aRet, 2) Then ReDim $aRet[$iUBRow][$iUBCol] EndIf For $j = 0 To $iUBCol - 1 If $iRowCount = -1 Then $aRowSpan = StringRegExp($aRows[$i], $sRowSpanPatt, 1) $iRowCount = ((Not @error) ? $aRowSpan[0] - 2 : -1) EndIf $aRet[$iEnum][$j] = StringRegExpReplace($aCols[$j], $sRemoveTagPatt, "") Next $iEnum += 1 Next Return $aRet EndFunc ;==>_htmlraw_TableToArray
    1 point
  12. ImOracle, I have used seangriffin's FileSystemMonitor UDF very successfully to detect new files being created. Give it a go and come back if you run into problems. M23
    1 point
  13. Someone familiar with another language such as C++ would never declare a variable without also assigning a value to it. In C++ when you declare a variable without assigning a value, that variable can hold the contents of the memory that variable is assigned to, and you'd have no way of knowing what's in that memory location when you do this, so your variable could hold absolutely any value. This link might help with understanding what I am talking about. So a person that comes into AutoIt from that other language, or is learning that other language and wants to use that new knowledge in AutoIt, would want to assign something to the variables when they're declared just to be sure they know what's in it.
    1 point
  14. Look in my signature for DPI Awareness
    1 point
  15. I know this is an old thread, but I reworked the code to place everything in a func which changed globals to locals, and it returns the date/time in an array. so that way you can do 1 global variable array if one so desired. The missing backslashes are there. ;usage Global $currentdatetimearr = SetSysTime() ;or you could just do SetSysTime() without the global variable. func SetsysTime() ; For the ActiveTimeBias registry key: ; 4294967296 = 0 for UTC +X:YZ Time zones ; subtract value of key to get Time zone offset. ; EG: 4294976296-4294976236 = 60 = UTC +1:00; ; UTC Time zone uses 0 for the value; ; UTC -A:BC Time zones use the number of minutes of the offset ; EG: 480 = UTC -8:00; To-Do: ; 1. Add a timezone check to make sure the system is properly configured for its area ; EG: Time Zone is currently "Pacific Standard Time", is this correct? [Y/N] ; 2. Add error checking to _EndOfMonth() should the need arise [user editing of code] ; EG: -2 is not a valid month, you silly goose! ; ---------------------------------------------------------------------------------------------------------------------------------- ; Get Time from HTTP server (Defaults to google.com ... pool.ntp.org is a good alternative) ; ---------------------------------------------------------------------------------------------------------------------------------- $site = "www.google.com" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://" & $site & "/", False) $oHTTP.Send() $date = $oHTTP.GetResponseHeader("Date") ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set Global variables used throughout the script ; ---------------------------------------------------------------------------------------------------------------------------------- ; $tzo: timezoneOffset (the number of hours by which the local machine varies from UTC) Local $tzo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation", "ActiveTimeBias"), _ $y = StringMid($date, 13, 4), _ ; The current year $m = StringMid($date, 9, 3), _ ; The current month $d = StringMid($date, 6, 2), _ ; The current day of month $h = StringMid($date, 18, 2), _ ; The current hour $n = StringMid($date, 21, 2), _ ; The current minute $s = StringMid($date, 24, 2) ; The current second If $tzo < 1500 Then $tzo /= -60 Else $tzo = (4294967296 - $tzo) / 60 EndIf ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Calculate Time zone changes (correct the hour/day/month/year based on timezone/hour/day/month changes ; ---------------------------------------------------------------------------------------------------------------------------------- $h += $tzo ; Set the local hour based on offset from UTC Select ; If the hour changes day forward/backward, correct appropriate values. Case $h >= 24 $d += 1 $h -= 24 Case $h < 0 $d -= 1 $h += 24 EndSelect Switch $m Case 'JAN'; 31 days in month $m = 1 Case 'FEB'; 28/29 days in month $m = 2 Case 'MAR' ; 31 days in month $m = 3 Case 'APR'; 30 days in month $m = 4 Case 'MAY'; 31 days in month $m = 5 Case 'JUN' ; 30 days in month $m = 6 Case 'JUL' ; 31 days in month $m = 7 Case 'AUG' ; 31 days in month $m = 8 Case 'SEP' ; 30 days in month $m = 9 Case 'OCT' ; 31 days in month $m = 10 Case 'NOV' ; 30 days in month $m = 11 Case 'DEC' ; 31 days in month $m = 12 EndSwitch Local $epm = _EndOfMonth($m - 1), _ ; The last day of the previous month (28-31) $ecm = _EndOfMonth($m) ; The last day of the current month (28-31); Correct value for $tzo from the registry value to a +/- number of hours Switch $d ; If the day changes month forward/backward, correct appropriate values. Case $ecm + 1 $m += 1 $d = 1 Case 0 $m -= 1 $d = $epm EndSwitch Switch $m ; If the month changes year forward/backward, correct appropriate values. Case 0 $m = 12 $d = 31 $y -= 1 Case 13 $m = 1 $d = 1 $y += 1 EndSwitch ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set system date/time using functions from #include ; ---------------------------------------------------------------------------------------------------------------------------------- _SetDate($d, $m, $y) _SetTime($h, $n, $s) local $sysdatetime[6] $sysdatetime[0] = $m $sysdatetime[1] = $d $sysdatetime[2] = $y $sysdatetime[3] = $h $sysdatetime[4] = $n $sysdatetime[5] = $s Return $sysdatetime ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; FUNCTION: _EndOfMonth ::: Determine the ending date of the month (28, 29, 30, or 31) ; ---------------------------------------------------------------------------------------------------------------------------------- EndFunc Func _EndOfMonth($vMON) Local $end Switch $vMON Case 0, 1, 3, 5, 7, 8, 10, 12, 13 $end = 31 Case 4, 6, 9, 11 $end = 30 Case 2 If IsInt(@YEAR / 4) Then $end = 29 Else $end = 28 EndIf Case Else SetError(-1) Return (0) EndSwitch Return ($end) EndFunc ;==>_EndOfMonth
    1 point
  16. Search inter process communication IPC There are many ways to communicate. If you want the script to remain exactly as it is now, and trigger a function externally, you're out of luck.
    1 point
  17. Yashied

    Skin UDF

    All you need is a _Skin_AddButtonEx() function. Here's an example: #Region Resources #AutoIt3Wrapper_Res_File_Add=background.bmp, 2, 200 #AutoIt3Wrapper_Res_File_Add=red_normal.png, PNG, RED_NORMAL #AutoIt3Wrapper_Res_File_Add=red_hover.png, PNG, RED_HOVER #AutoIt3Wrapper_Res_File_Add=red_click.png, PNG, RED_CLICK #AutoIt3Wrapper_Res_File_Add=yellow_normal.png, PNG, YELLOW_NORMAL #AutoIt3Wrapper_Res_File_Add=yellow_hover.png, PNG, YELLOW_HOVER #AutoIt3Wrapper_Res_File_Add=yellow_click.png, PNG, YELLOW_CLICK #AutoIt3Wrapper_Res_File_Add=green_normal.png, PNG, GREEN_NORMAL #AutoIt3Wrapper_Res_File_Add=green_hover.png, PNG, GREEN_HOVER #AutoIt3Wrapper_Res_File_Add=green_click.png, PNG, GREEN_CLICK #AutoIt3Wrapper_Res_File_Add=alpha.png, PNG, ALPHA #EndRegion Resources #Include <GDIPlus.au3> #Include <GUIConstantsEx.au3> #Include <Memory.au3> #Include <Skin.au3> #Include <WinAPIEx.au3> Global $hInstance = _WinAPI_GetModuleHandle('') Global $hBitmap[10] = ['RED_NORMAL', 'RED_HOVER', 'RED_CLICK', 'YELLOW_NORMAL', 'YELLOW_HOVER', 'YELLOW_CLICK', 'GREEN_NORMAL', 'GREEN_HOVER', 'GREEN_CLICK', 'ALPHA'] Global $Button[3] _GDIPlus_Startup() For $i = 0 To 9 $hBitmap[$i] = _LoadResourceImage($hInstance, 'PNG', $hBitmap[$i]) Next _GDIPlus_Shutdown() $hForm = GUICreate('MyGUI', 278, 106) GUICtrlCreatePic('', 0, 0, 278, 106) GUICtrlSendMsg(-1, 0x0172, 0, _WinAPI_LoadBitmap($hInstance, 200)) GUICtrlSetState(-1, $GUI_DISABLE) $Button[0] = _Skin_AddButtonEx(20 , 20, 66, 66, $hBitmap[0], $hBitmap[1], $hBitmap[2], 0, $hBitmap[9], 1) $Button[1] = _Skin_AddButtonEx(106, 20, 66, 66, $hBitmap[3], $hBitmap[4], $hBitmap[5], 0, $hBitmap[9], 1) $Button[2] = _Skin_AddButtonEx(192, 20, 66, 66, $hBitmap[6], $hBitmap[7], $hBitmap[8], 0, $hBitmap[9], 1) _Skin_EnableKBInput(1) For $i = 0 To 2 _Skin_SetFocusRect($Button[$i], 5, 5, 56, 56) Next _Skin_EnableFocus(1) GUISetState() While 1 _Skin_Helper($hForm) $ID = GUIGetMsg() Switch $ID Case 0 ContinueLoop Case $GUI_EVENT_CLOSE ExitLoop Case $Button[0] ConsoleWrite('Red' & @CR) Case $Button[1] ConsoleWrite('Yellow' & @CR) Case $Button[2] ConsoleWrite('Green' & @CR) Case Else EndSwitch WEnd Func _LoadResourceImage($hInstance, $sType, $sName, $iLanguage = 0) Local $hInfo, $hData, $pData, $iSize, $hMem, $pMem, $pStream, $hBitmap If Not $hInstance Then $hInstance = _WinAPI_GetModuleHandle('') EndIf If $iLanguage Then $hInfo = _WinAPI_FindResourceEx($hInstance, $sType, $sName, $iLanguage) Else $hInfo = _WinAPI_FindResource($hInstance, $sType, $sName) EndIf $hData = _WinAPI_LoadResource($hInstance, $hInfo) $iSize = _WinAPI_SizeOfResource($hInstance, $hInfo) $pData = _WinAPI_LockResource($hData) If @Error Then Return SetError(1, 0, 0) EndIf $hMem = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE) $pMem = _MemGlobalLock($hMem) _WinAPI_MoveMemory($pMem, $pData, $iSize) _MemGlobalUnlock($hMem) $pStream = _WinAPI_CreateStreamOnHGlobal($hMem) _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromStream($pStream) _GDIPlus_Shutdown() _WinAPI_ReleaseStream($pStream) If Not $hBitmap Then Return SetError(2, 0, 0) EndIf Return $hBitmap EndFunc ;==>_LoadResourceImage #cs Func _GDIPlus_BitmapCreateFromStream($pStream) Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromStream', 'ptr', $pStream, 'handle*', 0) If (@Error) Or ($Ret[0]) Then Return SetError(1, 0, 0) EndIf Return $Ret[2] EndFunc ;==>_GDIPlus_BitmapCreateFromStream #ce
    1 point
  18. Hi, wraithdu. This is my machine code version. C Source from Martin Pool. #Include-once #Include <Memory.au3> Global $_NaturalCompare_CodeBufferPtr, $_NaturalCompare_CodeBuffer Func NaturalCompare_Shutdown() _MemVirtualFree($_NaturalCompare_CodeBufferPtr, 0, $MEM_RELEASE) $_NaturalCompare_CodeBufferPtr = 0 EndFunc Func NaturalCompare_Startup() If Not $_NaturalCompare_CodeBuffer Then Local $Code If @AutoItX64 Then $Code = Binary("0x41574531D24531C9415641554154555756534883EC184963C14989D3668B2C414963C2668B1C42418D41014898488D0441400FB6FD4188EC83FF207F198D77F783FE04760583FF20750C668B2841FFC14883C002EBDB418D42014C89DA66892C244898498D04430FB6F34188DB83FE207F1B448D6EF74183FD04760583FE20750C668B1841FFC24883C002EBDA450FB6E44183EC304183FC090F8709010000450FB6DB4183EB304183FB090F87F70000006683FB3074066683FD3075634963C24C8D24424963C14C8D1C4166458B2B410FB6C583E83083F80966418B042476140FB6C083E83083F8090F860A010000E9B4000000440FB6F04183EE304183FE090F87F8000000664139C50F82E90000000F87E80000004983C3024983C402EBAB4963C24C8D2C424963C14C8D244131C066458B3424450FB6DE4183EB304183FB0966458B5D007614450FB6DB4183EB304183FB090F869F000000EB48450FB6FB4183EF304183FF090F8790000000664539DE730A85C041BBFFFFFFFFEB0A760E85C041BB01000000410F44C3EB0C664585F67506664585DB740A4983C4024983C502EB8C85C075406685DB75056685ED74344585C0751C8D5F9F8D47E083FB198D5EE00F46F88D469F66893C2483F8190F47DE66391C247220772341FFC141FFC2E930FEFFFF31C04883C4185B5E5F5D415C415D415E415FC383C8FFEBEAB801000000EBE3") Else $Code = Binary("0x5531C989E531D257565383EC1C8B5D0C8B4508668B1C4B668B045066895DEA8B5D08668945E28D4453028A5DE20FB6F383FE20885DF07F1A8D5EF783FB04760583FE20750D668B184283C00266895DE2EBD8668B45E28B5D0C8955E4668945DE8D444B020FB67DEA89FA0FB6DA83FB207F1A8D53F783FA04760583FB20750D668B184183C00266895DEAEBD80FB645F08B55E483E83083F8090F872301000081E7FF00000083EF3083FF090F871101000066837DEA30740766837DE230756D8B450C8D3C488B45088D04508945F08B45F0668B00668945E40FB645E483E83083F809668B07668945EC76150FB645EC83E83083F8090F8618010000E9C20000000FB645EC83E83083F8090F87080100008B45EC663945E40F82F60000000F87F50000008345F00283C702EBA28B450C8955D88D04488945EC8B45088D04508945E431C08B55E4668B120FB6FA668955E08B55EC83EF3083FF09668B12668955F076150FB67DF08B55D883EF3083FF090F869E000000EB470FB67DF083EF3083FF090F87910000008B55F0663955E0730985C0751D83C8FFEB18760885C07512B001EB0E66837DE000750766837DF000740A8345E4028345EC02EB888B55D885C0754766837DEA00750766837DE2007437837D1000751E8D469F83F819770383EE208D439F83F819668975DE770383EB2066895DEA668B5DEA66395DDE721577184241E906FEFFFF31C083C41C5B5E5F5DC2100083C8FFEBF1B801000000EBEA") EndIf Local $CodeLen = BinaryLen($Code) $_NaturalCompare_CodeBufferPtr = _MemVirtualAlloc(0, $CodeLen, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) $_NaturalCompare_CodeBuffer = DllStructCreate("byte[" & $CodeLen & "]", $_NaturalCompare_CodeBufferPtr) DllStructSetData($_NaturalCompare_CodeBuffer, 1, $Code) OnAutoItExitRegister("NaturalCompare_Shutdown") EndIf EndFunc Func NaturalCompareFast($String1, $String2, $Case = 0) If Not $_NaturalCompare_CodeBufferPtr Then NaturalCompare_Startup() Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $_NaturalCompare_CodeBufferPtr, _ "wstr", $String1, _ "wstr", $String2, _ "int", $Case, _ "int", 0) Return $Ret[0] EndFunc Speed test: ConsoleWrite("_NaturalCompare:" & @CRLF) $Timer = TimerInit() For $i = 1 To 10000 _NaturalCompare("abC10", "abc2") _NaturalCompare("abC10", "abc2", 1) Next ConsoleWrite(TimerDiff($Timer) & @CRLF) ConsoleWrite("NaturalCompareFast:" & @CRLF) $Timer = TimerInit() For $i = 1 To 10000 NaturalCompareFast("abC10", "abc2") NaturalCompareFast("abC10", "abc2", 1) Next ConsoleWrite(TimerDiff($Timer) & @CRLF) Result on my computre: _NaturalCompare: 1288.4765591166 NaturalCompareFast: 472.212972604665 I hope this may help you.
    1 point
×
×
  • Create New...