-
Posts
2,318 -
Joined
-
Last visited
Reputation Activity
-
gcue reacted to slayerz in Drag and Drop onto compiled autoit .exe
Just use commandline parameter. Quick example
If $CmdLine[0] <> 0 Then MsgBox(4000, "Drag n Drop Demo", "Dropped file is " & $CmdLine[1])
The script must be compiled
-
gcue got a reaction from SOLVE-SMART in trying to get JSON from output
this worked!!!
-w "%%header{Dropbox-Api-Result}" thank you both VERY much!!
🕺
-
gcue reacted to UEZ in Inline Assembler Snippets
I will try to maintain this topic by inserting links in the first post (here) to the snippets to keep track of the snippets.
My examples are using AndyG's AssembleIt UDF / AssembleIt2 UDF which is here:
AssembleIt.au3 (needs FASM.au3 -> see link below (ward))
;AssembleIt by Andy @ www.autoit.de ;BIG thx to progandy for the "Buttons" in the debugger ;see examples how to call _AssembleIt() ;Listview changed in Debugger 12.05.2012 ;SSE-Register are nor in the right direction (bitwise from right to left) 20.02.2012 ;Debugger included 07.04.2011 ;modified by UEZ 05.03.2015 #include-once #include "FASM.au3" #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> ;#include <GUIListBox.au3> #include <GuiStatusBar.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <array.au3> #include <GuiListView.au3> #include <WinAPI.au3> ;Opt("MustDeclareVars", 1) If @AutoItX64 Then MsgBox(0, "_AssembleIt Error", "Sorry, 64Bit is not supported. Program will be terminated!") Exit EndIf Global $_ASSEMBLEIT_FLAG = 1 Global $Fasm = FasmInit() If @error Then MsgBox(0, "_AssembleIt Error", "Not able to FasmInit! Program will be terminated!") Exit EndIf ; #FUNCTION# ====================================================================================== ; Name ..........: _AssembleIt() ; Description ...: "Wrapper" for the FASM.au3 by Ward ; Syntax ........: _AssembleIt($Returntype, $sFunc, $Type1 = "type", $Param1 = 0, $Type2 = "type", $Param2 = 0.... ; Parameters ....: $Returntype - Data type returned by the assembled program ; $sFunc - Name of the function, in which the Assemblercode is contained ; $sType1 - DataType of Parameter1 ; $sParam1 - Parameter1 ; $sType2 - DataType of Parameter2 ; $sParam2 - Parameter2.....and so on, you can pass up to 20 parameters ; ; Return values .: Success depends on $Returntype @error=0 ; Failure @error = -2 FasmReset has failed ; Failure @error = -3 Error in Assemblercode detected by Fasm ; Failure @error = -4 Function with Assemblercode doesn´t exist (i.e. wrong functionname) ; Failure @error = -5 Error while executing MemoryFuncCall ; ; Author ........: Andy @ www.autoit.de ; Modified ......: ; Remarks .......: _AssembleIt() instructs MemoryFuncCall with cdecl-convention, so only a RET is necessary at the end of the ASM-code ; If $_ASSEMBLEIT_FLAG = 0 is set before calling AssembleIt(), an AutoIt-code to call the opcodes without the need of FASM.au3 is created ; Related .......: Fasm.au3 by Ward http://www.autoitscript.com/forum/index.php?showtopic=111613&view=findpost&p=782727 ; Link ..........: ; Example .......: ; ================================================================================================= Func _AssembleIt($Returntype, $sFunc, $Type1 = "int", $Param1 = 0, $Type2 = "int", $Param2 = 0, $Type3 = "int", $Param3 = 0, $Type4 = "int", $Param4 = 0, $Type5 = "", $Param5 = 0, $Type6 = "", $Param6 = 0, $Type7 = "", $Param7 = 0, $Type8 = "", $Param8 = 0, $Type9 = "", $Param9 = 0, $Type10 = "", $Param10 = 0, $Type11 = "", $Param11 = 0, $Type12 = "", $Param12 = 0, $Type13 = "", $Param13 = 0, $Type14 = "", $Param14 = 0, $Type15 = "", $Param15 = 0, $Type16 = "", $Param16 = 0, $Type17 = "", $Param17 = 0, $Type18 = "", $Param18 = 0, $Type19 = "", $Param19 = 0, $Type20 = "", $Param20 = 0) ;assembles the code FasmReset($Fasm) If @error Then MsgBox(0, "_AssembleIt Error", "Error in Function FasmReset()") Return SetError(-2, 0, "ERROR -2") EndIf If $sFunc <> "" Then Call($sFunc) ;extract Assemblercode from function $sFunc() If @error = 0xDEAD Then MsgBox(0, "_AssembleIt Error", "The called function " & $sFunc & " doesn´t exist or contains errors!") Return SetError(-4, 0, "ERROR -4") EndIf Local $bytecode = FasmGetBinary($Fasm) ;assemble ASM-code to opcodes If @extended Then ;shows errors during assembling Local $Error = FasmGetLastError() ;gets errors MsgBox(0, "FASM-ERROR in function " & $sFunc & "()", "Error Code:" & $Error[0] & _ @CRLF & "Error Message:" & $Error[1] & @CRLF & "Error Line:" & $Error[2] & @CRLF) Return SetError(-3, 0, "ERROR -3") Else ;no errors during assembling the code FileDelete("asm_test.bin") ;creates binary file with opcodes, in the case that someone wants to use an external debugger^^ FileWrite("asm_test.bin", BinaryToString(String(FasmGetBinary($Fasm)))) ; ConsoleWrite($bytecode & @CRLF) ;opcodes, can easily be copied and inserted somewhere.... If $_ASSEMBLEIT_FLAG = 0 Then ;if less then 4 parameters, CallWindowProcW is possible If @NumParams > 10 Then ;only a maximum of 4 parameters in CallWindowProcW posssible MsgBox(0, "_AssembleIt Error", "The $_ASSEMBLEIT_FLAG is set to 0, but more than 4 Parameters are used in the Function " & $sFunc & @CRLF & _ "Please reduce the number of parameters to a maximum of 4 if you want an AutoItscript with a CallWindowProcW-call!") Exit Else ;all is ready to create an AutoItscript which can execute the opcodes without FASM.au3 Local $scriptstring = 'Local $iRet, $tCodeBuffer = DllStructCreate("byte ASM[' & StringLen($bytecode) / 2 - 1 & ']") ;reserve memory for ASM opcodes' & @CRLF & _ '$tCodeBuffer.ASM = "' & $bytecode & '" ;write opcodes into memory (struct)' & @CRLF $scriptstring &= '$iRet = DllCall("user32.dll", "' & $Returntype & '", "CallWindowProcW", "ptr", DllStructGetPtr($tCodeBuffer)' Local $n = 1 For $i = 3 To 9 Step 2 ;CallWindowProcW must be called with 4 parameters... $scriptstring &= ', "' & Eval("Type" & $n) & '", ' If Eval("Param" & $n) <> 0 Or Eval("Param" & $n) <> "" Then $scriptstring &= "Param" & $n Else $scriptstring &= '0' EndIf $n += 1 Next $scriptstring &= ')' & @CRLF ClipPut($scriptstring) ;puts the AutoItcode into Clipboard MsgBox(0, "_AssembleIt() Info!", "The following code was created and written into the Clipboard:" & _ @CRLF & @CRLF & $scriptstring & @CRLF & @CRLF & @CRLF & _ "This code can now be inserted into an AutoIt-Script, please adapt the parameters in the Dll-call to the used AutoIt-variables!" & _ @CRLF & "The Program will be terminated!") FasmExit($Fasm) Exit EndIf ElseIf $_ASSEMBLEIT_FLAG = 2 Then $scriptstring = '$tCodeBuffer.ASM = "' & $bytecode & '" ;write opcodes into memory (struct) / length: ' & StringLen($bytecode) / 2 - 1 ClipPut($scriptstring) MsgBox(0, "_AssembleIt() Info!", "ONLY the byte code line was created and written into the Clipboard:" & _ @CRLF & @CRLF & $scriptstring) FasmExit($Fasm) Exit EndIf ;MemoryFuncCall Local $scriptstring = 'MemoryFuncCall("' & $Returntype & ':cdecl",' & FasmGetFuncPtr($Fasm) ;cdecl instructs the function to clean the stack, only a simple RET at the end is necessary ;Local $scriptstring = 'MemoryFuncCall("' & $Returntype & '",' & FasmGetFuncPtr($Fasm) ;if "compatible" mode to existing programs is required, please commend out this line Local $n = 1 For $i = 3 To @NumParams Step 2 ;all parameters $scriptstring &= ',"' & Eval("Type" & $n) & '", $Param' & $n $n += 1 Next $scriptstring &= ')' Local $a = Execute($scriptstring) ;do the MemoryFuncCall, execute the opcodes If @error Then MsgBox(0, "_AssembleIt Error", "Error executing the MemoryFuncCall!") Return SetError(-5, 0, "ERROR -5") EndIf ;_arraydisplay($a) Return SetError(0, 0, $a[0]) EndIf EndFunc ;==>_AssembleIt Func _($str) ;short version of Fasmadd Fasmadd($Fasm, $str) EndFunc ;==>_ ;debug-Fenster Dim $_DBG_LABEL[170] Global $hwnd_weiterbutton, $_DBG_closebutton Global $_DBG_firstcall = True, $_DBG_buttonID Global $_DBG_GUI = GUICreate("AssembleIt Debug-Info 1.0", 670, 550, 10, 10, 0, $WS_EX_DLGMODALFRAME) Global $_DBG_winpos = WinGetPos($_DBG_GUI) Global $_DBG_Window_posold_x = $_DBG_winpos[0] ;fensterposition merken Global $_DBG_Window_posold_y = $_DBG_winpos[1] + $_DBG_winpos[3] ;$WM_MOVING = 0x0216 Global $_DBG_BUTTONSGUI = -1 GUIRegisterMsg(0x0216, "_DBG_WM_MOVING") ; $WM_MOVING GUIRegisterMsg(0x0232, "_DBG_WM_MOVING") ; $WM_EXITSIZEMOVE GUIRegisterMsg($WM_MOVE, "_DBG_WM_MOVING") ;~ GUIRegisterMsg($WM_MOVING, "_DBG_WM_MOVING") ;~ GUIRegisterMsg($WM_SIZE, "_DBG_WM_SIZE") ;GUIRegisterMsg($WM_COMMAND, "_DBG_WM_COMMAND") $_DBG_LABEL[18] = GUICtrlCreateLabel("FPU-Register showed as DOUBLE!", 10, 175, 290, 16) GUICtrlSetFont(-1, -1, -1, 4) ;GUICtrlSetResizing ( -1, 32+ 2 ) $_DBG_LABEL[17] = GUICtrlCreateLabel("EFlags", 580, 16, 102, 16) GUICtrlSetFont(-1, -1, -1, 4) $_DBG_LABEL[38] = GUICtrlCreateLabel("CF =", 580, 32 + 16 * 0, 30, 16);CF $_DBG_LABEL[59] = GUICtrlCreateLabel("DF =", 580, 32 + 16 * 1, 30, 16) $_DBG_LABEL[39] = GUICtrlCreateLabel("PF =", 580, 32 + 16 * 2, 30, 16) $_DBG_LABEL[68] = GUICtrlCreateLabel("OF =", 580, 32 + 16 * 3, 30, 16) $_DBG_LABEL[48] = GUICtrlCreateLabel("AF =", 580, 32 + 16 * 4, 30, 16) $_DBG_LABEL[49] = GUICtrlCreateLabel("ZF =", 580, 32 + 16 * 6, 30, 16) $_DBG_LABEL[58] = GUICtrlCreateLabel("SF =", 580, 32 + 16 * 7, 30, 16) For $i = 0 To 7 $_DBG_LABEL[10 + $i] = GUICtrlCreateLabel("ST" & $i & " = ", 10 + Mod($i, 2) * 180, 195 + 16 * Int($i / 2), 30, 16) $_DBG_LABEL[80 + $i] = GUICtrlCreateLabel("", 50 + Mod($i, 2) * 180, 195 + 16 * Int($i / 2), 100, 16) $_DBG_LABEL[30 + $i] = GUICtrlCreateLabel("XMM" & $i & " = ", 10, 400 + 15 * $i, 40, 16);XMM0-XMM7 $_DBG_LABEL[90 + $i] = GUICtrlCreateLabel("", 60, 400 + 15 * $i, 300, 16);XMM $_DBG_LABEL[40 + $i] = GUICtrlCreateLabel("", 60, 32 + 16 * $i, 400, 16);hex $_DBG_LABEL[50 + $i] = GUICtrlCreateLabel("", 150, 32 + 16 * $i, 400, 16);int $_DBG_LABEL[60 + $i] = GUICtrlCreateLabel("", 230, 32 + 16 * $i, 300, 16);float $_DBG_LABEL[70 + $i] = GUICtrlCreateLabel("", 320, 32 + 16 * $i, 240, 16);bin $_DBG_LABEL[100 + $i] = GUICtrlCreateLabel("", 610, 32 + 16 * $i, 40, 16) ;eflags $_DBG_LABEL[110 + $i] = GUICtrlCreateLabel("", 280, 400 + 15 * $i, 250, 16);XMM-2xdouble $_DBG_LABEL[120 + $i] = GUICtrlCreateLabel("", 440, 400 + 15 * $i, 250, 16);XMM-4xfloat Next GUICtrlSetPos($_DBG_LABEL[105], 590, 32 + 16 * 5, 1, 1) ;platz machen für ungenutztes label $_DBG_LABEL[20] = GUICtrlCreateLabel("FPU-Flags", 10, 270, 55, 16) GUICtrlSetFont(-1, -1, -1, 4) $_DBG_LABEL[21] = GUICtrlCreateLabel("CO= C1= C2=", 520, 200, 135, 20) $_DBG_LABEL[25] = GUICtrlCreateLabel("Stack", 370, 175, 130, 20) GUICtrlSetFont(-1, -1, -1, 4) $_DBG_LABEL[26] = GUICtrlCreateLabel("HEX", 450, 175, 130, 20) GUICtrlSetFont(-1, -1, -1, 4) $_DBG_LABEL[27] = GUICtrlCreateLabel("INT", 550, 175, 130, 20) GUICtrlSetFont(-1, -1, -1, 4) For $i = 40 To 0 Step -4 $_DBG_LABEL[129 + $i / 4] = GUICtrlCreateLabel(StringFormat("[esp %+02.2d]", 40 - $i), 370, 195 + 16 * $i / 4, 50, 16);129-140 $_DBG_LABEL[141 + $i / 4] = GUICtrlCreateLabel("", 450, 195 + 16 * $i / 4, 100, 16);141-152 $_DBG_LABEL[155 + $i / 4] = GUICtrlCreateLabel("", 550, 195 + 16 * $i / 4, 100, 16);155-161 Next $_DBG_LABEL[108] = GUICtrlCreateLabel("SSE-Register HEX", 10, 375, 150, 20) GUICtrlSetFont(-1, -1, -1, 4) $_DBG_LABEL[109] = GUICtrlCreateLabel("2x Double", 280, 375, 100, 20) GUICtrlSetFont(-1, -1, -1, 4) $_DBG_LABEL[118] = GUICtrlCreateLabel("4x Float", 450, 375, 100, 20) GUICtrlSetFont(-1, -1, -1, 4) ;GUIRegisterMsg($WM_COMMAND, "MyWM_COMMAND") Global $listviewitem_reg32[8] Global $reg_32[8] = ["EAX", "EBX", "ECX", "EDX", "ESI", "EDI", "ESP", "EBP"] Global $Listview_reg32 = GUICtrlCreateListView("REG32|HEX|INT|FLOAT|BIN [BIT31....Bit0]", 10, 2, 560, 172, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOSORTHEADER));,$GUI_BKCOLOR_LV_ALTERNATE ) GUICtrlSetFont(-1, 8.5, -1, -1) GUICtrlSetBkColor($Listview_reg32, 0xF0f0f0) ; Grau GUICtrlSetBkColor($Listview_reg32, $GUI_BKCOLOR_LV_ALTERNATE) _GUICtrlListView_BeginUpdate($Listview_reg32) For $i = 0 To 7 $listviewitem_reg32[$i] = GUICtrlCreateListViewItem($reg_32[$i] & "|0xDDDDDDDD|88888888888|9.99999999E999|00000000 00000000 00000000 00000000 ", $Listview_reg32) GUICtrlSetBkColor($listviewitem_reg32[$i], 0xFFFFFF) ; weiss Next For $i = 0 To 4 _GUICtrlListView_SetColumnWidth($Listview_reg32, $i, $LVSCW_AUTOSIZE_USEHEADER);$LVSCW_AUTOSIZE) Next _GUICtrlListView_EndUpdate($Listview_reg32) ;thx progandy für den "button" ! Global Const $tagDLGTEMPLATE = "align 2 ;DWORD style; DWORD dwExtendedStyle; WORD cdit; short x; short y; short cx; short cy;" Global Const $tagDLGITEMTEMPLATE = "align 2 ;DWORD style; DWORD dwExtendedStyle; short x; short y; short cx; short cy; WORD id;" Global $_DBG_noshowflag = 0 Global $dlgproc = DllCallbackRegister("_DlgProc", "bool", "hwnd;uint;wparam;lparam") Global $_DBG_ = DllCallbackRegister("_DBG_MSGBOX", "dword", "dword;dword;dword;dword;dword;dword;dword;dword;dword") ;speicher reservieren für datenbereich Global $ptr_dbgmem = Number(_MemGlobalAlloc(600, 0)) ;512 byte + 8 byte weil nur 8byte-align Local $mod = Mod($ptr_dbgmem, 16) ;benötigt wird für SSE-Register abe 16-byte-align If $mod <> 0 Then $ptr_dbgmem += (16 - $mod) ;16 byte align EndIf Global $_dbg_string[100], $_DBG_nr = 0, $_DBG_command[2] Global $struct_FXSAVE = DllStructCreate("byte[512]", $ptr_dbgmem);platz für Daten aus FXSAVE Global $struct_STACK = DllStructCreate("dword[11]", $ptr_dbgmem + 520);platz für Daten aus STACK [esp-20] bis [esp+20] Global $ptr_STACK = DllStructGetPtr($struct_STACK) ;http://siyobik.info/index.php?module=x86&id=128 ;ob ich diese flags noch einbaue, weiss ich nicht Local $struct = DllStructCreate("" & _ "word FCW;" & _ ;FPU control word 0+1 "word FSW;" & _ ;FPU statusword 2+3 "byte FTW;" & _ ;FPU ag word 4 "byte;" & _ ;reserved 5 "word FOP;" & _ ;FPU opcode 6+7 "dword FIP;" & _ ;FPU instruction pointer 8-11 "word CS;" & _ ; 12-13 "word ;" & _ ;reserved 14-15 "dword FDP;" & _ ; 16-19 "word DS;" & _ ; 20+21 "word ;" & _ ;reserved 22-23 "dword MXCSR;" & _ ;MXCSR 24-27 "dword MXCSR_MASK;" & _ ;MXCSR_MASK 28-31 "byte[10] ST0;") ;ST0 32-41 Global $struct_double = DllStructCreate("double[8]") ;platz für 8 doubles der FPU register st0-st7 Global $struct_128SSE = DllStructCreate("byte[128]", Ptr($ptr_dbgmem + 160));platz für 16 byte SSE Global $struct_EFLAGS = DllStructCreate("dword EFLAGS", Ptr($ptr_dbgmem + 512));platz 32 bit eflags Global $ptr_SSE = DllStructGetPtr($struct_128SSE) ;pointer Global $ptr_EFLAGS = DllStructGetPtr($struct_EFLAGS) Global $struct_SSE64x2int = DllStructCreate("uint64[16]", $ptr_SSE) ;platz für 2x 64byte SSE Global $struct_SSE32x4int = DllStructCreate("uint[32]", $ptr_SSE) ;platz für 4x 32byte SSE Global $struct_SSE16x8int = DllStructCreate("word[64]", $ptr_SSE) ;platz für 8x 16byte SSE Global $struct_SSE64x2dbl = DllStructCreate("double[16]", $ptr_SSE) ;platz für 2x 64byte DOUBLE SSE Global $struct_SSE32x4flt = DllStructCreate("float[32]", $ptr_SSE) ;platz für 4x 32byte FLOAT SSE ;debug-funktion, aus dem asmcode per call an die callback-adresse aufgerufen Func _DBG_MSGBOX($anz, $edi, $esi, $ebp, $esp, $ebx, $edx, $ecx, $eax);aus asm übergebene register If $_DBG_noshowflag = 1 Then Return 0 GUISetState(@SW_SHOW, $_DBG_GUI) _WinAPI_UpdateWindow($_DBG_GUI) ;_DBG_WM_SIZE($_DBG_GUI,0,0,0) Dim $reg[8] = [$eax, $ebx, $ecx, $edx, $esi, $edi, $esp, $ebp] _GUICtrlListView_BeginUpdate($Listview_reg32) For $i = 0 To 7 ;fenster mit Werten füllen GUICtrlSetData($listviewitem_reg32[$i], "|" & Ptr($reg[$i]) & "|" & _ String($reg[$i]) & "|" & _ StringFormat(" %2.6G", int2float($reg[$i])) & "|" & int2bin($reg[$i])) ;hex GUICtrlSetData($_DBG_LABEL[$i + 80], DllStructGetData($struct_double, 1, $i + 1));FPU st0-st7 ;SSE $struct_temp = DllStructCreate("byte[16]", $ptr_SSE + 16 * $i) $struct = DllStructCreate("byte[16]") For $z = 1 To 16 DllStructSetData($struct, 1, DllStructGetData($struct_temp, 1, 17 - $z), $z) Next GUICtrlSetData($_DBG_LABEL[$i + 90], DllStructGetData($struct, 1)) GUICtrlSetData($_DBG_LABEL[$i + 100], BitAND(2 ^ $i, DllStructGetData($struct_EFLAGS, 1)) / (2 ^ $i));eflags $struct = DllStructCreate("double[2]", $ptr_SSE + 16 * $i); 2x 64byte DOUBLE SSE GUICtrlSetData($_DBG_LABEL[$i + 110], StringFormat("%6s %6s", DllStructGetData($struct, 1, 2), DllStructGetData($struct, 1, 1))) $struct = DllStructCreate("float[4]", $ptr_SSE + 16 * $i); 4x 32byte FLOAT SSE GUICtrlSetData($_DBG_LABEL[$i + 120], StringFormat("%10.5f %10.5f %10.5f %10.5f", DllStructGetData($struct, 1, 4), DllStructGetData($struct, 1, 3), DllStructGetData($struct, 1, 2), DllStructGetData($struct, 1, 1))) Next GUICtrlSetData($_DBG_LABEL[101], BitAND(2 ^ 10, DllStructGetData($struct_EFLAGS, 1)) / (2 ^ 10));eflags DF GUICtrlSetData($_DBG_LABEL[103], BitAND(2 ^ 11, DllStructGetData($struct_EFLAGS, 1)) / (2 ^ 11));eflags OF For $i = 0 To 10 ;stack GUICtrlSetData($_DBG_LABEL[141 + $i], Ptr(DllStructGetData($struct_STACK, 1, $i + 1)));stack hex GUICtrlSetData($_DBG_LABEL[155 + $i], Int(DllStructGetData($struct_STACK, 1, $i + 1)));stack int Next _GUICtrlListView_EndUpdate($Listview_reg32) If $anz = 0 Or Execute($_dbg_string[$anz]) Then Switch __GET_MSGBOX_BUTTON() Case 0, 1 Case 2 $_DBG_noshowflag = True Case 3 DllCall("kernel32.dll", "none", "ExitProcess", "int", 0xDEADBEEF) EndSwitch EndIf Return 0 EndFunc ;==>_DBG_MSGBOX Func __GET_MSGBOX_BUTTON() Local Static $tDLG, $aOldPos[4] = [0, 0, -1, -1] Local $pos_DBB_Window = WinGetPos($_DBG_GUI) ;Positionsdaten der GUI holen If $aOldPos[0] <> $pos_DBB_Window[0] Or $aOldPos[1] <> $pos_DBB_Window[1] Or $aOldPos[2] <> $pos_DBB_Window[2] Or $aOldPos[2] <> $pos_DBB_Window[2] Then $aOldPos = $pos_DBB_Window Local $x = Int($pos_DBB_Window[0] / 2) Local $y = Int(($pos_DBB_Window[1] + $pos_DBB_Window[3]) / 2) ;es folgen die Daten für den "...NEXT"-Button, der muss ein modales Fenster sein, wer da eine andere Idee hat, bitte melden Local $w = Int($pos_DBB_Window[2] / 2) ;breite Button Local $h = 30 ;höhe Button Local $bTitle = StringToBinary("Next....", 2) ;text Button Local $bXY = BinaryMid(Binary($x), 1, 2) & BinaryMid(Binary($y), 1, 2);Buttondaten Local $bWH = BinaryMid(Binary($w), 1, 2) & BinaryMid(Binary($h), 1, 2) Local $bWhalfH = BinaryMid(Binary(Int($w / 2 - 15)), 1, 2) & BinaryMid(Binary($h), 1, 2) Local $bDIALOG = Binary("0x00000090400000040300") & $bXY & $bWH & Binary("0x000000000000") & Binary("0x000000500000000000000000") & $bWhalfH & Binary("0x0100FFFF8000") & $bTitle & Binary("0x0000") & Binary("0x0000") ; |Style ||ExStyl||cdit| |Empty "Arrays"| |Style ||ExStyl||x ||y | |id||BUTTON| |Chr0| |irgend welche anderen Arrays $x = Mod(BinaryLen($bDIALOG), 4) If $x Then $bDIALOG &= BinaryMid(Binary("0x000000"), 1, $x) $bTitle = StringToBinary("End Debugging", 2) ;text Button $bDIALOG &= Binary("0x0000005000000000") & BinaryMid(Int($w / 2 - 15), 1, 2) & Binary("0x0000") & $bWhalfH & Binary("0x0200FFFF8000") & $bTitle & Binary("0x0000") & Binary("0x0000") $x = Mod(BinaryLen($bDIALOG), 4) If $x Then $bDIALOG &= BinaryMid(Binary("0x000000"), 1, $x) $bTitle = StringToBinary("Kill", 2) ;text Button $bDIALOG &= Binary("0x0000005000000000") & BinaryMid(Int($w - 30), 1, 2) & Binary("0x0000") & BinaryMid(30, 1, 2) & BinaryMid($h, 1, 2) & Binary("0x0300FFFF8000") & $bTitle & Binary("0x0000") & Binary("0x0000") $tDLG = DllStructCreate("byte[" & BinaryLen($bDIALOG) & "]") DllStructSetData($tDLG, 1, $bDIALOG) ;Button-Daten in struct schreiben EndIf Local $aRet = DllCall("user32.dll", "int", "DialogBoxIndirectParamW", "ptr", 0, "ptr", DllStructGetPtr($tDLG), "hwnd", 0, "ptr", DllCallbackGetPtr($dlgproc), "lparam", 0) If @error Then Return 0 Return $aRet[0] EndFunc ;==>__GET_MSGBOX_BUTTON ;Alle Register, Flags, Stack usw werden in einen Speicherbereich geschrieben und von dort mit ;der Funktion _DBG_MSGBOX() ausgelesen Func _asmdbg_($_DBG_command = "") ;Register _("push dword[esp+40]") ;stack in memory _("pop dword[" & $ptr_STACK & "]") _("push dword[esp+36]") ;stack in memory _("pop dword[" & $ptr_STACK + 4 & "]") _("push dword[esp+32]") ;stack in memory _("pop dword[" & $ptr_STACK + 8 & "]") _("push dword[esp+28]") ;stack in memory _("pop dword[" & $ptr_STACK + 12 & "]") _("push dword[esp+24]") ;stack in memory _("pop dword[" & $ptr_STACK + 16 & "]") _("push dword[esp+20]") ;stack in memory _("pop dword[" & $ptr_STACK + 20 & "]") _("push dword[esp+16]") ;stack in memory _("pop dword[" & $ptr_STACK + 24 & "]") _("push dword[esp+12]") ;stack in memory _("pop dword[" & $ptr_STACK + 28 & "]") _("push dword[esp+08]") ;stack in memory _("pop dword[" & $ptr_STACK + 32 & "]") _("push dword[esp+04]") ;stack in memory _("pop dword[" & $ptr_STACK + 36 & "]") _("push dword[esp+00]") ;stack in memory _("pop dword[" & $ptr_STACK + 40 & "]") _("pushfd") ;eflags sichern _("pop dword[" & Ptr($ptr_EFLAGS) & "]") ;eflags speichern in struct _("pushfd") ;eflags sichern _("push eax") _("mov eax," & $ptr_dbgmem) ;alle FPU+SSE Registerinhalte und flags sichern _("FXSAVE [eax]") _("fstp qword[" & DllStructGetPtr($struct_double) & "]") ;alle FPU-Register sichern _("fstp qword[" & DllStructGetPtr($struct_double) + 8 & "]") _("fstp qword[" & DllStructGetPtr($struct_double) + 16 & "]") _("fstp qword[" & DllStructGetPtr($struct_double) + 24 & "]") _("fstp qword[" & DllStructGetPtr($struct_double) + 32 & "]") _("fstp qword[" & DllStructGetPtr($struct_double) + 40 & "]") _("fstp qword[" & DllStructGetPtr($struct_double) + 48 & "]") _("fstp qword[" & DllStructGetPtr($struct_double) + 56 & "]") ; _("fwait") _("pop eax") _("pushad") ;alle Register sichern _("pushad") ;auf den stack für für die msgbox If $_DBG_command <> "" Then ;falls kein Befehl übergeben wurde $_DBG_nr += 1 $_dbg_string[$_DBG_nr] = $_DBG_command _("push " & Ptr($_DBG_nr)) ;anzahl der Else _("push " & Ptr(0)) EndIf _("call " & DllCallbackGetPtr($_DBG_)) ;in autoit-callbackroutine springen _("mov eax," & $ptr_dbgmem) ;alle FPU+SSE registerinhalte und flags restore _("FXRSTOR [eax]") ;restore alle FPU-Register ; _("fwait") _("popad") ;alle register wieder zurücksetzen _("popfd") ;eflags setzen EndFunc ;==>_asmdbg_ Func bin2ascii($bin_string) ;string aus nullen und einsen in 8-bit-ascii text string umwandeln Local $step = 8 ;8-Bit ASCII Buchstaben Local $ascii_string = "" ;Rückgabestring For $f = 1 To StringLen($bin_string) Step $step ;string von Vorne nach hinten 8-bitweise durchsuchen Local $t = StringMid($bin_string, $f, $step) ; 8-Bit-Wort, ein ASCII-Buchstabe Local $bin = 0 ;startwert für For $i = 1 To $step ;jedes Bit suchen If StringMid($t, $i, 1) = "1" Then $bin += (2 ^ ($step - $i)) ;wenn Bit=1 dann binärzahl=binärzahl+2^(8-Bitposition) Next $ascii_string &= Chr($bin) Next Return $ascii_string EndFunc ;==>bin2ascii Func int2bin($integer) ;32Bit in binärstring darstellen Local $bin_string = "" For $i = 31 To 0 Step -1 ;asciicode in bits If Mod($i + 1, 8) = 0 Then $bin_string &= " " If BitAND($integer, 2 ^ $i) Then $bin_string &= "1" Else $bin_string &= "0" EndIf Next Return $bin_string EndFunc ;==>int2bin Func int2float($integer) Local $struct = DllStructCreate("int") Local $struct2 = DllStructCreate("float", DllStructGetPtr($struct)) DllStructSetData($struct, 1, $integer) Local $ret = DllStructGetData($struct2, 1) $struct = 0 $struct2 = 0 Return $ret EndFunc ;==>int2float Func _DlgProc($hwnd, $uMsg, $wParam, $lParam) ;thx to progandy! If $uMsg = $WM_INITDIALOG Then $_DBG_BUTTONSGUI = $hwnd ElseIf $uMsg = $WM_CLOSE Then DllCall("user32.dll", "bool", "EndDialog", "hwnd", $hwnd, "int_ptr", 0) Return True ElseIf $uMsg = $WM_COMMAND Then DllCall("user32.dll", "bool", "EndDialog", "hwnd", $hwnd, "int_ptr", BitAND($wParam, 0xFFFF)) Return True ElseIf $uMsg = $WM_DESTROY Then $_DBG_BUTTONSGUI = -1 EndIf Return False EndFunc ;==>_DlgProc Func _DBG_WM_MOVING($hwnd, $uMsg, $wParam, $lParam) If $hwnd = $_DBG_GUI And IsHWnd($_DBG_BUTTONSGUI) Then Local $pos = WinGetPos($hwnd) WinMove($_DBG_BUTTONSGUI, "", $pos[0], $pos[1] + $pos[3]) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_DBG_WM_MOVING Func _DBG_WM_SIZE($hwnd, $message, $wParam, $lParam);fenstergrösse wird verändert Local $posgui = WinGetPos($_DBG_GUI) $_DBG_Window_posold_x = $posgui[0] ;fensterposition merken $_DBG_Window_posold_y = $posgui[1] ;WinMove($hwnd_weiterbutton, "", $pos[0], $pos[1] + $pos[3], 200, 60);buttonposition anpassen WinMove($hwnd_weiterbutton, "", $posgui[0], $posgui[1] + $posgui[3], $posgui[2], 60);fensterposition anpassen WinMove($_DBG_GUI, "", $posgui[0], $posgui[1], $posgui[2], $posgui[3]);fensterposition anpassen _WinAPI_SetWindowPos($_DBG_buttonID, 0, 0, 0, $posgui[2], 60, 0x0020);buttonpos im fenster resze EndFunc ;==>_DBG_WM_SIZE You can use also different inline assembler UDFs, e.g. Extended Flat Assembler (by Beege) or the originaly by Ward The Embedded Flat Assembler (FASM) UDF
Without the help of AndyG and Eukalyptus I wouldn't be able to create ASM code - many thanks!!!
Many thanks dudes - you rock!
I'm a novice in assembler coding - please don't blame me.
Feel free to post your snippets here!
Categories
String
_ASM_StringLFCharCount (counts the line feeds within a string)
_ASM_StringReplaceWChar (replaces a unicode char within a string)
_StringReverse / _StringReverse2 (reverse a string coded by AndyG)
Graphic
_ASM_DrawRectFilled (draws a filled rectangle)
_ASM_ImageInvert (inverts (negative) an image)
_ASM_BitmapCreateBitmapWithAlpha (merges an image with an alpha blend image)
_ASM_ImageCreateNegativeMMX (inverts (negative) an image using MMX)
_ASM_DrawLineUsingGDIPlus (draws a line using the GDIPlus lib)
_ASM_BitCompareBitmapsMMX (bitwise bitmap compare)
_ASM_BitmapGetAverageColorValue / _ASM64_BitmapGetAverageColorValue.au3 (gets the average color of a bitmap)
-
gcue reacted to Andreik in Rewrite of the PowerPoint UDF
I can live with manual downloading of UDF to gain the advantage of quick fixes. Thank you for clarification.
-
gcue reacted to mikell in trying to first and last name only
or this
;$string = "bob smith cima, phd, ma" $string = "brian o'connor cima, phd, ma" $res = StringRegExpReplace($string, '^([[:alpha:]'']+) ((?1)).*', "$2, $1") MsgBox(0,'', $res)
-
gcue got a reaction from water in OutlookEX UDF - Help & Support (IV)
i figured out the issue. the email had a png file for the signature. was saving that with the zip file name. doh! thought id follow up in case anyone else had the same issue.
-
gcue reacted to Danyfirex in Best way to use google image search? [SOLVED]
An alternative way without using IE.
#include <Array.au3> #include <String.au3> Global Const $HTTP_STATUS_OK = 200 Local $sKeyWord = "house" Local $sURL = "http://www.google.com/search?q=" & $sKeyWord & "&tbm=isch" Local $sData = HttpGet($sURL) ;~ ConsoleWrite($sData & @CRLF) Local $aMetas = _StringBetween($sData, '"rg_meta">', '</div>') ;~ _ArrayDisplay($aMetas) Local $sUrlImage = "" Local $sImageName = "" Local $sExtension = "" If IsArray($aMetas) Then If UBound($aMetas) >= 5 Then For $i = 0 To 4 ConsoleWrite(">Image Number: " & $i + 1 & @CRLF) $sUrlImage = _GetImageUrl($aMetas[$i]) $sImageName = _GetImageName($aMetas[$i]) ;maybe you want to get the name from image url instead of metadata $sExtension = _GetImageExtension($aMetas[$i]) ConsoleWrite($sUrlImage & @CRLF) ConsoleWrite($sImageName & @CRLF) ConsoleWrite($sExtension & @CRLF) ConsoleWrite(@CRLF) Next EndIf EndIf Func _GetImageName($sData) Local $aData = _StringBetween($sData, '"s":"', '"') If IsArray($aData) Then Return $aData[0] EndFunc ;==>_GetImageName Func _GetImageUrl($sData) Local $aData = _StringBetween($sData, '"ou":"', '"') If IsArray($aData) Then Return $aData[0] EndFunc ;==>_GetImageUrl Func _GetImageExtension($sData) Local $aData = _StringBetween($sData, '"ity":"', '"') If IsArray($aData) Then Return $aData[0] EndFunc ;==>_GetImageExtension Func HttpGet($sURL) Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", $sURL, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0") $oHTTP.SetRequestHeader("Content-Type", "text/plain; charset=utf-8") If (@error) Then Return SetError(1, 0, 0) $oHTTP.Send() If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc ;==>HttpGet Make sure to clean up the file name.
Saludos
-
gcue reacted to GaryFrost in Move MsgBox (/AutoIt3ExecuteScript)
; InputBox OnTop ; Author - herewasplato $ans = _InputBoxOnTop("Title", "Prompt") If @error = 0 Then MsgBox(0, "Returned", $ans) If @error = 1 Then MsgBox(0, "", "The Cancel button was pushed.") If @error = 2 Then MsgBox(0, "", "The Timeout time was reached.") If @error = 3 Then MsgBox(0, "", "The InputBox failed to open.") Func _InputBoxOnTop($IBTitle, $IBPrompt, $IBDefault = "", _ $IBpassword_char = "", $IBWidth = -1, $IBHeight = -1, _ $IBLeft = Default, $IBTop = Default, $IBTimeOut = "") Local $file = FileOpen(EnvGet("temp") & "\InputBoxOT.au3", 2) If $file = -1 Then Return;if error, give up Local $line1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')' Local $line2 = 'WinWait("' & $IBTitle & '", "' & $IBPrompt & '")' Local $line3 = 'WinSetOnTop("' & $IBTitle & '", "' & $IBPrompt & '" ,1)' FileWrite($file, $line1 & @CRLF & $line2 & @CRLF & $line3) FileClose($file) Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\InputBoxOT.au3") Local $ans = InputBox($IBTitle, $IBPrompt, $IBDefault, _ $IBpassword_char, $IBWidth, $IBHeight, _ $IBLeft, $IBTop, $IBTimeOut) If @error Then $ans = @error While Not FileDelete(EnvGet("temp") & "\InputBoxOT.au3") Sleep(10) WEnd SetError($ans) $ans = "" Return $ans EndIf While Not FileDelete(EnvGet("temp") & "\InputBoxOT.au3") Sleep(10) WEnd Return ($ans) EndFunc ;==>_InputBoxOnTop -
gcue got a reaction from Gianni in DateDiff_WorkDaysOnly
Thought I'd share this snippet I created based off jdelaney's post
Calculates date in the past based off of only work days (ie: a week of just workdays). Any feedback welcome
$start_date = "2023/03/27" $weekdays_ago = 2 $date = DateDiff_WeekDaysOnly($start_date, $weekdays_ago) Func DateDiff_WeekDaysOnly($start_date, $weekdays_ago) $weekdays = 0 $days_reduce = 0 While $weekdays <> $weekdays_ago $days_reduce -= 1 $running_date = _DateAdd("d", $days_reduce, $start_date) $aTemp = StringSplit($running_date, "/") $iDate = _DateToDayOfWeek($aTemp[1], $aTemp[2], $aTemp[3]) If $iDate <> 1 And $iDate <> 7 Then $weekdays += 1 EndIf WEnd $date_desired = _DateAdd("d", $days_reduce, $start_date) Return $date_desired EndFunc ;==>DateDiff_WeekDaysOnly
-
gcue got a reaction from Skeletor in DateDiff_WorkDaysOnly
Thought I'd share this snippet I created based off jdelaney's post
Calculates date in the past based off of only work days (ie: a week of just workdays). Any feedback welcome
$start_date = "2023/03/27" $weekdays_ago = 2 $date = DateDiff_WeekDaysOnly($start_date, $weekdays_ago) Func DateDiff_WeekDaysOnly($start_date, $weekdays_ago) $weekdays = 0 $days_reduce = 0 While $weekdays <> $weekdays_ago $days_reduce -= 1 $running_date = _DateAdd("d", $days_reduce, $start_date) $aTemp = StringSplit($running_date, "/") $iDate = _DateToDayOfWeek($aTemp[1], $aTemp[2], $aTemp[3]) If $iDate <> 1 And $iDate <> 7 Then $weekdays += 1 EndIf WEnd $date_desired = _DateAdd("d", $days_reduce, $start_date) Return $date_desired EndFunc ;==>DateDiff_WeekDaysOnly
-
gcue got a reaction from Skeletor in DateDiff_WorkDaysOnly
i had it like that originally. I just changed it to manual values so i can test with different dates
thx
-
gcue got a reaction from argumentum in how to pass a multi-line data value or JSON with curl?
that worked! hardcoding the json AND replacing the file contents like this...
$txt_file = "file.txt" $txt_query = FileRead($txt_file) $txt_query = StringStripWS($txt_query, 8) $txt_query = StringReplace($txt_query, '"', '\"') $iPID = Run(@ComSpec & ' /c curl.exe --header "accept:application/json" --data "' & $txt_query & '"', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) thank youuuuu!!!!
-
gcue got a reaction from Parsix in change date taken (file property) from an image
sure thing
#include <array.au3> #include <GDIPlus.au3> #include <file.au3> $msg_normal = 0 Global Const $PropertyTagTypeByte = 1 Global Const $PropertyTagTypeASCII = 2 Global Const $PropertyTagTypeShort = 3 Global Const $PropertyTagTypeLong = 4 Global Const $PropertyTagTypeRational = 5 Global Const $PropertyTagTypeUndefined = 7 Global Const $PropertyTagTypeSLong = 9 Global Const $PropertyTagTypeSRational = 10 _GDIPlus_Startup() $dir = "C:\Users\Me\Desktop\Halloween" $date_time = "2015:10:29 09:00:00" $array = _FileListToArrayRec($dir, "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT, $FLTAR_FULLPATH) For $x = 1 To UBound($array) - 1 $original_file = $array[$x] $file_name_extension = StringRegExpReplace($original_file, "^.*\\", "") $file_path_dir = StringReplace($original_file, "\" & $file_name_extension, "") $file_name = _GetFileName($original_file) $file_extension = _GetFileExtension($file_name_extension) $temp_file = $file_path_dir & "\" & $file_name & "_TMP." & $file_extension $hFile = _GDIPlus_ImageLoadFromFile($original_file) _GDIPlus_SetMetaData($hFile, "DateTimeOriginal", $date_time) _GDIPlus_ImageSaveToFile($hFile, $temp_file) _GDIPlus_ImageDispose($hFile) FileMove($temp_file, $original_file, 1) Next _GDIPlus_Shutdown() Func _GDIPlus_SetMetaData($hHandle, $sTagName, $vStr) Local $tagPropertyItem = "ulong id; ulong length; ushort Type; ptr value" Local $Struct_String, $Struct_Meta, $aResult, $PropertyTagType Switch $sTagName Case "ImageWidth" $ID = 0x100 $PropertyTagType = $PropertyTagTypeShort Case "ImageLength" $ID = 0x101 $PropertyTagType = $PropertyTagTypeShort Case "BitsPerSample" $ID = 0x102 $PropertyTagType = $PropertyTagTypeShort Case "Compression" $ID = 0x103 $PropertyTagType = $PropertyTagTypeShort Case "PhotometricInterpretation" $ID = 0x106 $PropertyTagType = $PropertyTagTypeShort Case "Orientation" $ID = 0x112 $PropertyTagType = $PropertyTagTypeShort Case "SamplesPerPixel" $ID = 0x115 $PropertyTagType = $PropertyTagTypeShort Case "PlanarConfiguration" $ID = 0x11C $PropertyTagType = $PropertyTagTypeShort Case "YCbCrSubSampling" $ID = 0x212 $PropertyTagType = $PropertyTagTypeShort Case "YCbCrPositioning" $ID = 0x213 $PropertyTagType = $PropertyTagTypeShort Case "XResolution" $ID = 0x11A $PropertyTagType = $PropertyTagTypeRational Case "YResolution" $ID = 0x11B $PropertyTagType = $PropertyTagTypeRational Case "ResolutionUnit" $ID = 0x296 $PropertyTagType = $PropertyTagTypeShort Case "StripOffsets" $ID = 0x111 $PropertyTagType = $PropertyTagTypeShort Case "RowsPerStrip" $ID = 0x116 $PropertyTagType = $PropertyTagTypeShort Case "StripByteCounts" $ID = 0x117 $PropertyTagType = $PropertyTagTypeShort Case "JPEGInterchangeFormat" $ID = 0x201 $PropertyTagType = $PropertyTagTypeLong Case "JPEGInterchangeFormatLength" $ID = 0x202 $PropertyTagType = $PropertyTagTypeLong Case "TransferFunction" $ID = 0x12D $PropertyTagType = $PropertyTagTypeShort Case "WhitePoint" $ID = 0x13E $PropertyTagType = $PropertyTagTypeRational Case "PrimaryChromaticities" $ID = 0x13F $PropertyTagType = $PropertyTagTypeRational Case "YCbCrCoefficients" $ID = 0x211 $PropertyTagType = $PropertyTagTypeRational Case "ReferenceBlackWhite" $ID = 0x214 $PropertyTagType = $PropertyTagTypeRational Case "DateTimeOriginal" $ID = 0x9003 $PropertyTagType = $PropertyTagTypeASCII Case "DateTime" $ID = 0x132 $PropertyTagType = $PropertyTagTypeASCII Case "ImageDescription" $ID = 0x10E $PropertyTagType = $PropertyTagTypeASCII Case "Make" $ID = 0x10F $PropertyTagType = $PropertyTagTypeASCII Case "Model" $ID = 0x110 $PropertyTagType = $PropertyTagTypeASCII Case "Software" $ID = 0x131 $PropertyTagType = $PropertyTagTypeASCII Case "Artist", "Author" $ID = 0x13B $PropertyTagType = $PropertyTagTypeASCII Case "Copyright" $ID = 0x8298 $PropertyTagType = $PropertyTagTypeASCII Case Else Return SetError(1, -1, False) EndSwitch ; Store string in array $Struct_String = DllStructCreate("char[" & StringLen($vStr) + 1 & "];") DllStructSetData($Struct_String, 1, $vStr) $Struct_Meta = DllStructCreate($tagPropertyItem) DllStructSetData($Struct_Meta, "ID", $ID) DllStructSetData($Struct_Meta, "Length", StringLen($vStr) + 1) DllStructSetData($Struct_Meta, "Type", $PropertyTagType) DllStructSetData($Struct_Meta, "Value", DllStructGetPtr($Struct_String)) $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPropertyItem", "hwnd", $hHandle, "ptr", DllStructGetPtr($Struct_Meta)) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetMetaData Func _GetFileName($sFile) $file_name_extension = StringRegExpReplace($sFile, "^.*\\", "") $file_extension = StringRegExpReplace($file_name_extension, "^.*\.", "") $file_name = StringReplace($file_name_extension, "." & $file_extension, "") Return $file_name EndFunc ;==>_GetFileName Func _GetFileExtension($sFile) Return StringRegExpReplace($sFile, "^.*\.", "") EndFunc ;==>_GetFileExtension Func Debug($variable1 = "", $variable2 = "", $variable3 = "", $variable4 = "") ;~ #include <array.au3> ;~ $msg_normal = 0 If IsArray($variable1) Then _ArrayDisplay($variable1) Else If $variable2 <> "" Then $variable1 &= @CRLF & $variable2 EndIf If $variable3 <> "" Then $variable1 &= @CRLF & $variable3 EndIf If $variable4 <> "" Then $variable1 &= @CRLF & $variable4 EndIf ClipPut($variable1) MsgBox($msg_normal, "Debug", $variable1) EndIf EndFunc ;==>Debug
-
gcue got a reaction from jay97 in get variable name
hello =)
is there any way to get a variable's name as it is passed through a function?
ie:
$final_result = "4652" Get_Variable($final_result) Func Get_Variable($variable="") Endfunc how do i get "$final_result"?
i know Get_Variable("$final_result", $final_result) would give me both the variable name and value but i'm trying to see if there's another way
thanks in advance!
-
gcue reacted to michaelslamet in _FileInUse to check if file is in used or not (work on both local and network drive)
This is my first thread in Example, so please easy with me
I found a function by Rogue5099 to check if a file is in used or not, but it only working great when
checking a file in local drive. I make a little change so it can also report a correct "file in used" status
for files that on network.
I hope this script can benefit for every of us
$fFile = "c:\myscript.exe" If _FileInUse($fFile) = 0 then Msgbox(64, "Info", $fFile & " is NOT in used") Else Msgbox(64, "Info", $fFile & " is in used") EndIf ;=============================================================================== ; ; Function Name: _FileInUse() ; Description: Checks if file is in use ; Parameter(s): $sFilename = File name ; Return Value(s): 1 - file in use (@error contains system error code) ; 0 - file not in use or file not exists ; Create by: Rogue5099 ; Modified by: michaelslamet ; ;=============================================================================== Func _FileInUse($sFilename) ;note: dword", 0x40000000, _ ---> jalan bagus jika $sFilename ada di hdd local, tapi jika $sFilename ada di network drive, gunakan dword", 0x80000000, _ Local $aRet, $hFile If StringUpper(DriveGetType($sFilename)) = "NETWORK" Then $aRet = DllCall("Kernel32.dll", "hwnd", "CreateFile", _ "str", $sFilename, _ ;lpFileName "dword", 0x80000000, _ ;dwDesiredAccess = GENERIC_READ "dword", 0x00000004, _ ;dwShareMode = DO NOT SHARE "dword", 0, _ ;lpSecurityAttributes = NULL "dword", 3, _ ;dwCreationDisposition = OPEN_EXISTING "dword", 128, _ ;dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL "hwnd", 0) ;hTemplateFile = NULL Else $aRet = DllCall("Kernel32.dll", "hwnd", "CreateFile", _ "str", $sFilename, _ ;lpFileName "dword", 0x40000000, _ ;dwDesiredAccess = GENERIC_WRITE "dword", 0x00000004, _ ;dwShareMode = DO NOT SHARE "dword", 0, _ ;lpSecurityAttributes = NULL "dword", 3, _ ;dwCreationDisposition = OPEN_EXISTING "dword", 128, _ ;dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL "hwnd", 0) ;hTemplateFile = NULL EndIf If NOT FileExists($sFilename) Then Return 0 Else $hFile = $aRet[0] If $hFile = -1 Then ;INVALID_HANDLE_VALUE = -1 $aRet = DllCall("Kernel32.dll", "int", "GetLastError") SetError($aRet[0]) Return 1 Else ;close file handle DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return 0 EndIf EndIf EndFunc -
gcue reacted to Siao in Need help with copy verification
Forum is full of examples and UDFs of how to use DllCall, using Windows API too.
Anyway, here you go...
$file = "FileInUseTestfile.txt" $h = FileOpen($file, 1) $x = _FileInUse($file) MsgBox(0, "_FileInUse() example", "File "& $file & @CRLF & "Return= " & $x & " (Error = " & @error & ")") FileClose($h) $x = _FileInUse($file) MsgBox(0, "_FileInUse() example", "File "& $file & @CRLF & "Return= " & $x & " (Error = " & @error & ")") FileDelete($file) ;=============================================================================== ; ; Function Name: _FileInUse() ; Description: Checks if file is in use ; Parameter(s): $sFilename = File name ; Return Value(s): 1 - file in use (@error contains system error code) ; 0 - file not in use ; ;=============================================================================== Func _FileInUse($sFilename) Local $aRet, $hFile $aRet = DllCall("Kernel32.dll", "hwnd", "CreateFile", _ "str", $sFilename, _ ;lpFileName "dword", 0x80000000, _ ;dwDesiredAccess = GENERIC_READ "dword", 0, _ ;dwShareMode = DO NOT SHARE "dword", 0, _ ;lpSecurityAttributes = NULL "dword", 3, _ ;dwCreationDisposition = OPEN_EXISTING "dword", 128, _ ;dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL "hwnd", 0) ;hTemplateFile = NULL $hFile = $aRet[0] If $hFile = -1 Then ;INVALID_HANDLE_VALUE = -1 $aRet = DllCall("Kernel32.dll", "int", "GetLastError") SetError($aRet[0]) Return 1 Else ;close file handle DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return 0 EndIf EndFunc -
gcue reacted to rasim in check if file is open before FileMove()
cyanidemonkey
Try this:
Global Const $GENERIC_READ = 0x80000000 Global Const $GENERIC_WRITE = 0x40000000 Global Const $OPEN_EXISTING = 3 Global Const $FILE_ATTRIBUTE_NORMAL = 0x80 $file = "d:\Base\work.dat" If Not FileExists($file) Then Exit $hFile = DllCall("kernel32.dll", "hwnd", "CreateFile", _ "str", $file, _ "int", BitOR($GENERIC_READ, $GENERIC_WRITE), _ "int", 0, _ "ptr", 0, _ "int", $OPEN_EXISTING, _ "int", $FILE_ATTRIBUTE_NORMAL, _ "int", 0) If $hFile[0] = -1 Then MsgBox(48, "Warning", "File is open") Else DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile[0]) EndIf -
gcue reacted to Danny35d in Replace all NON "A-Z, a-z" characters inside a string
Try it:
$UserEnters = ' 1(2E[u]ro)p e' MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace($UserEnters, '[^a-zA-Z]|\W', '')) -
gcue reacted to rudi in Getting rid of special characters
Hi.
$RegExNonStandard="(?i)([^a-z0-9-_])" $Artist="Sean O’Daniels" $NameClean=StringRegExpReplace($Artist,$RegExNonStandard,"_") MsgBox(0,"Done",$Artist & @CRLF & $NameClean) Regards, Rudi.
-
gcue reacted to GMK in Read PDFs
$App = ObjCreate("AcroExch.App") ;; start Adobe Acrobat $App.Show ;; show Acrobat or comment out for hidden mode ;; actions $AVDoc = ObjCreate("AcroExch.AVDoc") ;; connect to Ac Viewer If $AVDoc.Open($FilePath,"") Then ;; open the file $PDDoc = $AVDoc.GetPDDoc ;; get PdDoc from AvDoc $JSO = $PDDoc.GetJSObject ;; get JS Object from PDDoc $test = $oJSO.GetField($fieldname).Value ;; get field value msgbox(0,"",$test) ;~ $PDDoc.save(1,$fileOut) ;~ $app.closeAlldocs() $app.exit() Else msgbox(0,"","Coudn't open report") endif ;; release objects $JSO = 0 $PdDoc = 0 $AvDoc = 0 $App = 0
-
gcue got a reaction from seadoggie01 in _ValidUserPass - when password has %
other passwords work fine. i do have the right password for sure
-
gcue reacted to Melba23 in Extracting just the filename and extension from a full path?
nf67,
Or you can use these SREs from Malkey to get various parts of the path directly:
Local $sFile = "C:\Program Files\Another Dir\AutoIt3\AutoIt3.chm" ; Drive letter - Example returns "C" Local $sDrive = StringRegExpReplace($sFile, ":.*$", "") ; Full Path with backslash - Example returns "C:\Program Files\Another Dir\AutoIt3\" Local $sPath = StringRegExpReplace($sFile, "(^.*\\)(.*)", "\1") ; Full Path without backslash - Example returns "C:\Program Files\Another Dir\AutoIt3" Local $sPathExDr = StringRegExpReplace($sFile, "(^.:)(\\.*\\)(.*$)", "\2") ; Full Path w/0 backslashes, nor drive letter - Example returns "\Program Files\Another Dir\AutoIt3\" Local $sPathExDrBSs = StringRegExpReplace($sFile, "(^.:\\)(.*)(\\.*$)", "\2") ; Path w/o backslash, not drive letter: - Example returns "Program Files\Another Dir\AutoIt3" Local $sPathExBS = StringRegExpReplace($sFile, "(^.*)\\(.*)", "\1") ; File name with ext - Example returns "AutoIt3.chm" Local $sFilName = StringRegExpReplace($sFile, "^.*\\", "") ; File name w/0 ext - Example returns "AutoIt3" Local $sFilenameExExt = StringRegExpReplace($sFile, "^.*\\|\..*$", "") ; Dot Extenstion - Example returns ".chm" Local $sDotExt = StringRegExpReplace($sFile, "^.*\.", ".$1") ; Extenstion - Example returns "chm" Local $sExt = StringRegExpReplace($sFile, "^.*\.", "") MsgBox(0, "Path File Name Parts", _ "Drive " & @TAB & $sDrive & @CRLF & _ "Path " & @TAB & $sPath & @CRLF & _ "Path w/o backslash" & @TAB & $sPathExBS & @CRLF & _ "Path w/o Drv: " & @TAB & $sPathExDr & @CRLF & _ "Path w/o Drv or \'s" & @TAB & $sPathExDrBSs & @CRLF & _ "File Name " & @TAB & $sFilName & @CRLF & _ "File Name w/o Ext " & @TAB & $sFilenameExExt & @CRLF & _ "Dot Extension " & @TAB & $sDotExt & @CRLF & _ "Extension " & @TAB & $sExt & @CRLF) M23
-
gcue reacted to forger in Script To Stop The Computer To Going Into Idle.
You need #include <Process.au3> with _RunDos
ShutDown(1)
But anyway, here's the code:
;If you press the END key, the AntiIdle stops HotKeySet("{END}", "EndAntiIdle") While 1 Run(@ComSpec & " /c @echo hello","", @SW_HIDE) Sleep(600000) WEnd ;Runs the check every 600000 seconds (10 minutes) Func EndAntiIdle() Exit 0 EndFunc -
gcue got a reaction from Skysnake in Array To SQLite
This function is to convert a 2d array to sqlite database. Improvement suggestions welcome! Original idea taken from here
#include <array.au3> #include <sqlite.au3> $sqlDB = @ScriptDir & '\test.sql' FileDelete($sqlDB) _SQLite_Startup() $array = Build_Array() $array_start_index = 0 $table = "aTest" $columns = "Col1, Col2, Col3" ArrayToSQL($array, $array_start_index, $sqlDB, $table, $columns) _SQLite_Shutdown() Func ArrayToSQL($array, $array_start_index, $sqlDB, $table, $columns) Local $hDB = _SQLite_Open($sqlDB) Local $ret = _SQLite_Exec(-1, 'CREATE TABLE if not exists ' & $table & ' (' & $columns & ');') If $ret <> $SQLITE_OK Then Exit (MsgBox(0, 'SQLITE ERROR', 'Create Table Failed')) $columns_array = StringSplit($columns, ",") $num_columns = $columns_array[0] Local $sSQLHead = 'INSERT INTO ' & $table & ' VALUES ' Local $sSQLWork = $sSQLHead For $x = $array_start_index To UBound($array) - 1 $sSQLWork &= '("' For $y = 0 To $num_columns - 1 $sSQLWork &= $array[$x][$y] & '","' Next $sSQLWork = StringTrimRight($sSQLWork, 3) $sSQLWork &= '")' _SQLite_Exec($hDB, $sSQLWork) $sSQLWork = $sSQLHead Next _SQLite_Close($hDB) EndFunc ;==>ArrayToSQL Func Build_Array() Local $iNumRecs = 800 Local $aTest[$iNumRecs][3] For $i = 0 To $iNumRecs-1 $aTest[$i][0] = Random(100, 199, 1) $aTest[$i][1] = Random(500, 599, 1) $aTest[$i][2] = Random(300, 699, 1) Next Debug($aTest) Return $aTest EndFunc ;==>Build_Array Func Debug($variable1 = "", $variable2 = "", $variable3 = "", $variable4 = "") If IsArray($variable1) Then _ArrayDisplay($variable1) Else If $variable2 <> "" Then $variable1 &= @CRLF & $variable2 EndIf If $variable3 <> "" Then $variable1 &= @CRLF & $variable3 EndIf If $variable4 <> "" Then $variable1 &= @CRLF & $variable4 EndIf ClipPut($variable1) MsgBox(0, "Debug", $variable1) EndIf EndFunc ;==>Debug
-
gcue reacted to TheXman in stuck on a query to identify unique items
Looking at your latest query, it appears that you want to find missing songs based solely on the sh1 value. If this is true, then the following example is a different way to achieve your goal.
The current query that you are using, with "cross join", is rather difficult to keep extending to meet your expanding needs.
I used the table data from your last post. As I'm sure you know, all of the sha1 values are the same. So when you run the example, it will show that there are no missing songs based on sha1.
I added some additional information to the console so that you can see what the example is doing.
#include <Constants.au3> #include <SQLite.au3> example() Func example() Const $SQLITE_DLL = "c:\program files\sqlite\sqlite3.dll" ;<-- Change to the location of your sqlite dll ; From a list of all distinct sha1/song/id3 values for a given set of ; selected devices, this query finds all sha1 values that don't already ; exist on a specified device. So to find the result for all selected ; devices, this query needs to be UNION'd once for each selected device. ; (See the generated query in the console output) Const $SQL_QUERY_TEMPLATE = _ "SELECT <device> [device], song [missing song], id3, sha1" & @CRLF & _ "FROM (SELECT DISTINCT id3, song, sha1 from songs WHERE device IN (<selected_devices>))" & @CRLF & _ "WHERE sha1 NOT IN (SELECT sha1 FROM songs WHERE device = <device>)" & @CRLF Local $a2DResult, $aSelectedDevices[0] Local $iRows = 0, $iCols = 0 Local $sSelectedDevices = "", $sSqlQuery = "" ;Init sqlite and create a memory db _SQLite_Startup($SQLITE_DLL, False, 1) If @error Then Exit MsgBox($MB_ICONERROR, "SQLite Error", "Unable to start SQLite. Check existence of DLL") _SQLite_Open() ;Create a songs table _SQLite_Exec(-1, "BEGIN TRANSACTION;") _SQLite_Exec(-1, _ "CREATE TABLE songs (device, song, id3, sha1);" & _ "INSERT INTO songs VALUES " & _ "('Device A', 'Song 1', 'id3-1', '1x2323'), ('Device A', 'Song 3', 'id3-1', '1x2323'), ('Device A', 'Song 4', 'id3-4', '1x2323'), ('Device A', 'Song 5', 'id3-5', '1x2323'), " & _ "('Device B', 'Song 1', 'id3-1', '1x2323'), ('Device B', 'Song 2', 'id3-2', '1x2323'), ('Device B', 'Song 4', 'id3-4', '1x2323'), " & _ "('Device C', 'Song 2', 'id3-2', '1x2323'), ('Device C', 'Song 3', 'id3-2', '1x2323'), ('Device C', 'Song 4', 'id3-4', '1x2323'), ('Device C', 'Song 5', 'id3-5', '1x2323'), " & _ "('Device D', 'Song 1', 'id3-1', '1x2323'), ('Device D', 'Song 2', 'id3-2', '1x2323'), ('Device D', 'Song 3', 'id3-1', '1x2323'); " _ ) _SQLite_Exec(-1, "COMMIT;") ;Create an array of selected devices to be queried _ArrayAdd($aSelectedDevices, "Device A|Device B|Device D") ;Build "selected devices" string to be used by the query For $i = 0 To UBound($aSelectedDevices) - 1 If $i > 0 Then $sSelectedDevices &= "," $sSelectedDevices &= _SQLite_Escape($aSelectedDevices[$i]) Next ConsoleWrite(@CRLF & "Selected Devices: " & $sSelectedDevices & @CRLF) ;Build SQL Query UNIONs (one for each selected device) For $i = 0 To UBound($aSelectedDevices) - 1 If $i > 0 Then $sSqlQuery &= "UNION" & @CRLF $sSqlQuery &= StringReplace($SQL_QUERY_TEMPLATE, "<device>", _SQLite_Escape($aSelectedDevices[$i])) Next $sSqlQuery = StringReplace($sSqlQuery, "<selected_devices>", $sSelectedDevices) ConsoleWrite(@CRLF & "Generated SQL Query: " & @CRLF & $sSqlQuery) ;Execute query and display the results _SQLite_GetTable2d(-1, $sSqlQuery, $a2DResult, $iRows, $iCols) If $iRows > 0 Then ConsoleWrite(@CRLF & "Selected Devices: " & $sSelectedDevices & @CRLF & @CRLF) _SQLite_Display2DResult($a2DResult, 15) Else ConsoleWrite(@CRLF & "WARNING: No missing songs found" & @CRLF) EndIf ;Close db and shutdown sqlite _SQLite_Close() _SQLite_Shutdown() EndFunc