Advertisement
Najeebsk

BigSize.ahk

Sep 22nd, 2022
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance,Force
  2. #NoTrayIcon
  3. SetBatchLines,-1
  4.  
  5. Gui,Add,Text,,Filename
  6. Gui,Add,Edit,vfilename w200,BigSize
  7. Gui,Add,Text,Section,Size
  8. Gui,Add,Edit,vfilesize w95,100
  9. Gui,Add,Text,ys,B/KB/MB/GB/TB
  10. Gui,Add,DropDownList,vbyte w95,Byte||KiloByte|MegaByte|GigaByte|TerraByte
  11. Gui,Add,Text,xm,ASCII/Binary
  12. Gui,Add,DropDownList,vfiletype w200,Binary||ASCII
  13. Gui,Add,Text,xm,
  14. Gui,Add,Text,xm vstatus,Please input values and press Create
  15. Gui,Add,Text,xm,
  16. Gui,Add,Button,ys ym+20 gCREATE vcreate,Create
  17. Gui,Show,xCenter yCenter,BigSize by Najeeb S Khan
  18. Return
  19.  
  20. CREATE:
  21. Gui,Submit,NoHide
  22. If filename=
  23. {
  24.   GuiControl,,status,Empty filename!
  25.   Return
  26. }
  27.  
  28. If filesize=
  29. {
  30.   GuiControl,,status,Empty size!
  31.   Return
  32. }
  33.  
  34. If filesize<1
  35. {
  36.   GuiControl,,status,Too small!
  37.   Return
  38. }
  39.  
  40. size:=filesize
  41. If byte=KiloByte
  42.   size:=size*1024
  43. If byte=MegaByte
  44.   size:=size*1024*1024
  45. If byte=GigaByte
  46.   size:=size*1024*1024*1024
  47. If byte=TerraByte
  48.   size:=size*1024*1024*1024*1024
  49.  
  50. GuiControl,Disable,create,
  51. GuiControl,,status,Creating file...
  52.  
  53. If filetype=ASCII
  54. {
  55.   size-=1
  56.   type=a
  57.   Gosub,CREATEASCII
  58. }
  59. Else
  60. {
  61.   type=b
  62.   Gosub,CREATEBINARY
  63. }
  64.  
  65. goal=%size%
  66. oldcounter=0
  67. counter=1
  68. string=
  69. Loop
  70. {
  71.   If(counter>goal)
  72.     Break
  73.   RunWait,cmd /c copy /y /%type% %oldcounter% + %oldcounter% %counter%,,Hide
  74.   oldcounter:=counter
  75.   counter:=counter*2
  76.   GuiControl,,status,Creating file %counter%...
  77. }
  78.  
  79. sum=0
  80. Loop
  81. {
  82.   counter/=2
  83.   If(goal-counter<0)
  84.     Continue
  85.   If(goal-counter=0)
  86.     Break
  87.   goal-=%counter%
  88.   string=%string% %counter% +
  89.   sum+=%counter%
  90.   GuiControl,,status,Creating file %counter%...
  91. }
  92. string=%string% %counter%
  93. sum+=%counter%
  94. RunWait,cmd /c copy /y /%type% %string% %filename%,,Hide
  95.  
  96. goal=%size%
  97. counter=1
  98. Loop
  99. {
  100.   If(counter>=goal)
  101.     Break
  102.   RunWait,cmd /c del %counter%,,Hide
  103.   counter:=counter*2
  104. }
  105.  
  106. GuiControl,,status,%filesize% %byte% %kind% %filename% created
  107. GuiControl,Enable,create,
  108. MsgBox,0,BigByte,%filesize% %byte% %kind% %filename% created
  109. GuiControl,,status,Please input values and press Create
  110. Return
  111.  
  112.  
  113. CREATEASCII:
  114. FileDelete,1
  115. FileAppend,0,1
  116. If ErrorLevel=1
  117. {
  118.   MsgBox,Error creating file!
  119.   GuiControl,Enable,create,
  120.   Return
  121. }
  122. Return
  123.  
  124.  
  125. CREATEBINARY:
  126. hFile:=DllCall("CreateFile","str","1","Uint",0x40000000,"Uint",0,"UInt",0,"UInt",2,"Uint",0,"UInt",0)
  127. If (ErrorLevel or hFile=-1)
  128. {
  129.   MsgBox,Error creating file!
  130.   Return
  131. }
  132. result:=DllCall("WriteFile","UInt",hFile,"UChar *",0,"UInt",1,"UInt *",BytesActuallyWritten,"UInt",0)
  133. If (!result or ErrorLevel)
  134. {
  135.   MsgBox,Error creating file!
  136.   Return
  137. }
  138. result:=DllCall("CloseHandle","Uint",hFile)
  139. If (!result or ErrorLevel)
  140. {
  141.   MsgBox,Error creating file!
  142.   GuiControl,Enable,create,
  143.   Return
  144. }
  145. Return
  146.  
  147. GuiClose:
  148. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement