Code: Select all
[###########.......]
ANY & ALL help is GREATLY appreciated! <3
Thank You! <3
Code: Select all
[###########.......]
Code: Select all
EnableExplicit
Import "kernel32.lib"
AttachConsole(processID.l)
EndImport
Procedure.f GetHashPercentage()
Protected hConsole.i, processID.i, hStdOut.i, NumberOfChars.l, Y.i, Pos1.i, Pos2.i, Result.f
Protected MaxCarrets.i, CurrentCarrets.i
Protected ConsoleScreenBufferInfo.CONSOLE_SCREEN_BUFFER_INFO
Protected *Buffer
Protected ReadCoord.COORD
Protected Line$
Result = -1
hConsole = FindWindow_("ConsoleWindowClass", #Null)
If hConsole
GetWindowThreadProcessId_(hConsole, @processID)
If AttachConsole(processID)
hStdOut = GetStdHandle_(#STD_OUTPUT_HANDLE)
If hStdOut
If GetConsoleScreenBufferInfo_(hStdOut, @ConsoleScreenBufferInfo)
*Buffer = AllocateMemory((ConsoleScreenBufferInfo\srWindow\right + 1) * (ConsoleScreenBufferInfo\srWindow\bottom + 1) * SizeOf(Character), #PB_Memory_NoClear)
If *Buffer
ReadCoord\x = 0
ReadCoord\y = ConsoleScreenBufferInfo\srWindow\top
If ReadConsoleOutputCharacter_(hStdOut, *Buffer, (ConsoleScreenBufferInfo\srWindow\right + 1) * (ConsoleScreenBufferInfo\srWindow\bottom + 1), PeekL(@ReadCoord), @NumberOfChars)
For Y = 0 To ConsoleScreenBufferInfo\srWindow\bottom - ConsoleScreenBufferInfo\srWindow\top
Line$ = PeekS(*Buffer + (Y * (ConsoleScreenBufferInfo\srWindow\right + 1) * SizeOf(Character)), ConsoleScreenBufferInfo\srWindow\right + 1)
Pos1 = FindString(Line$, "[")
If Pos1
Debug Line$
If Pos1 < 16 ; I don't know where it starts, but needed because DOS returns the Version in []
Pos1 + 1
Pos2 = FindString(Line$, "]", Pos1)
If Pos2
MaxCarrets = Pos2 - Pos1
Line$ = Mid(Line$, Pos1, MaxCarrets)
CurrentCarrets = CountString(Line$, "#")
Debug Str(CurrentCarrets) + " of " + Str(MaxCarrets)
Result = CurrentCarrets * 100 / MaxCarrets
Break
EndIf
EndIf
EndIf
Next Y
EndIf
FreeMemory(*Buffer)
EndIf
EndIf
EndIf
FreeConsole_()
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Define Prog.i
Prog = RunProgram("cmd", "/K @echo [##### ]", "", #PB_Program_Open)
If Prog
Delay(1000)
Debug StrF(GetHashPercentage(), 2) + "%"
Delay(3000)
KillProgram(Prog)
CloseProgram(Prog)
EndIf