#NoTrayIcon FileToRead =Todo.txt ;replace "FILE.txt" by the name of the file to read Sum = 0 AutoTrim,Off Loop, Read, %FileToRead%,, { Flag=false Loop, parse, A_LoopReadLine, %A_Tab% { If Flag=true continue Sum +=%A_LoopField% Flag=true } } Random, Number, 1, Sum CompleteSum := Sum Sum = 0 Line = 0 Loop, Read, %FileToRead%,, { Line+=1 Flag=false Loop, parse, A_LoopReadLine, %A_Tab% { If Flag=true If Sum>=%Number% { Message=%A_LoopField% GoSub, Found Return } Sum +=%A_LoopField% Probability=%A_LoopField% Flag=true } } return Found: Percentage :=floor(Probability/CompleteSum*100) Gui, Add, Picture, x11 y11 Icon5, user32.dll Gui, Add, Button, gSave x78 y66 w75 h23 +default,&OK Gui, Add, Button, gRetry x158 y66 w75 h23,&Retry Gui, Add, Button, gGuiClose x239 y66 w75 h23 ,&Cancel Gui, Add, Edit, vNewProbability x10 y58 w32 h20 Limit4,%Probability% Gui, Font, s12 w700, Verdana Gui, Add, Text, x61 y10 w327 h38,[%Percentage%`%]%Message% Gui, Show, xCenter yCenter h101 w395, RandomLine Return GuiClose: ExitApp Save: Gui,Submit FileRead,CompleteFile,%FileToRead% StringReplace,CompleteFileModified,CompleteFile,``n,`n,ReplaceAll StringReplace,CompleteFile,CompleteFileModified,%probability%%A_Tab%%message%,%NewProbability%%A_Tab%%message% FileDelete,%FileToRead% FileAppend,%CompleteFile%,%FileToRead% ExitApp Retry: Reload