Leaderboard
Popular Content
Showing content with the highest reputation on 12/12/2016 in all areas
-
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... RT1 point
-
After you have loaded the image using _GDIPlus_BitmapCreateFromMemory (returned handle must be a GDI+ handle) you can resize it using _GDIPlus_ImageResize _GDIPlus_ImageScale1 point
-
Remove/exclude any whitespace/tab before pattern when using StringRegExp
amdogelover reacted to mikell for a topic
I don't know how and where the files are but you could try something like this $tempRead = _FileListToArray(@MyDocumentsDir & "\path\", "*X_2*", $FLTA_FILES, true) _ArrayDisplay($tempRead) ; $fromSourceRead = FileRead($tempRead[3]) ; Msgbox(0,"", $fromSourceRead) For $i = 1 To $tempRead[0] ConsoleWrite("i: " & $i & " " & $tempRead[$i] & @CRLF) $fromSourceRead = FileRead($tempRead[$i]) $tempAverageFpsVal2 = StringRegExp($fromSourceRead, 'Average FPS:\s*(\S+)', 1) $tempMinimumFpsVal2 = StringRegExp($fromSourceRead, 'Min FPS:\s*(\S+)', 1) $tempFramesFpsVal = StringRegExp($fromSourceRead, 'Num Frames:\s*(\S+)', 1) _ArrayDisplay($tempAverageFpsVal2) _ArrayDisplay($tempMinimumFpsVal2) _ArrayDisplay($tempFramesFpsVal) Next1 point -
Remove/exclude any whitespace/tab before pattern when using StringRegExp
amdogelover reacted to mikell for a topic
StringRegExp(..., ..., 1) returns an array And my code strips the WS around the result Please try it on the text you posted in post #1 #Include <Array.au3> $txt = "Raw Benchmark Statistics for 1 run:" & @crlf & _ @crlf & _ " Benchmark Statistics (Run No. 1):" & @crlf & _ " Min FPS: 46.4 <- THIS" & @crlf & _ " Max FPS: 80.8" & @crlf & _ " Average FPS: 60.0 <- THIS" & @crlf & _ " Num Frames: 1471 <- THIS" Msgbox(0,"", $txt) ;$txt = FileRead("1.txt") $res = StringRegExp($txt, 'Average FPS:\s*(\S+)', 1) _ArrayDisplay($res)1 point -
Remove/exclude any whitespace/tab before pattern when using StringRegExp
amdogelover reacted to mikell for a topic
Try this StringRegExp($fromSourceRead, 'Average FPS:\s*(\S+)', 1)1 point -
ConsoleWrite(_GetDrivePartitionStyle() & @CRLF) ConsoleWrite(_WinAPI_GetFirmwareEnvironmentVariable() & @CRLF) Func _GetDrivePartitionStyle($sDrive = "C") Local $tDriveLayout = DllStructCreate('dword PartitionStyle;' & _ 'dword PartitionCount;' & _ 'byte union[40];' & _ 'byte PartitionEntry[8192]') Local $hDrive = DllCall("kernel32.dll", "handle", "CreateFileW", _ "wstr", "\\.\" & $sDrive & ":", _ "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ "ptr", 0) If @error Or $hDrive[0] = Ptr(-1) Then Return SetError(@error, @extended, 0) ; INVALID_HANDLE_VALUE DllCall("kernel32.dll", "int", "DeviceIoControl", _ "hwnd", $hDrive[0], _ "dword", 0x00070050, _ "ptr", 0, _ "dword", 0, _ "ptr", DllStructGetPtr($tDriveLayout), _ "dword", DllStructGetSize($tDriveLayout), _ "dword*", 0, _ "ptr", 0) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hDrive[0]) Switch DllStructGetData($tDriveLayout, "PartitionStyle") Case 0 Return "MBR" Case 1 Return "GPT" Case 2 Return "RAW" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_GetDrivePartitionStyle Func _WinAPI_GetFirmwareEnvironmentVariable() DllCall("kernel32.dll", "dword", _ "GetFirmwareEnvironmentVariableW", "wstr", "", _ "wstr", "{00000000-0000-0000-0000-000000000000}", "wstr", "", "dword", 4096) Local $iError = DllCall("kernel32.dll", "dword", "GetLastError") Switch $iError[0] Case 1 Return "LEGACY" Case 998 Return "UEFI" Case Else Return "UNKNOWN" EndSwitch EndFunc ;==>_WinAPI_GetFirmwareEnvironmentVariable1 point
-
ISN AutoIt Studio [old thread]
radienergos reacted to ISI360 for a topic
Hi radienergos! Currently a variable is not included. (but i plan to add more with the next updates) But at this time, you could create it by your own with: Create a Macro and add "Execute command" to the actions list. Add one of the following code: Run ("C:\windows\notepad.exe "&$Datei_pfad[_GUICtrlTab_GetCurFocus($htab)]) In this example, the macro runs notepad.exe with the currently opened file of the ISN AutoIt Studio. OR use this for @scriptdir+@scriptname: Run("C:\temp\tool.exe "&StringTrimRight($Datei_pfad[_GUICtrlTab_GetCurFocus($htab)],(stringlen($Datei_pfad[_GUICtrlTab_GetCurFocus($htab)])-StringInStr($Datei_pfad[_GUICtrlTab_GetCurFocus($htab)],"\",0,-1))+1)&" "&StringTrimleft($Datei_pfad[_GUICtrlTab_GetCurFocus($htab)],StringInStr($Datei_pfad[_GUICtrlTab_GetCurFocus($htab)],"\",0,-1))) This should do the job as you wish. Hope this helps you!1 point -
I've seen a few questions since I've been back on how to handle IE events. I've answered a couple, but the last time I answered one, they said it looked complicated. So here's an attempt to help them and others easily track html document events (basic, 2, 3, and 4). There are links within the source to msdn explaining the events they capture. I've provided two "simple" examples. Things to note: When doing these, since they are callback methods, I wanted to treat them like we would GUIRegisterMsg a bit. So the 3 params you'll have to have in your event handler (if you don't use the internal) are (names can be different, but the data will be specific when sent to it). Param1: Event object variable Param2: Target object variable (target is: object.currentTarget, object.Target, object.srcElement if you're wondering) Param3: Type variable (to hold a string) Take a look at the example if you have questions. As always, if you see something that could be better or added let me know. Changes: ; B0.0.2 Fixed: Error for include in examples ; B0.0.2 Fixed: Missing volatile functions (Major) Downloads: 2015-01-03 HTMLDocumentEvents.B001.zip 2015-01-04 HTMLDocumentEvents.B002.zip1 point
-
Use WM_PAINT to draw on the GUI, orelse with your code try to minimize + restore you will find that all the graphics disappear. For your question check the function CheckPointer in the example. Example #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Global $hGraphic, $hBrush, $hBrushFont, $hFont, $hFormat, $hFamily, $hGUI, $tRect_Coords[4] ;would be used in two functions therefore declared as global. Global $iTheme = 0 Example() Func Example() ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) ; Fill a rectangle _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBrush = _GDIPlus_BrushCreateSolid(0xAA43A6DF) $hBrushFont = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Light") $hFont = _GDIPlus_FontCreate($hFamily, 20, 2) $tRect_Coords[0] = 10 $tRect_Coords[1] = 10 $tRect_Coords[2] = 100 $tRect_Coords[3] = 100 ;Register for painting GUIRegisterMsg($WM_PAINT, "WM_PAINT") ;$WM_PAINT GUISetState() ; Loop until the user exits. Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN If CheckPointer($tRect_Coords) Then SetTheme(1) Case $GUI_EVENT_PRIMARYUP SetTheme(0) Case $GUI_EVENT_MOUSEMOVE If GetTheme() = 1 Then ContinueLoop If CheckPointer($tRect_Coords) Then SetTheme(2) Else SetTheme(0) EndIf EndSwitch Until 0 ; Clean up resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrushFont) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example Func WM_PAINT($hGUI, $iMsg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) ;Your Code must lie below ;Paint the string _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) _GDIPlus_GraphicsFillRect($hGraphic, $tRect_Coords[0], $tRect_Coords[1], $tRect_Coords[2], $tRect_Coords[3], $hBrush) _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, _GDIPlus_RectFCreate($tRect_Coords[0], $tRect_Coords[1], $tRect_Coords[2], $tRect_Coords[3]), $hFormat, $hBrushFont) ;End of your code _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return 0;'GUI_RUNDEFMSG' EndFunc ;==>WM_PAINT Func CheckPointer(ByRef $aiCoords_ClientRel) Return _WinAPI_PtInRectEx(_WinAPI_GetMousePosX(True, $hGUI), _WinAPI_GetMousePosY(True, $hGUI), $aiCoords_ClientRel[0], $aiCoords_ClientRel[1], $aiCoords_ClientRel[2] + $aiCoords_ClientRel[0], $aiCoords_ClientRel[3] + $aiCoords_ClientRel[1]) EndFunc ;==>CheckPointer Func GetTheme() Return $iTheme EndFunc ;==>GetTheme Func SetTheme($Theme, $f_Redraw = true) If GetTheme() = $Theme Then Return 1 If $Theme = 0 Then ;Idle _GDIPlus_BrushSetSolidColor($hBrush, 0xAA43A6DF) _GDIPlus_BrushSetSolidColor($hBrushFont, 0xFFFFFFFF) ;Default Dimensions $tRect_Coords[0] = 10 $tRect_Coords[1] = 10 $tRect_Coords[2] = 100 $tRect_Coords[3] = 100 ElseIf $Theme = 1 Then ;MouseDown _GDIPlus_BrushSetSolidColor($hBrush, 0xFF3685B2) _GDIPlus_BrushSetSolidColor($hBrushFont, 0xFFFFFFFF) ;Compress a Bit $tRect_Coords[0] = 12 $tRect_Coords[1] = 12 $tRect_Coords[2] = 96 $tRect_Coords[3] = 96 ElseIf $Theme = 2 Then ;MouseOver _GDIPlus_BrushSetSolidColor($hBrush, 0xBB7BC1E9) _GDIPlus_BrushSetSolidColor($hBrushFont, 0xFFFFFFFF) ;Enlarge a Bit $tRect_Coords[0] = 8 $tRect_Coords[1] = 8 $tRect_Coords[2] = 104 $tRect_Coords[3] = 104 Else Return SetError(1, 0, 0) EndIf $iTheme = $Theme ConsoleWrite("CurTheme: " & $iTheme & @CRLF) If $f_Redraw Then _WinAPI_RedrawWindow($hGUI, 0, 0, BitOR($RDW_INTERNALPAINT, $RDW_ERASE)) endfunc ;==>SetTheme Thumbs up if it helped. Regards Phoenix XL1 point
-
Here something you can play with: ;needs GDIPlus.au3 at least from AutoIt version 3.3.9.23 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hGUI = GUICreate("GDI+ Test", 200, 100) GUISetBkColor(0x505050) Global Const $iPicBtn = GUICtrlCreatePic("", 60, 38, 80, 24) Global $aButtons = _GDIPlus_CreateTextButton("install", 80, 24) _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) GUISetState() Global $aMouseInfo, $bShow = False, $bHide = False Do If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation Switch $aMouseInfo[4] Case $iPicBtn _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1])) $bShow = True $bHide = False Case Else _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) $bHide = True $bShow = False EndSwitch EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($aButtons[0]) _WinAPI_DeleteObject($aButtons[1]) _GDIPlus_Shutdown() Exit Case $iPicBtn MsgBox(0, "Information", "Button pressed") EndSwitch Until False ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_CreateTextButton ; Description ...: Draws via GDI+ a Windows 8 style button with text ; Syntax ........: _GDIPlus_CreateTextButton($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[, ; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]]) ; Parameters ....: $sString - A string value. ; $iWidth - An integer value. ; $iHeight - An integer value. ; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1. ; $iFontSize - [optional] An integer value. Default is 16. ; $sFont - [optional] A string value. Default is "Times New Roman". ; $iHoverColor - [optional] An integer value. Default is 0xFFC9388C. ; $iFrameSize - [optional] An integer value. Default is 2. ; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA. ; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF. ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button ; Author ........: UEZ ; Version .......: 0.85 build 2014-05-08 ; Modified ......: ; Remarks .......: Dispose returned GDI bitmap handles when done ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_CreateTextButton($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $sFont = "Times New Roman", $iHoverColor = 0xFFFFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF) ;some checks If $sString = "" Then Return SetError(1, 0, 0) If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0) If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0) ;create font objects Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis ;create bitmap and graphics context handles Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)] Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])] ;set drawing quality _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;define brush and pen objects Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, 1), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize) ;create path object Local Const $hPath = _GDIPlus_PathCreate() ;create cloned path object for string measurement Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath) _GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat) ;~ Local Const $aInfo = _GDIPlus_PathGetWorldBounds($hPath_Dummy) ;~ $tLayout.Y = ($iHeight - $aInfo[3]) / 2 - Ceiling($aInfo[1]) ;center string on Y axis ;add string to path _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat) ;clear bitmap and draw string _GDIPlus_GraphicsClear($aGfxCtxt[0], $iBgColor) _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) ;draw rectangle on cloned bitmap for hover effect _GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawRect($aGfxCtxt[1], $iFrameSize / 2, $iFrameSize / 2, $iWidth - $iFrameSize, $iHeight - $iFrameSize, $hPenHoverColor) ;dispose object resources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Dummy) _GDIPlus_GraphicsDispose($aGfxCtxt[0]) _GDIPlus_GraphicsDispose($aGfxCtxt[1]) _GDIPlus_BrushDispose($hBrushFontColor) _GDIPlus_PenDispose($hPenFontFrameColor) _GDIPlus_PenDispose($hPenHoverColor) ;create GDI bitmap for later usage Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])] ;dispose GDI+ bitmaps _GDIPlus_BitmapDispose($aBitmaps[0]) _GDIPlus_BitmapDispose($aBitmaps[1]) Return $aHBitmaps EndFunc Br,UEZ1 point