Jump to content
ghost911

PureAutoIt machine code compiler small executable

Recommended Posts

Posted (edited)

I create purebasic language functions similar to autolt I let the members of the furom improve the concept with a beginning of idea I included some functions it works very well for the moment I let you modify and give your ideas thank ;)

add in your purebasic source code (IncludeFile "AutoitCoding.PB") and program as on autolt it remains full of function to program the concept is to improve the languages remain similar

AutoIt Code :  415 kb with UPX Interpreted Language

$Time=TimerInit()
MsgBox (16,"Autoit",StringIsDigit ("123a"))
MsgBox (16,"Autoit",StringIsDigit ("123"))
$VarBin=StringToBinary("Hello")
MsgBox (64,"Autoit",@Hour)
MsgBox (64,"Autoit",@TempDir)
MsgBox (64,"Autoit",$VarBin)
MsgBox (64,"Autoit",BinaryToString($VarBin))
MsgBox (0,"Autoit",StringLen ("bonjour"))
MsgBox (1,"Autoit",@DesktopCommonDir)
MsgBox (2,"Autoit",@ProgramFilesDir)
Sleep (1000)
MsgBox (3,"Autoit",FileGetSize("test.pb"))
MsgBox (4,"Autoit",Random (1,10,1))
$Variable=FileGetSize("test.pb")
MsgBox (0,"Autoit",$Variable)
;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg")
MsgBox (0,"Autoit",StringReplace ("Hella","a","o"))
MsgBox (0,"Autoit",StringTrimLeft ("Hello",1))
MsgBox (0,"Autoit",StringTrimRight("Hello",1))
    If  FileExists ("test.pb") Then
        MsgBox(0,"Title","the file exist")
    Else
        MsgBox(0,"Title","the file does not exist")
    EndIf
MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1))
MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1))
MsgBox(0,"Autoit",FileGetVersion("UPX.exe"))
MsgBox(0,"Autoit",TimerDiff($Time))
If IsAdmin() Then
    MsgBox(0,"Autoit", "IsAdmin You are administrator !.")
Else
    MsgBox(0,"Autoit", "IsAdmin You are not administrator !.")
EndIf
MsgBox(0,"Autoit",String (10))
MsgBox(0,"Autoit",Ping ("google.fr"))

PureBasic Code : Executable Size : 12 kb with UPX Real Compiler ( Your source code is secure )

IncludeFile "AutoitCoding.PB"
;MsgBox (16,"Autoit",StringIsDigit ("123a")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable
;MsgBox (16,"Autoit",StringIsDigit ("123"))  ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable
;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") ; InetFonctions be sure to activate it in AutoitCoding.PB this increases the size of the executable

Time$=TimerInit()
VarBin$=StringToBinary("Hello")
MsgBox (64,"Autoit",Hours ())
MsgBox (64,"Autoit",TempDir ())
MsgBox (64,"Autoit",VarBin$)
MsgBox (64,"Autoit",BinaryToString(VarBin$))
MsgBox (48,"Autoit",StringLenS ("bonjour"))
MsgBox (1,"Autoit",DesktopCommonDir ())
MsgBox (2,"Autoit",ProgramFilesDir ())
Sleep (1000)
MsgBox (3,"Autoit",FileGetSize("test.pb"))
MsgBox (4,"Autoit",Randoms (1,10))
Variable$=FileGetSize("test.pb")
MsgBox (0,"Autoit",Variable$)
MsgBox (0,"Autoit",StringReplace ("Hella","a","o"))
MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) 
MsgBox (0,"Autoit",StringTrimRight("Hello",1))
If  FileExists ("test.pb")
  MsgBox(0,"Autoit","the file exist")
Else
  MsgBox(0,"Autoit","the file does not exist")
EndIf
MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%mm/%dd/%yyyy %hh:%ii:%ss"))
MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%hh:%ii:%ss"))
MsgBox(0,"Autoit",FileGetVersion("UPX.exe",#FV_FileVersion))
MsgBox(0,"Autoit",TimerDiff(Time$))
If IsAdmin()
  MsgBox(0,"Autoit", "IsAdmin You are administrator !.")
  Else
    MsgBox(0,"Autoit", "IsAdmin You are not administrator !.")
EndIf
MsgBox(0,"Autoit",String(10))
MsgBox(0,"Autoit",Ping ("google.fr"))
;Bonus Function
MsgBox(0,"Autoit",HostNameToIp ("google.fr"))

there is a slight difference but nothing important I am counting on you to improve the project and add functions !

( Disadvantage purebasic is paying you can not have all ) 

 

Functions compatible :

 

Msgbox

Sleep

FileGetSize

ClipPut

ClipGet

Randoms

DirCopy

DirCreate

DirRemove

StringReplace

StringLen

 

Add Fonctions :  (11/03/2019)

 

StringTrimLeft

StringTrimRight

FileCopy

FileMove

StringUpper

StringLower

Add Fonctions :  (12/03/2019)

StringIsFloat

StringIsAlpha

StringIsDigit

StringReverse

BinaryToString

StringToBinary

FileExists

Msgbox ADD :

MB_ICONERROR = 16

MB_ICONQUESTION = 32

MB_ICONWARNING = 48

MB_ICONINFORMATION=64

You can control the size of the executable

Division of executable size by 10 ( 119 kb to 12 kb)

( I separated the functions in several file activated if necessary )

;IncludeFile "FonctionsIncludes\StringIs.PB" I separated the functions into several activated files If necessary remove
;IncludeFile "FonctionsIncludes\InetFonctions.PB" ; I separated the functions into several activated files If necessary remove

Add Functions:  (20/03/2019)

 

 

 

 

 

 

 

 

 

 

 

String

IsAdmin

TimerDiff (thank @JiBe)

TimerInit (thank @JiBe)

Ping

FileGetVersion

add :

#FV_FileVersion

#FV_FileDescription

#FV_LegalCopyright

#FV_InternalName

#FV_OriginalFilename

#FV_ProductName

#FV_ProductVersion

#FV_CompanyName

#FV_LegalTrademarks

#FV_SpecialBuild

#FV_PrivateBuild

#FV_Comments

#FV_Language

FileGetTime

Flag :

 0 Last modified (default)
 1 Created
 2 Last accessed

Msgbox ADD :

MB_DEFBUTTON2 = 256 Flag

MB_DEFBUTTON3 = 512 Flag

MB_DEFBUTTON4 = 768 Flag

MB_SYSTEMMODAL = 4096 Flag

MB_TASKMODAL = 8192 Flag

MB_DEFAULT_DESKTOP_ONLY = 131072 Flag

MB_RIGHT = 524288 Flag

MB_RTLREADING = 1048576 Flag

MB_SETFOREGROUND = 65536 Flag

MB_TOPMOST = 262144 Flag

MB_SERVICE_NOTIFICATION = 2097152 Flag

 

Bonus Functions :

HostNameToIp

Add Functions:  (22/03/2019)

 

-----------------------

ADD Macros : (thank @AZJIO)

DesktopCommonDir () 

MyDocumentsDir () 

ProgramFilesDir ()

ScriptFullPath ()

ScriptName ()

ScriptDir ()

-----------------------

OSVersions ()

Add Functions:  (26/03/2019)

 

-----------------------

ADD Macros :

TempDir ()

Hours ()

Min ()

Sec ()

MDAY ()

MON ()

Years ()

LF ()

CR ()

CRLF ()

-----------------------

Functions

Floor

Ceiling

Stringlen ( Update :Return Number)

StringlenS (Temporary function asks for reflection)

GuiExampleAutoitCoding (Hybrid Code).rar

PureAutoitInclude.rar

Edited by ghost911
Reset font to normal

Share this post


Link to post
Share on other sites
Posted (edited)

StringSplit ( "string", "" )

If you use an empty string "" for the delimiters, each character will be returned as an element.

Procedure StrToArrLetter(Array Arr.s{1}(1), String$)
    Protected LenStr, i
    LenStr = Len(String$)
    If LenStr
        ReDim Arr(LenStr - 1)
        PokeS(Arr(), String$, -1, #PB_String_NoZero)
    EndIf
EndProcedure

StringSplit ( "string", " " )

Procedure StrToArr(Array Arr.s(1), String$, Sep$ = " ")
    Protected CountSep, n
    CountSep = CountString(String$ , Sep$)
    If CountSep = 0
        ReDim Arr(1)
        Arr(1) = String$
    Else
        ReDim Arr(CountSep+1)
        For n = 1 To CountSep+1
            Arr(n) = StringField(String$, n, Sep$)
        Next
    EndIf
EndProcedure

StringFormat

ImportC "msvcrt.lib"
  swprintf(*s, Format.s, Param1=0, Param2=0, Param3=0, Param4=0)
EndImport

num1.l = 16049884
Buff.s{100}
swprintf(@Buff, "%06X", num1)
Debug Buff

StringTrimLeft

Procedure.s TrimLeft(String$, n)
    ;ProcedureReturn Right(String$, Len(String$) - n)
    ProcedureReturn Mid(String$, n+1)
EndProcedure

StringTrimRight

Procedure.s TrimRight(String$, n)
    ProcedureReturn Left(String$, Len(String$) - n)
EndProcedure

@ScriptDir =analog= GetPathPart(ProgramFilename())
@ScriptName =analog= GetFilePart(ProgramFilename())
@ScriptFullPath =analog= ProgramFilename()
@MyDocumentsDir =analog= GetUserDirectory(#PB_Directory_Documents)
@ProgramFilesDir =analog= GetUserDirectory(#PB_Directory_Programs)
@DesktopCommonDir  =analog= GetUserDirectory(#PB_Directory_Desktop)

Edited by AZJIO

Share this post


Link to post
Share on other sites
On 3/6/2019 at 11:33 PM, ghost911 said:

PureBasic Code : Executable Size : 119 kb with UPX Real Compiler ( Your source code is secure )

I think the code is not a hash sum, so it is always possible to study. He also gives commands to the OS, which means that he acts according to a scenario that the system recognizes. If you look at the functions for working with ListView, then in PureBasic there are only 15 functions, and in AutoIt3 - 150. In PureBasic, you have to write all the functions yourself. I can not write an analogue of the function _GUICtrlRichEdit_StreamFromVar. Although there is a curve example for the old version, but I can not adapt it. Therefore, in AutoIt3 you can program, and in PureBasic, watch how other people write programs.

Share this post


Link to post
Share on other sites
Posted (edited)

@AZJIO thank you i will add the fonctions to the code 

if other members can participate

@Chimp purebasic is even more complete for interfaces and richer in function

Edited by ghost911

Share this post


Link to post
Share on other sites
Posted (edited)

Hello if everybody wants a real compiler we have to find solutions after most people use basic functions this could be an alternative solution after nothing is perfect !

Edited by ghost911

Share this post


Link to post
Share on other sites
On 3/10/2019 at 9:14 AM, Chimp said:

why did not you opt for FreeBasic instead? (https://www.freebasic.net/)

When I last used FB I found even the most basic of compiled binaries to be pretty chunky but it was some time ago, have they optimized the compiler these days?

 

@ghost911 Sterling work keep it up :)

Share this post


Link to post
Share on other sites
10 hours ago, Mobius said:

When I last used FB I found even the most basic of compiled binaries to be pretty chunky but it was some time ago, have they optimized the compiler these days?

....  I don't know, never done comparisons between the two (apart from the fact that one is free and the other is not), I have only seen some very speedy examples posted on this forum by @UEZ

https://www.autoitscript.com/forum/topic/185024-freebasic-graphical-examples-build-2018-07-10/

https://www.autoitscript.com/forum/topic/190642-ascii-art-kaleidoscope/?do=findComment&comment=1368827

 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
16 hours ago, Chimp said:

....  I don't know, never done comparisons between the two (apart from the fact that one is free and the other is not), I have only seen some very speedy examples posted on this forum by @UEZ

https://www.autoitscript.com/forum/topic/185024-freebasic-graphical-examples-build-2018-07-10/

https://www.autoitscript.com/forum/topic/190642-ascii-art-kaleidoscope/?do=findComment&comment=1368827

 

... So you are asking why the op didn't use a language for their project that you don't really use yourself, ok.

No denying that both are perfectly capable languages but to eschew one over another purely based on one having a price tag and another not ... your choice I guess.

Share this post


Link to post
Share on other sites
2 hours ago, Mobius said:

... So you are asking why the op didn't use a language for their project that you don't really use yourself, ok.

No denying that both are perfectly capable languages but to eschew one over another purely based on one having a price tag and another not ... your choice I guess.

Yes, since I don't know, I've asked. I have no claims to proselytize for FreeBasic vs PureBasic.
Since OP stated "( Disadvantage purebasic is paying you can not have all )"
I've just asked "why did not you opt for FreeBasic instead?" I've not say "You have to use FreeBasic instead!"
OP answered "purebasic is even more complete for interfaces and richer in function". That's all (sorry for the misunderstanding and the hijacking)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Time spent on learning the language and further use is hundreds of times more expensive. It takes me 3 days to work to buy PureBasic, but studying and addictive will take several months. It is more difficult to pay, as it is necessary to register on PayPal.

I do not think that it is necessary to make an AutoIt3 shell for PureBasic. It is better to make a table of function analogs in order to understand with the help of which function you can do the same things. I for example know the name of the function "Sleep", but I can not find its equivalent in the PureBasic help file, because the name is different.

Share this post


Link to post
Share on other sites

i just meant we needed to get him a better paying job, lol but yeah, the list would be nice. for me, it's not hard to pick up another language when you already know a few really well. but i did cut my teeth on Color Basic that shipped with my Tandy coco, then onto C, Java, and on from there. It's a lot of the same stuff really.


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites

TimerInit() and TimerDiff()


Procedure.f TimerInit()
  ProcedureReturn ElapsedMilliseconds()
EndProcedure

Procedure.f TimerDiff(StartTime.f)
  ProcedureReturn (ElapsedMilliseconds() - StartTime)/1000
EndProcedure

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...