#SingleInstance Force Gui, Add, Text,, How big are your files? Find out. Press Alt-Q to exit. Gui, Add, Edit, r1 vPath -wantreturn, Full Path (Do not use quotes) Gui, Add, Text,, Please specify bytes, kilobytes, or megabytes. Gui, Add, Checkbox, Checked vBytes, Bytes? Gui, Add, Checkbox, vKB, KB? gui, Add, Checkbox, vMB, MB? Gui, Add, Button, Default, Go! Gui, Show,, Get File Sizes! Return ButtonGo!: Gui, Submit gui, Destroy If Bytes=0 { if KB=1 { filegetsize, Size, %Path%, K if MB+Bytes<1 { if Size is not integer { MsgBox, 0, Error, Please enter a valid path. Quotation marks are unnecessary. Exit App } Else if Size is integer { MsgBox, 0, File size, The file size of %Path% is %Size% KB. ExitApp } } } if KB=0 { if MB=1 { filegetsize, Size, %Path%, M If KB+Bytes<1 { if Size is not integer { MsgBox, 0, Error, Please enter a valid path. Quotation marks are unnecessary. ExitApp } Else if Size is integer { MsgBox, 0, File size, The file size of %Path% is %Size% MB. ExitApp } } } } } If Bytes=1 { filegetsize, Size, %Path% if KB+MB<1 { if Size is not integer { MsgBox, 0, Error, Please enter a valid path. Quotation marks are unnecessary. ExitApp } if Size is integer { MsgBox, 0, File size, The file size of %Path% is %Size% bytes. ExitApp } } } If Bytes+KB+MB=0 { MsgBox, 0, Error, Please check a box. ExitApp } If Bytes+KB+MB>1 { MsgBox, 0, Error, Please check only one box. ExitApp } !q:: ExitApp
File Get Size
Started by
Cauthon
, Apr 20 2006 04:10 PM
7 replies to this topic
A really simple program that I overdid by using Checkboxes, not radio buttons. I had to make sure no one checked more than one box.
#1
-
Posted 20 April 2006 - 04:10 PM
Hey, since when parentheses are not necessary to force expression evaluation in the If?
From my tests, it seems that the If becomes a If with expression if AutoHotkey see an expression before a comparison sign... Ie. if the part before the comparison isn't a pure variable name.
Argh, this changes my algorithm of the highlighting lexer for Scintilla!
From my tests, it seems that the If becomes a If with expression if AutoHotkey see an expression before a comparison sign... Ie. if the part before the comparison isn't a pure variable name.
Argh, this changes my algorithm of the highlighting lexer for Scintilla!
#2
-
Posted 20 April 2006 - 05:12 PM
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
[quote name="PhiLho"]Hey, since when parentheses are not necessary to force expression evaluation in the If?[/quote][quote name="Documentation]An if-statement that contains an expression is differentiated from a traditional-if such as If FoundColor <> Blue by making the character after the word "if" an open-parenthesis. Although this is usually accomplished by enclosing the entire expression in parentheses, it can also be done with something like if (x > 0) and (y > 0). In addition, the open-parenthesis may be omitted entirely if the first item after the word "if" is a function call or an operator such as "not" or "!".[/quote]
Good script Cauthon. However I'd suggest a browse button and a fileselectfile dialog for the file path field.
Good script Cauthon. However I'd suggest a browse button and a fileselectfile dialog for the file path field.
#3
-
Posted 20 April 2006 - 05:41 PM
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
Titan, I have re-read this section before writing my message, and I don't see anything stating that something like If a + b > c is legal... No opening parenthesis, no function call, no initial operator.
I guess this will be yet another rarely-used-feature that my lexer will not support...
This gives non-symetrical situations, where if a + b = c will not give the same result that if c = a + b...
Aah, legacy...
Cauthon: sorry for the off topic remarks!
As you wrote, you overdid it a bit, making manually the job of radio buttons. But that's a good programming challenge.
If you do the checks for validity earlier, you would avoid to do them for each case, you would just check if Bytes = 1 {} else if KB = 1 { } else if MB = 1 {}
I guess this will be yet another rarely-used-feature that my lexer will not support...
This gives non-symetrical situations, where if a + b = c will not give the same result that if c = a + b...
Aah, legacy...
Cauthon: sorry for the off topic remarks!
As you wrote, you overdid it a bit, making manually the job of radio buttons. But that's a good programming challenge.
If you do the checks for validity earlier, you would avoid to do them for each case, you would just check if Bytes = 1 {} else if KB = 1 { } else if MB = 1 {}
#5
-
Posted 21 April 2006 - 07:50 AM
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Just a tweak:
#SingleInstance Force Gui, Add, Text,, How big are your files? Find out. Press Alt-Q to exit. Gui, Add, Edit, r1 vPath -wantreturn, Full Path (Do not use quotes) Gui, Add, Text,, Please specify bytes, kilobytes, or megabytes. Gui, Add, Radio, Checked vRadSize, Bytes? Gui, Add, Radio, x+5 , KB? Gui, Add, Radio, x+5 , MB? Gui, Add, Button, Default, Go! Gui, Show,, Get File Sizes! Return ButtonGo!: Gui, Submit If (RadSize = 1){ Size = Unit = bytes }Else If (RadSize = 2){ Size = K Unit = KB }Else { Size = M Unit = MB } filegetsize, Size, %Path%, %Size% if Size is not integer MsgBox, 0, Error, Please enter a valid path. Quotation marks are unnecessary. Else MsgBox, 0, File size, The file size of %Path% is %Size% %Unit%. ExitApp Return GuiClose: !q:: ExitApp*not tested*
#6
-
Posted 21 April 2006 - 08:11 AM
Ciao
toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
Here is a different version with a browse button and a shorter calculating routine:
#NoEnv Gui, Add, Text, , This checks how big your files are: Gui, Add, Text, Section, File: Gui, Add, Edit, vFile xm+40 ys-3 w130 Gui, Add, Button, ys-2 h20 gBrowse, Browse Gui, Add, Text, Section xm, Sizes: Gui, Add, Checkbox, vBytes xm+40 ys Checked, Bytes Gui, Add, Checkbox, vKB ys Checked, KB Gui, Add, Checkbox, vMB ys Checked, MB Gui, Add, Button, xm ys+25 gDisplay, Display Gui, Show, , File Size Checker Return Browse: FileSelectFile, File, 3, %A_MyDocuments% GuiControl, , File, %File% Goto, Display Return Display: Gui, Submit, NoHide FileGetSize, Size, %File% If !Bytes and !KB and !MB Return IfEqual, Bytes, 1, SetEnv, Msg, `n%Size% bytes IfEqual, KB, 1, SetEnv, Msg, % Msg . "`n" . Size / 1024 . " kb" IfEqual, MB, 1, SetEnv, Msg, % Msg . "`n" . Size / 1024 /1024 . " mb" MsgBox, 64, File Size, The size of the file %File% is:`n%Msg% Msg = ; Return !q:: GuiClose: ExitApp
#7
-
Posted 21 April 2006 - 09:40 AM
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit