Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/19/2013 in all areas

  1. You are mixing two purposes of Obfuscator -> 1. Stripping unused Funcs and Global Variables 2. Obfuscating Funcs and Variables This is more or less how it works: Step 1: Obfuscator will read all source code including all #Include files and determine what FUNCs exists build a table with all FUNC names. Step 2: Read the source again and start the lexing process finding the used of each of these FUNCs. it will keep track of which part of the script makes the Call to the UDF being either the Main (Body) of the script or name of the FUNC. Step 3: Check for each FUNC in the total source whether or not it was used by reading the table and see which FUNC Called it. The clever part is that it determines through a number of Iterations whether a FUNC is used by an Initial call from the MAIN script or not to determine if it can be removed. Step 4: The Obfuscation process is done which will rename the Found FUNCs and its references to a preset newname also stored in the FUNC table. Steps 1-3 are done when any of the /Strip options is selected. Step 4 is the default process or when any of the /Convert options is used. Hope this explains it a little but feel free to ask if not. Jos
    2 points
  2. Zedna asked me to post this Script in Example-Forum. This Script uses some GDI(Plus)-functions to set image directly to Control., so you can provide them in Script code, when no Transparency is required. Update: This code is outdated and has memory leaks. Please go to for updated functions. #include <GUIConstants.au3> #include "BinaryImage.au3" #region - GUI Create GUICreate('Image from Stream smile.gif',200,80,-1,-1,$WS_CAPTION+$WS_SYSMENU) ;#~ Start image Creation $picbox = GUICtrlCreatePic("", 10,10,64,63) GUICtrlSetCursor(-1,0) $LOGO = _LOGOBin() _SetImageBinaryToCtrl($picbox,$LOGO) ;#~ end image Creation GUICtrlCreateLabel("www.progandy.de.tt",80,20) $zedna = GUICtrlCreateLabel("Zedna on autoitscript.com",80,40) GUICtrlSetCursor(-1,0) GUISetState() #endregion #region - GUI SelectLoop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $picbox ShellExecute("www.progandy.de.tt") Case $msg = $zedna ShellExecute("http://www.autoitscript.com/forum/index.php?showuser=6483") EndSelect WEnd #endregion Func _LOGOBin() Local $FileName = "0xFFD8FFE000104A46494600010101006000600000FFE1001645786966000049492A0008000000000000000000FFDB004300080606070605080707070909080A" $FileName &= "0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C30313434341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D" $FileName &= "1832211C213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232FFC0001108003F0040" $FileName &= "03012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D" $FileName &= "01020300041105122131410613516107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A43444546474849" $FileName &= "4A535455565758595A636465666768696A737475767778797A838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5" $FileName &= "C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F0100030101010101010101010000000000000102030405060708" $FileName &= "090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0156272D10A162434" $FileName &= "E125F11718191A262728292A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A9293949596" $FileName &= "9798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C0301" $FileName &= "0002110311003F00F78DDC64D729ABF8BFEC17DF678EDE699B04E2242C703D80F7AE9657DB1393D00AE37C29FE97E30D62F32D886148978E097624FE5B17F3AF" $FileName &= "0B30E7AF8B8616326935776FC0EFC2538724EACD5D4509FF0009CCFF00F40CBFFF00C077FF000A07C418609116EE196DF79C2F9CA5371F6CF5AED26B88EDE332" $FileName &= "CD2A471AFDE791B007E2698925BDEDBEE4314F04808C821D5877E7A1A1E4CD7C35A57F52BEB343AD1D3D59574CD6ADB5240617539E7835A7BABCF759D363F0CE" $FileName &= "B3697DA78F2ED2EA429242B9DA8FD723B007D3B62B7B53F14DB68ED6AB7322A89D495C9C1E3AFF003ACE19855C1D4950C4FBD6D9ADC2AE0D4F96543552FBCE93" $FileName &= "26973EF58963E23B1BE00472A96EBD6B5C3E4023A1AF530B8FA189FE1BD7B1C5528CE93E59AB14AFE51158CAE4FF0009EB5CE780A33FD9B7D78C4E6E6E98807D" $FileName &= "1405AD0F13DC791A248DBB048A3C2D07D93C316119565668C48CA7A82DC915C186FDEE67567FCA923B57B9817FDE7F912F8934B9F5AD20D9413C7096914B1917" $FileName &= "20A8392314BE1ED1D740D256C84C653E63485F18E49CE00EC2A8EBBE25974AD4A0B1B6B2FB54D2446565DFB768CE07F5FCAB34F897C4374A63B7D262818E30F2" $FileName &= "316C7AF15D75B1B84A355BA92B4874B0D89A941434507AEE897C6D73E7DC69BA544D995A6F39D476400807F13FC8D5CD575CB7D2960B3BBD365BC89E2FDE9455" $FileName &= "70BDB1B5BAE6A9E99A47F6619F59D6EE8BCA17749349D71E83F4C0141D2F45F165F3EA16D7F72D1A9D93440B2678F978600AF1F9D7954A55B158A788A4924B45" $FileName &= "7EBDCE9B518C6309DDC637BB5DD95DB45D175DB77BDF0D4B1D9DF47FF2C946C5CE3EEB20E83B640FCEB47C2FAD4B705EC6F55E2BA84EC747EA0FF9FC2B92568B" $FileName &= "C3DE35DD64EE208A68EDA42E4B16DD8C8CFD4823E95D0EB2A2CFC71652C7F29B984EF007F75B00FE4696323FBB78986938357B7537AB4AE952936E32578DF75E" $FileName &= "44BE3AF35F4A448E36656E084EB8EF491F8D34C8618E34B5D480450A33067B7FBD5D21F2DD364881D7B66A3FB2D9FF00CFBA9F6AD961F1F86AB51D049A93BEE7" $FileName &= "9D0C4D074634EAC5E9E76392B0B93AEF8C9EF9229D2DD2258E31326D23B9F5EE6ACEADE21BEB2F16C3A6431C696ECF17CE63C9756C86FD476AD2D76EA6D22C05" $FileName &= "C69B6F197C82491FC3DC63D6B175FD3FFE128D32CF58D20FFA4AAE55720332F5DB9E9B95B18CFA9F5AE5C35275E756A54B3A975A5B6B1DB4E54EA4A329AB536B" $FileName &= "955DECFCCB1E3B9716BA7248C040D724C99E9F2A9229FE0780269771A9C9841772EF5623198C7DD3F4EB8F635969E398E583ECFA9E9624B98DB0E8CC000C3D55" $FileName &= "F907F95476FE3AB9B69E492F2DE17B565022821700C78FE79FD31C57A4AAE1A388559CBA5AD6D8D3EAB89FAAFB050D9EF75AFA143C3D04BE22D623B8F2CBC1F6" $FileName &= "937770EC721792513DCF41EC0574334DFDB3E39022F9A1B15F2B781D589CB0FC38AA5A8EBDAA7F621974ED29F4BD39884F3D940701BBAA81C0E8371F5AE83C2F" $FileName &= "A759E9FA6AC96E779719DDEA7D4D7062D592C253D5D4776F61D7AAE29D79AB69CA92D6DDEE69EEA37549F64B8FF9E47FEFA1FE349F64B8FF009E47FEFA1FE35F" $FileName &= "507CE0D611CD118661943EA3A572B2691AAF87EE64B8D25849048774903728DEFEC7DC7E39E2BADFB25C8FF9647FEFA1FE34E586ED78F2C91E8483FD6BC9C5E5" $FileName &= "CE753DBD0972CFF067561F172A49C5ABA7D0E324F10D9DC129AC6812E4F0488D6507078F7E94D8B5BD16CCE74DD0253213CE2D82631D0E4D766D661C1F32C816" $FileName &= "F5C8FF001A45B054E63B200FD56B99ACCF6718B7DCEB58BC35BE17E977638E921D7BC4E0C37282CEC5FAC49C961FED377EDD2BAAB5B48EC2C92D636CEDEBED56" $FileName &= "DA2BB23023DA3D148FF1A8FECB71FF003C8FFDF43FC6B7C365F515555F152BC96DD91CF88C5BA9154E2B963D91FFD9" Return $FileName EndFunc;Authors: Prog@ndy, based on code by Zedna Func _SetImageBinaryToCtrl($CtrlId, ByRef $Binary) Local $picdata = Binary($Binary) ; Fetch the Data Local $piclength = BinaryLen($picdata) ; Get Length Local $picstruct = DllStructCreate("byte[" & $piclength & "]") DllStructSetData($picstruct,1,$picdata) Local $picmemory = DllStructGetPtr($picstruct) _SetMemoryImageToCtrl($CtrlId, $picmemory, $piclength) DllStructSetData($picstruct,1,0) $picstruct = "" EndFunc ; Authors: Zedna, based on code by Prog@ndy Func _SetMemoryImageToCtrl($CtrlId, $Pointer, $nSize) Local $hData, $pData, $pStream, $pBitmap, $hBitmap ; use GDI+ for converting to bitmap first $hData = _MemGlobalAlloc($nSize,2) $pData = _MemGlobalLock($hData) _MemMoveMemory($Pointer,$pData,$nSize) _MemGlobalUnlock($hData) $pStream = DllCall( "ole32.dll","int","CreateStreamOnHGlobal", "int",$hData, "long",1, "Int*",0) $pStream = $pStream[3] _GDIPlus_Startup() $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "int*",0) $pBitmap = $pBitmap[2] $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($pBitmap) _SetBitmapToCtrl($CtrlId, $hBitmap) If @error Then SetError(3, 0, 0) _GDIPlus_BitmapDispose($pBitmap) _GDIPlus_Shutdown() _WinAPI_DeleteObject($pStream) _MemGlobalFree($hData) EndFunc ; internal helper function ; Out of resources.au3 :) Func _SetBitmapToCtrl($CtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 Local $hWnd = GUICtrlGetHandle($CtrlId) If $hWnd = 0 Then Return SetError(1, 0, 0) ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE) If @error Then Return SetError(2, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(3, 0, 0) Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap) If @error Then Return SetError(4, 0, 0) If $oldBmp[0] <> 0 Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc
    1 point
  3. Hi guys, I read these threads: and I thought about, is it possible to add such things to Autoit core or make it available by creating a free dll or UDF? There are lot of Windows controls which are available through functions included in Autoit3 core and there are some additional things added via UDFs. Can somebody explain to me, what needs to be done to have the possibility to create menus like in Excel and so on with Autoit. Thanks! Sorry, I'm no C++ programmer and that is why, I do not know much about these COM objects and .Net classes ... So, please do not flame me. Mega
    1 point
  4. OK. Then we need the following code: #include <Excel.au3> $oExcel = _ExcelBookOpen("F:\datafiles\DOT\JLauto\Resources\DOT.xls") If @error Then Exit MsgBox(16, "Error", "_ExcelBookOpen returned error " & @error) $aSheets = _ExcelSheetList($oExcel) If @error Then Exit MsgBox(16, "Error", "_ExcelSheetList returned error " & @error)Now we have an array with all sheet names. Which sheet should be processed?
    1 point
  5. KaFu

    Is _Arraysort() a wimp?

    I used the region tag for pure readability, to show which part of the global code is necessary for the function to work. This should do it: ArraySortClib.au3 #include-once #include <memory.au3> Global $h_DLL_user32 = DllOpen("user32.dll") Global $h_DLL_msvcrt = DllOpen("msvcrt.dll") Global $h_DLL_Kernel32 = DllOpen("kernel32.dll") Global $pEnumProc_ArraySortClib_Mem1 = _MemVirtualAlloc(0, 64, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; needed for _ArraySortClib() Global $pEnumProc_ArraySortClib_Mem2 = _MemVirtualAlloc(0, 64, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; needed for _ArraySortClib() Global $pEnumProc_ArraySortClib_Mem3 = _MemVirtualAlloc(0, 36, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; needed for _ArraySortClib() OnAutoItExitRegister("ArraySortClib_Mem_Release") Func ArraySortClib_Mem_Release() _MemVirtualFree($pEnumProc_ArraySortClib_Mem1, 0, $MEM_RELEASE) ; release mem reserved for _ArraySortClib() _MemVirtualFree($pEnumProc_ArraySortClib_Mem2, 0, $MEM_RELEASE) ; release mem reserved for _ArraySortClib() _MemVirtualFree($pEnumProc_ArraySortClib_Mem3, 0, $MEM_RELEASE) ; release mem reserved for _ArraySortClib() DllClose($h_DLL_user32) DllClose($h_DLL_msvcrt) DllClose($h_DLL_Kernel32) EndFunc ;==>ArraySortClib_Mem_Release ; http://www.autoitscript.com/forum/index.php?showtopic=63525&view=findpost&p=474072 ;=============================================================================== ; Function Name: _ArraySortClib() v4 ; Description: Sort 1D/2D array using qsort() from C runtime library ; Syntax: ; Parameter(s): $Array - the array to be sorted, ByRef ; $iMode - sort mode, can be one of the following: ; 0 = numerical, using double precision float compare ; 1 = string sort, case insensitive (default) ; 2 = string sort, case sensitive ; 3 = word sort, case insensitive - compatible with AutoIt's native compare ; $fDescend - sort direction. True = descending, False = ascending (default) ; $iStart - index of starting element (default 0 = $array[0]) ; $iEnd - index of ending element (default 0 = Ubound($array)-1) ; $iColumn - index of column to sort by (default 0 = first column) ; $iStrMax - max string length of each array element to compare (default 4095 chars) ; Requirement(s): msvcrt.dll (shipped with Windows since Win98 at least), 32-bit version of AutoIt ; Return Value(s): Success = Returns 1 ; Failure = Returns 0 and sets error: ; @error 1 = invalid array ; @error 2 = invalid param ; @error 3 = dll error ; @error 64 = 64-bit AutoIt unsupported ; Author(s): Siao ; Modification(s): KaFu, added three global _MemVirtualAlloc() calls to top of script to prevent DEP Errors: ; ; Global $pEnumProc_ArraySortClib_Mem1 = _MemVirtualAlloc(0, 64, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; needed for _ArraySortClib() ; Global $pEnumProc_ArraySortClib_Mem2 = _MemVirtualAlloc(0, 64, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; needed for _ArraySortClib() ; Global $pEnumProc_ArraySortClib_Mem3 = _MemVirtualAlloc(0, 36, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; needed for _ArraySortClib() ; ;=============================================================================== Func _ArraySortClib(ByRef $array, $iMode = 1, $fDescend = False, $iStart = 0, $iEnd = 0, $iColumn = 0, $iStrMax = 4095) If @AutoItX64 Then Return SetError(64, 0, 0) Local $iArrayDims = UBound($array, 0) If @error Or $iArrayDims > 2 Then Return SetError(1, 0, 0) Local $iArraySize = UBound($array, 1), $iColumnMax = UBound($array, 2) If $iArraySize < 2 Then Return SetError(1, 0, 0) If $iEnd < 1 Or $iEnd > $iArraySize - 1 Then $iEnd = $iArraySize - 1 If ($iEnd - $iStart < 1) Then ; ConsoleWrite("- _ArraySortClib ERROR: #1 - " & ($iEnd - $iStart < 1) & @tab & ($iEnd - $iStart) & @crlf) Return SetError(2, 0, 0) EndIf If $iArrayDims = 2 And ($iColumnMax - $iColumn < 0) Then ; ConsoleWrite("- _ArraySortClib ERROR: #2 - " & $iArrayDims & @tab & ($iColumnMax - $iColumn < 0) & @tab & ($iColumnMax - $iColumn) & @crlf) Return SetError(2, 0, 0) EndIf If $iStrMax < 1 Then ; ConsoleWrite("- _ArraySortClib ERROR: #3 - " & $iStrMax & @crlf) Return SetError(2, 0, 0) EndIf Local $i, $j, $iCount = $iEnd - $iStart + 1, $fNumeric, $aRet, $sZero = ChrW(0), $sStrCmp, $sBufType = 'byte[', $tSource, $tIndex, $tFloatCmp Local $tEnumProc = DllStructCreate('byte[64]', $pEnumProc_ArraySortClib_Mem1) Local $tCmpWrap = DllStructCreate('byte[64]', $pEnumProc_ArraySortClib_Mem2) If $h_DLL_msvcrt = -1 Then Return SetError(3, 0, 0) ;; initialize compare proc Switch $iMode Case 0 $fNumeric = True $tFloatCmp = DllStructCreate('byte[36]', $pEnumProc_ArraySortClib_Mem3) DllStructSetData($tFloatCmp, 1, '0x8B4C24048B542408DD01DC1ADFE0F6C440750D80E441740433C048C333C040C333C0C3') DllStructSetData($tCmpWrap, 1, '0xBA' & Hex(Binary(DllStructGetPtr($tFloatCmp)), 8) & '8B4424088B4C2404FF30FF31FFD283C408C3') DllStructSetData($tEnumProc, 1, '0x8B7424048B7C24088B4C240C8B442410893789470483C60883C708404975F1C21000') Case 1, 2 $sStrCmp = "_strcmpi" ;case insensitive If $iMode = 2 Then $sStrCmp = "strcmp" ;case sensitive $aRet = DllCall($h_DLL_Kernel32, 'ptr', 'GetModuleHandle', 'str', 'msvcrt.dll') $aRet = DllCall($h_DLL_Kernel32, 'ptr', 'GetProcAddress', 'ptr', $aRet[0], 'str', $sStrCmp) ;If $aRet[0] = 0 Then Return SetError(3, 0, 0 * DllClose($h_DLL_msvcrt)) If $aRet[0] = 0 Then Return SetError(3, 0, 1) DllStructSetData($tCmpWrap, 1, '0xBA' & Hex(Binary($aRet[0]), 8) & '8B4424088B4C2404FF30FF31FFD283C408C3') DllStructSetData($tEnumProc, 1, '0x8B7424048B7C24088B4C240C8B542410893789570483C7088A064684C075F9424975EDC21000') Case 3 $sBufType = 'wchar[' $aRet = DllCall($h_DLL_Kernel32, 'ptr', 'GetModuleHandle', 'str', 'kernel32.dll') $aRet = DllCall($h_DLL_Kernel32, 'ptr', 'GetProcAddress', 'ptr', $aRet[0], 'str', 'CompareStringW') ;If $aRet[0] = 0 Then Return SetError(3, 0, 0 * DllClose($h_DLL_msvcrt)) If $aRet[0] = 0 Then Return SetError(3, 0, 1) DllStructSetData($tCmpWrap, 1, '0xBA' & Hex(Binary($aRet[0]), 8) & '8B4424088B4C24046AFFFF306AFFFF3168000000006800040000FFD283E802C3') DllStructSetData($tEnumProc, 1, '0x8B7424048B7C24088B4C240C8B542410893789570483C7080FB70683C60285C075F6424975EAC21000') Case Else Return SetError(2, 0, 0) EndSwitch ;; write data to memory If $fNumeric Then $tSource = DllStructCreate('double[' & $iCount & ']') If $iArrayDims = 1 Then For $i = 1 To $iCount DllStructSetData($tSource, 1, $array[$iStart + $i - 1], $i) Next Else For $i = 1 To $iCount DllStructSetData($tSource, 1, $array[$iStart + $i - 1][$iColumn], $i) Next EndIf Else Local $sMem = "" If $iArrayDims = 1 Then For $i = $iStart To $iEnd $sMem &= StringLeft($array[$i], $iStrMax) & $sZero Next Else For $i = $iStart To $iEnd $sMem &= StringLeft($array[$i][$iColumn], $iStrMax) & $sZero Next EndIf $tSource = DllStructCreate($sBufType & StringLen($sMem) + 1 & ']') DllStructSetData($tSource, 1, $sMem) $sMem = "" EndIf ;; index data $tIndex = DllStructCreate('int[' & $iCount * 2 & ']') DllCall($h_DLL_user32, 'uint', 'CallWindowProc', 'ptr', DllStructGetPtr($tEnumProc), 'ptr', DllStructGetPtr($tSource), 'ptr', DllStructGetPtr($tIndex), 'int', $iCount, 'int', $iStart) ;; sort DllCall($h_DLL_msvcrt, 'none:cdecl', 'qsort', 'ptr', DllStructGetPtr($tIndex), 'int', $iCount, 'int', 8, 'ptr', DllStructGetPtr($tCmpWrap)) ;DllClose($h_DLL_msvcrt) ;; rearrange the array by sorted index Local $aTmp = $array, $iRef If $iArrayDims = 1 Then ; 1D If $fDescend Then For $i = 0 To $iCount - 1 $iRef = DllStructGetData($tIndex, 1, $i * 2 + 2) $array[$iEnd - $i] = $aTmp[$iRef] Next Else ; ascending For $i = $iStart To $iEnd $iRef = DllStructGetData($tIndex, 1, ($i - $iStart) * 2 + 2) $array[$i] = $aTmp[$iRef] Next EndIf Else ; 2D If $fDescend Then For $i = 0 To $iCount - 1 $iRef = DllStructGetData($tIndex, 1, $i * 2 + 2) For $j = 0 To $iColumnMax - 1 $array[$iEnd - $i][$j] = $aTmp[$iRef][$j] Next Next Else ; ascending For $i = $iStart To $iEnd $iRef = DllStructGetData($tIndex, 1, ($i - $iStart) * 2 + 2) For $j = 0 To $iColumnMax - 1 $array[$i][$j] = $aTmp[$iRef][$j] Next Next EndIf EndIf Return 1 EndFunc ;==>_ArraySortClib ArraySortClib_Example.au3 #include <ArraySortClib.au3> #include <array.au3> ; not needed for _ArraySortClib() itself, only for example Global $aFileList[60001][2] = [[60000, ""]] $timer = TimerInit() For $i = 1 To 30000 $aFileList[$i][0] = "FileType_A" & $i $aFileList[$i][1] = StringRight("00000" & $i, 6) Next For $i = 1 To 30000 $aFileList[$i + 30000][0] = "FileType_B" & $i $aFileList[$i + 30000][1] = StringRight("00000" & $i, 6) Next ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _ArrayDisplay($aFileList) ConsoleWrite(TimerDiff($timer) & @CRLF) ; _ArraySort($aFileList, 0, 1, 0, 1) $timer = TimerInit() _ArraySortClib($aFileList, 1, 0, 0, 0, 1) ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _ArrayDisplay($aFileList) ConsoleWrite(TimerDiff($timer) & @CRLF)
    1 point
  6. I've updated SciTE Jump with the largest changelog I have every created during my time developing SciTE Jump. This release comes with many bug fixes as well as nice additions, one of which is manually (for now) adding LineToPixel to the INI file and specifying whether the function should appear at the top or a certain number of pixels e.g. 180px. Any problems please post below and thanks for trying SciTE Jump. I've also included a ZIP file on the download page for those who are a little reluctant to use the Portable installer. It should be noted that I have updated the language strings from the previous version, so if you provided a translation for the last version then by all means update the translation and send to me. Download is available in the original post. Language Changes: Changelog:
    1 point
  7. Come on, Mircosoft is moving forward. There are new desgin concepts and new controls. Somebody must know, what needs to be done to use this stuff in Autoit.
    1 point
  8. It's not really clear to me what you want. I answered your questions but it seems this didn't clear the fog. Let's do it the other way round. I ask questions and as soon as we have an answer we create the needed code. Then go on to the next question. First question: Do the names of the worksheets change (this means you have to read the sheet names and then process the returned array) or are the names fixed?
    1 point
  9. Have you tried it without using GDI+ at all, unless it's absolutely necessary for the rest of your script that is? You could do the same thing with a label control with a background color which looks pretty much identical. #include <GUIConstantsEx.au3> ;~ #include <GDIPlus.au3> #include <WindowsConstants.au3> MsgOkey() Func MsgOkey() Local $win_Okey, $msg Local $img_hGraphic $win_Okey = GUICreate("Test", 386, 131, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_LAYOUTRTL) GUISetBkColor(0xFFFFFF) GUISetState() ;~ _GDIPlus_Startup() ;~ $img_hGraphic = _GDIPlus_GraphicsCreateFromHWND($win_Okey) ;~ _GDIPlus_GraphicsFillRect($iGuictrlcreatelabmg_hGraphic, 0, 85, 386, 70, _GDIPlus_BrushCreateSolid(0xF0F0F0F0)) GUICtrlCreateLabel("", 0, 85, 386, 70) GUICtrlSetBkColor(-1, 0xF0F0F0) GUICtrlSetState(-1, $GUI_DISABLE) Local $Button = GUICtrlCreateButton(" Test ", 70, 95) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ;~ _GDIPlus_Shutdown() GUIDelete() ExitLoop Case $msg = $Button MsgBox(0, "", "Button pressed") EndSelect WEnd EndFunc ;==>MsgOkey
    1 point
  10. Possibly if your wstring only contains characters from the ascii set, which in both standards are defined as the first 255. As soon as you get past that, you have troubles. eg. the letter 'Ā', in binary: 0000000100000000 will in a conversion done like this: wchar_t my_wc = 'Ā'; char my_c = (char)my_wc; be truncated to: 00000000 Or, null, which is the common string stop nominator (even though it works with std::strings .. you suddenly have unwanted null's in your string)
    1 point
  11. http://www.cplusplus.com/reference/string/basic_string/basic_string/ Specifically: where charT = wchar_t for std::wstrings. The casting and iteration process is safe per-se, but it's not guaranteed to be a valid ascii -> unicode conversion and as of such might output garbage. This operation is not reversable, as in, you cannot do this from unicode to ascii (it will truncate the wchar_t's to chars).
    1 point
  12. Sure. For details please have a look in the help file.
    1 point
  13. According to the book Code Complete these are some compelling reasons to avoid global scope. Most of these relate to information hiding in some way or another. A variable that is global is available to functions which may never need to have access to that variable. Most of these are relevant to AutoIt and others are not. * Inadvertent changes to global data. - "You might change the value of a global variable in one place and mistakenly think that it had remained unchanged somewhere else. Such a problem is known as a 'side effect'." Reducing side effects is also achieved by having functions perform one task and perform it well. Also, functions should not modify global data. They also should be referentially transparent. Basically, a function should only operate on data which is passed through its parameters. Additionally, every time a function is called with the same arguments it should return the same result every time. So, avoid using random numbers, time and date functions and avoid asking for user input within functions. * Bizarre and exciting aliasing problems with global data. - "'Aliasing' refers to calling the same variable by two or more different names." * Re-entrant code problems with global data. - "Code that can be entered by more than one thread of control is becoming increasingly common. Multithreaded code creates the possibility that global data will be shared not only among routines, but among different copies of the same program." * Code reuse hindered by global data. - "Ideally, you'd be able to lift out a single routine or class, plug it into another program, and continue merrily on your way. Global data complicates the picture." I've encountered this problem with code that I've tried to reuse in my own scripts. * Uncertain initialization-order issues with global data. - "The order in which data is initialized among different 'translation units' (files) is not defined in some languages." * Modularity and intellectual manageability damaged by global data. - "The essence of creating programs that are larger than a few hundred lines of code is managing complexity. The only way you can intellectually manage a large program is to break it into pieces so that you only have to think about one part at a time." edit: forgot a bullet point
    1 point
  14. Ah, that's when you know the actual name of the function. No problem then, at least you learnt something.
    1 point
  15. BrewManNH

    SciTE Colo(u)r Chooser

    Ever had the need to pick a hex value for a color for a GUI or a control? Ever tried to figure out how to get those numbers into your script once you've picked the perfect color? I have come up with an extremely small script, that when compiled and placed in a folder inside the SciTE folder will allow you to quickly select the color you want using the _ChooseColor dialog. It will then paste this color code into your script where you cursor is currently placed. It works with Scite only for now, mainly because it uses ControlSend to paste the value into SciTE's editor window, but can easily be modified to work with any editor by changing the window title and control ID it's sending to. This code will work when compiled and placed into the "Autoit3\Scite\ColorChooser" folder, or wherever you have your installation of SciTE, but has to be in the folder named ColorChooser for the tool code to work, or you'll have to change that yourself. Here's the code for the colorchooser: #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Run_Tidy=y #Tidy_Parameters=/rel #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/so #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Misc.au3> #include <SendMessage.au3> Opt("WinTitleMatchMode", 2) Global $sDefaultColor = 0 Global $iMode = 1 Global Const $WM_COPYDATA = 0x004A If $cmdline[0] > 0 Then $sDefaultColor = $cmdline[1] EndIf If StringLeft($sDefaultColor, 2) <> "0x" Then $iMode = 0 $sDefaultColor = "0x" & $sDefaultColor EndIf $sReturn = _ChooseColor(2, $sDefaultColor, 2) If $sReturn = -1 Then Exit (1) If Not $iMode Then $sReturn = StringMid($sReturn, 3) EndIf _SciTE_InsertText($sReturn) Func _SciTE_InsertText($sString) Return _SciTE_Send_Command(0, WinGetHandle("DirectorExtension"), "insert:" & $sString) EndFunc ;==>_SciTE_InsertText Func _SciTE_Send_Command($hHandle, $hSciTE, $sString) Local $ilParam, $tData If StringStripWS($sString, 8) = "" Then Return SetError(2, 0, 0) ; String is blank. EndIf $sString = ":" & Dec(StringTrimLeft($hHandle, 2)) & ":" & $sString $tData = DllStructCreate("char[" & StringLen($sString) + 1 & "]") ; wchar DllStructSetData($tData, 1, $sString) $ilParam = DllStructCreate("ptr;dword;ptr") ; ulong_ptr;dword;ptr DllStructSetData($ilParam, 1, 1) ; $ilParam, 1, 1 DllStructSetData($ilParam, 2, DllStructGetSize($tData)) DllStructSetData($ilParam, 3, DllStructGetPtr($tData)) _SendMessage($hSciTE, $WM_COPYDATA, $hHandle, DllStructGetPtr($ilParam)) Return Number(Not @error) EndFunc ;==>_SciTE_Send_Command As you can see, there's not a whole lot to it. It just pops open the color chooser dialog, copies the results to the clipboard and then pastes it into SciTE using the ControlSend command. You will also notice, that if you don't choose a color, by hitting cancel in the Color Chooser dialog, it will also exit without pasting anything, so you shouldn't need to worry about pasting something you don't want in your scripts. This code should be added to your SciTEUser.properties file so that you can call it from within SciTE by hitting Ctrl-Alt-C, this can be changed if you already have a hot key set to that combination. # 43 Color Chooser command.name.43.*=Color Chooser command.43.*="$(SciteDefaultHome)\ColorChooser\ColorChooser.exe" $(CurrentSelection) command.shortcut.43.*=Ctrl+Alt+C That's all there is to it, enjoy. EDIT: I have updated the script and the SciTEUser.properties code so that if you have a color code that's currently selected when this is called, it will send that to the _ChooseColor dialog now as the starting color. UPDATED: 31-May-12 I've updated the script so that it now uses the "DirectorExtension" as suggested by guinness instead of copying the data to the clipboard and pasting it into SciTE, which might cause problems with what you have on the clipboard currently. I have also updated it so that if you send the script a color in the format "FFFFFF" without the preceeding "0x", it will return the color code in the same format. This is useful if, for example, you're changing a color in one of SciTE's properties files, which don't start with "0x". I've also changed the command.43.* line, I've moved the quote from the end of the line to the end of the command because I've noticed that a lot of times it causes issues if the color code is inside the quotes.
    1 point
×
×
  • Create New...