Leaderboard
Popular Content
Showing content with the highest reputation on 06/07/2015 in all areas
-
I have wrote a lot of binary code library for AutoIt before. I also discover many ways to generate binary code for AutoIt in the past. However, all of them have limitation or need some extra effort. Recently, I think I found the best and easiest way to generate the binary code. So I wrote this UDF, may be my last one about binary code. The Features:Both AutoIt x86 and x64 version are supported.Windows API and static variables can be use (code relocation supported).Decompression at run-time with smallest footprint LZMA decoder.Allocated memory blocks are released automatically.Most C source code works without modification.Two step or one step script generation, very easy to use.How It Works: The C source code must be compiled by MinGW GCC with "-S -masm=intel" option. Output is GAS syntax assembly file.BinaryCall Tool is able to convert the GAS syntax assembly file (*.s) to FASM syntax (*.asm). During the conversion, global symbols will be stored as "Symbol Jump Table" at the head of the file. The output file should be able to be assembled to binary file under command line by FASM.EXE. This syntax conversion is step 1.The step 2 is to assemble the file. BinaryCall Tool will use the embedded FASM to assemble every file twice to generate the relocation table. "BinaryCall.inc" will be included automatically before assembling to detect the Windows API and generate the "API Jump table". All the results will be compressed and converted to AutoIt script output.There are two major functions in the output script. _BinaryCall_Create() function allocates memorys, decompress the binary, relocates the address in memory, and fills the "API Jump Table"._BinaryCall_SymbolList() converts the "Symbol Jump Table" to memory addresses, and then store them as pointers in a DllStruct variable.Finally, we can use DllCallAddress() to call the memory address stored in the DllStruct.Step by Step Tutorial: Write C source code:#include <windows.h> void main() { MessageBox(0, "Hello", "Welcome Message", 1); }Use GCC MinGW 32/64 to compile the source code: gcc -S -masm=intel -m32 MessageBox.cUse BinaryCall Tool "GAS2AU3 Converter", select "MessageBox.s": If Not @AutoItX64 Then Local $Code = '...' Local $Reloc = '...' Local $Symbol[] = ["main"] Local $CodeBase = _BinaryCall_Create($Code, $Reloc) If @Error Then Exit Local $SymbolList = _BinaryCall_SymbolList($CodeBase, $Symbol) If @Error Then Exit EndIfPaste the output script, call the main() in AutoIt: #Include "BinaryCall.au3" ; Paste output here DllCallAddress("none:cdecl", DllStructGetData($SymbolList, "main"))Try to run it! Change Log:v1.0Initial release.v1.1A lot of improvement for GAS2ASM converter and FASM header file.Add many C Run-Time library as inline asm subroutines.Add command-line to argc/argv parser for easy calling main() function.Add ability to redirect stdio.More C source code can work without modification in this version. Following open source projects are tested. And Yes, they can run as binary code library in AutoIt now. SQLite 3.8.5 TCC 0.9.26 PuTTY beta 0.63 v1.2Dynamic-link library (DLL) calling is supported now. If the C program requires a DLL file to run, just put it together with the source file. BinaryCall Tool will searches *.dll and exports all the symbols in these DLL files automatically. Of course, you need these DLL files when run the output script. However, it also works if you loaded them by last version of MemoryDll UDF.To add more Windows API library easily by editing the ini file.Better error handling and more error messages in output script.Add zero padding to avoid short jumps that crash the relocation table.BinaryCall Tool accepts drag and drop files now.Some small bug fixed. BinaryCall 1.0.zip BinaryCall 1.1.zip BinaryCall 1.2.zip1 point
-
I built my own libcurl for AutoIt based on BinaryCall UDF. libcurl - the multiprotocol file transfer library The Features: Pure AutoIt script, no DLLs needed.Build with SSL/TLS and zlib support (without libidn, libiconv, libssh2).Full easy-interface and partial multi-interface support.Data can read from or write to autoit variables or files.Smaller code size (compare to most libcurl DLL).The version information of this build: Curl Version: libcurl/7.42.1SSL Version: mbedTLS/1.3.10Libz Version: 1.2.8Protocols: ftp,ftps,http,httpsHere are the helper functions (not include in libcurl library). Curl_DataWriteCallback()Curl_DataReadCallback()Curl_FileWriteCallback()Curl_FileReadCallback()Curl_Data_Put()Curl_Data_Get()Curl_Data_Cleanup()See the example script for detail usage. Curl.zip1 point
-
Like Request for node.js or Requests for python, Request UDF is a powerful and easy-to-use HTTP client for AutoIt. It is based on my Curl.au3 and Json.au3 (not included). The Features: Request target can be a string (single url), an array (urls), an object (single url + options or url array + options), an object array (urls + different options), or a json string (decode to array or object automatically), etc.Easy to setup post data, cookies, agent, refer, timeout, proxy, etc.Easy to setup the default options before a series of requests.Use BinaryToString() to decode the returned data according to content type automatically. Use curl multi interface by default. It means all requests will transfer simultaneously and won't block the GUI event.Use callback function to recieve the data and information for every url before main function finished.Supports https and ftp protocols.Example: #Include "Json.au3" #Include "Curl.au3" #Include "Request.au3" RequestDefault('{refer: "http://www.autoitscript.com", agent: "AutoIt/Request", callback: "MyCallback"}') Local $Data = Request("http://httpbin.org/get") ConsoleWrite($Data & @LF) Request('["http://www.google.com", "http://wikipedia.org"]') Request('{url: "http://www.google.com", agent: "AutoIt/Request"}') Request('{url: ["http://www.google.com", "http://wikipedia.org"], agent: "AutoIt/Request"}') Local $Array[] = ["http://www.google.com", "http://wikipedia.org"] Request($Array) Request("http://httpbin.org/post", "key=Post%20can%20be%20the%20raw%20data") Request("http://httpbin.org/post", '{key: "Post can be a json object string"}') Request('{url: "http://httpbin.org/post", post:{key: "Post can be set as second paramemtr or \"post\" option"}}') Local $Obj Json_Put($Obj, ".key", "Post can be an object") Local $Json = Request("http://httpbin.org/post", $Obj) Func MyCallback($Obj) Local $Data = Json_ObjGet($Obj, "Data") Local $EffectiveUrl = Json_ObjGet($Obj, "EffectiveUrl") ConsoleWrite("Callback: " & $EffectiveUrl & " download size: " & StringLen($Data) & @LF) EndFunc More examples are in the archive. Request.zip1 point
-
The main points remains that the OP asked for an AutoIt construct similar in essential properties to the Pascal record and this does have an answer: DllStruct are just doing that, keeping in mind that they are an equivalent to C structs but not to C typedefed structs. What DllStructs are not suitable for is when one expects to use them for, say, masquerading the inner layout of objects or similar acrobatic tricks. This is the kind of sideways use that I believe Valik and Jon had in mind. That or doing tricks with the stack or even more dangerous misuse. Agreed, AutoIt isn't the language of choice to rewrite Stuxnet. I'd like to see a rebutal to the fact that they can be used (and are used today) to pass data to _WinAPI_WriteFile and from _WinAPI_ReadFile as an opaque binary container (address and size). This is all the OP wanted and I see no reason why such legitimate use should be discouraged. Yet again I must warn against the fact that, contrary to Pascal records, assigning an existing DllStruct to another variable doesn't create a distinct copy of the DllStruct, but a clone of the original struct based at the same address. Local $tBuf = DllStructCreate('dword') DllStructSetData($tBuf, 1, 1234) ConsoleWrite(DllStructGetData($tBuf, 1) & @LF) Local $tBufCopy = $tBuf DllStructSetData($tBuf, 1, 5678) ConsoleWrite(DllStructGetData($tBufCopy, 1) & @LF)1 point
-
In general, trying to have a severely owned machine clean itself is like expecting success to a brain surgeon practicing live brain surgery on himself. The very first step on infection is to render the boot and system volume(s) passive slaves by booting on a distinct, certified clean device, preferably read-only, preferably based on a distinct OS. Some sophisticated hard-to-kill malware infect from BIOS space.1 point
-
If DllStruct stop working the way they work today there will be more than unexpected behaviors. For instance would _WinAPI_WriteFile stop working when it's passed a DllStruct, which is readily used in some standard includes and Wrapper, to say the least? That is exactly what the OP could be using DllStruct for. Also would the large number of DllStructs used in other WinAPI calls stop working? For me DllStructs are containers which can hold data under a strict format definable by users with well documented basic types. Maybe both Valik and Jon feared completely different [mis]uses, but certainly not this one.1 point
-
@jemboy: you can stick a struct directly into an array, and then access specific fields within the struct, for any desired record within scope, with DllstructGetData/SetData: Local Const $tagSTRUCT1 = "struct;int var1;byte var2;uint var3;char var4[128];endstruct" $maxrecords=10 ; create data struct for each record Global $records[$maxrecords+1] For $rc=1 To $maxrecords $records[$rc] = DllStructCreate($tagSTRUCT1) Next $records[0]=Ubound($records)-1 ; load some content DllStructSetData($records[1],"var4","lastname1") DllStructSetData($records[2],"var4","lastname2") DllStructSetData($records[3],"var4","lastname3") ; retrieve a field for a specific record $myrecord=2 MsgBox(0,"struct in rec " & $myrecord,DllStructGetData($records[$myrecord],"var4"))1 point
-
The use of square brackets in the AutoIt help file normally indicate optional use. With multiple variable declarations on the same line, then using a Local, Global, Dim, Const, or Enum is not optional. A working example. Local $var = "contents" Local $newvar = $var, $var = "new" ; or $var = "" to clear variable ConsoleWrite("$newvar = " & $newvar & @LF) ConsoleWrite("$var = " & $var & @LF)1 point
-
change variable name
argumentum reacted to CarlD for a topic
Just reassign the var's data to newvar, and optionally zero out the old var: [Local] $newvar = $var, $var = "" Am I missing something?1 point -
Sodori, I would use a Accelerator key like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <WinAPI.au3> ; Array of values as strings Global $aList_String[8] = ["1", "2", "3", "12", "134", "14", "256", "8"] ; And sorted as strings _ArraySort($aList_String) ; Array of values as numbers Global $aList_Number[8] = [1, 2, 3, 12, 134, 14, 256, 8] ; And sorted as numbers _ArraySort($aList_Number) $hGUI = GUICreate("Test", 500, 500) ; Create lists without the sort style $cList_String = GUICtrlCreateList("", 10, 10, 230, 300, BitOr($WS_BORDER, $WS_VSCROLL)) $cList_Number = GUICtrlCreateList("", 260, 10, 230, 300, BitOr($WS_BORDER, $WS_VSCROLL)) ; Add items to the lists For $i = 0 To 7 GUICtrlSetData($cList_String, $aList_String[$i]) GUICtrlSetData($cList_Number, $aList_Number[$i]) Next $cDummy = GUICtrlCreateDummy() GUISetState() Local $aAccelKeys[1][2] = [["^c", $cDummy]] GUISetAccelerators($aAccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummy Switch _WinAPI_GetFocus() Case GUICtrlGetHandle($cList_String) ConsoleWrite(GUICtrlRead($cList_String) & @CRLF) Case GUICtrlGetHandle($cList_Number) ConsoleWrite(GUICtrlRead($cList_Number) & @CRLF) EndSwitch EndSwitch WEndM231 point
-
Data records with Array
Gianni reacted to jvanegmond for a topic
AutoIt beta added a Maps feature which is an excellent drop in replacement for this. It's not identical, you won't have any compile time checking done on the names used, but it's definitely a handy thing to have and may solve your use case. Dim $myBookRec[] $myBookRec.Title = 'Some Book' $myBookRec.Author = 'Victor John Saliba' $myBookRec.ISBN = '0-12-345678-9' $myBookRec.Price = 25.5 ConsoleWrite('Here are the book details:' & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite('Title: ' & $myBookRec.Title & @CRLF) ConsoleWrite('Author: ' & $myBookRec.Author & @CRLF) ConsoleWrite('ISBN: ' & $myBookRec.ISBN & @CRLF) ConsoleWrite('Price: ' & $myBookRec.Price & @CRLF)1 point -
Hi everyone! I often see questions like this: "How i can change the tooltip text and background colors?", "How i can change the tooltip font size and font name?", "How to create a custom tooltip?" And i became interesting about possibility to create a custom tooltip. This possible. Edit: Fixed 2 bugs ToolTip_UDF.zip1 point
-
Comment out line 9 (Global Const $TTDT_AUTOPOP = 2) and add #include <WinAPIConstants.au3> somewhere at the top and it should work. Btw, rasim is not active since 02/2009!1 point
-
to get the number of double clicked item have a look to the _GUICtrlListView_SubItemHitTest function and to get the text at that item number have a look to the _GUICtrlListView_GetItemText have a look in my previous post on how I used those functions1 point
-
here another way... #include <GuiListView.au3> #include <GUiConstants.au3> #include <File.au3> $Form1 = GUICreate("Form1", 322, 438, 297, 131) Global $MusicDir = FileSelectFolder("Please select a folder", @HomeDrive) $ListView1 = GUICtrlCreateListView("Mp3 files at " & $MusicDir, 16, 4, 289, 413) If @error Then Exit $filesArray = _FileListToArray($MusicDir, "*.mp3") For $i = 1 To $filesArray[0] GUICtrlCreateListViewItem($filesArray[$i], $ListView1) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "_Check_Click") ; Register a user defined function for a known Windows Message ID (WM_MSG). ---------+ ; | ; WM_NOTIFY event handler for click example: http://www.autoitscript.com/forum/topic/143900-listview-onclick/#entry1013670 <---+ Func _Check_Click($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Local $hList = GUICtrlGetHandle($ListView1) If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hList And DllStructGetData($tNMHDR, "Code") = $NM_CLICK Then ; event is from $hList and it is a $NM_CLICK ; is a Click ; manage click here EndIf ; what follows will check if it is a doubleClick and if is comming from the listview If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hList And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then ; event is from $hList and it is a $NM_DBLCLK ; is a DoubleClick $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hList) If $aLV_Click_Info[0] <> -1 Then ConsoleWrite("DoubleClick on " & _GUICtrlListView_GetItemText($hList, $aLV_Click_Info[0]) & @CRLF) Else ConsoleWrite("DoubleClick on an empty row" & @CRLF) EndIf ConsoleWrite($MusicDir & "\" & _GUICtrlListView_GetItemText($hList, $aLV_Click_Info[0]) & @CRLF) SoundPlay("") SoundPlay($MusicDir & "\" & _GUICtrlListView_GetItemText($hList, $aLV_Click_Info[0])) EndIf Return ; $GUI_RUNDEFMSG EndFunc ;==>_Check_Click While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd1 point
-
kisstom, Use _FileListToArrayRec to get files from within subfolders on the path. M231 point
-
kisstom, Welcome to the AutoIt forum. But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "This is NOT a general support forum!". I have moved it for you, but would ask you to be more careful in future. And when you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. M231 point
-
#include <Array.au3> Local $aArray = _GetRunEntries() _ArrayDisplay($aArray) ; Version: 1.00. AutoIt: V3.3.8.1 ; Retrieve the startup entries of all users. Func _GetRunEntries() Local $aReturn[1][6] = [[0, 5, 0]] Local $oWMIService = ObjGet('winmgmts:{impersonationLevel = impersonate}!.rootcimv2') Local $oColFiles = $oWMIService.ExecQuery('Select * From Win32_StartupCommand') If IsObj($oColFiles) Then For $oObjectFile In $oColFiles If ($aReturn[0][0] + 1) >= $aReturn[0][2] Then $aReturn[0][2] = ($aReturn[0][0] + 1) * 2 ReDim $aReturn[$aReturn[0][2]][$aReturn[0][1]] EndIf $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $oObjectFile.Command $aReturn[$aReturn[0][0]][1] = $oObjectFile.Description $aReturn[$aReturn[0][0]][2] = $oObjectFile.Location $aReturn[$aReturn[0][0]][3] = $oObjectFile.Name $aReturn[$aReturn[0][0]][4] = $oObjectFile.SettingID $aReturn[$aReturn[0][0]][4] = $oObjectFile.User Next $aReturn[0][2] = '' ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1]] Return $aReturn EndIf Return SetError(1, 0, $aReturn) EndFunc ;==>_GetRunEntries1 point
-
How to click a web button in already opened IE browser
dcbakkk reacted to lshankarmca for a topic
Hi I got the solution to click on the button which is inside the web dialog. following is code is to click on the submit button: #include <IE.au3> Local $oIE = _IEAttach("Submit Job" , "embedded") Local $oSubmit = _IEGetObjById($oIE, "LAWTBBUTTONundefined") _IEAction($oSubmit, "click") Now I want to run my script when my system starts and when ever it found "Submit Job" window open it should run the following code automatically How to achieve is? Regards, Shankar L1 point