Chr(160), which looks like a Space, which cannot name a variable.
I tried typing it directly as well as with x := Chr(160) .. Both work fine.. Thanks!
Regards,
Chr(160), which looks like a Space, which cannot name a variable.
"Is there a way in autohotkey to determine whether a certain variable exists?"
"I would like to be able to tell the difference between a variable that does not exist and a variable that exists, but has an empty-string for a value."
Would be useful with #MustDeclareVars.is it possible to have in-built function like VarExist() to test Variables ?
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
Since there's IsLabel() already I would prefer to have IsVar().
SoundCard()
Returns the number of soundcards available on a system.
A script can test the target machine for availability of a soundcard before playing an audio file.SoundCard() { Return DllCall("winmm.dll\waveOutGetNumDevs") }
Example:If SoundCard() SoundPlay, %A_WinDir%\Media\The Microsoft Sound.wav, wait Return SoundCard() { Return DllCall("winmm.dll\waveOutGetNumDevs") }
I am surprised to find search does not reveal any requests for this :roll:
Anyways!,
AviFileInfo()
Returns the video properties of an AVI file as a pipe delimited string.
MSDN Reference:
AVIFILEINFO Structure : <!-- m -->http://msdn2.microso...y/ms706413.aspx<!-- m -->
AVIFileInit : <!-- m -->http://msdn2.microso...y/ms706415.aspx<!-- m -->
AVIFileOpen : <!-- m -->http://msdn2.microso...y/ms706420.aspx<!-- m -->
AVIFileInfo : <!-- m -->http://msdn2.microso...y/ms706309.aspx<!-- m -->
AVIFileRelease : <!-- m -->http://msdn2.microso...y/ms706528.aspx<!-- m -->
Here is the function along with a working example:; Written by A.N.Suresh Kumar AKA "Goyyah", 23-Nov-2006 ; Post: http://www.autohotkey.com/forum/viewtopic.php?p=91036#91036 Loop, %A_WinDir%\*.AVI { AviFileInfo := AviFileInfo(A_LoopFileLongPath) StringSplit, Field, AviFileInfo, | FPS := (Field8/Field7) ; FPS is dwRate / dwScale Duration := FormatSeconds(Round(Field9/FPS,0)) ; Duration is dwLength / FPS MsgBox, 0, Properties :: %A_LoopFileName%, ( FileFullPath `t: %A_LoopFileLongPath% FileSize `t: %A_LoopFileSizeKB% KB MaxBytesPerSec `t: %Field1% Flags `t: %Field2% Caps `t: %Field3% No Of Streams `t: %Field4% Sugg. BufferSize `t: %Field5% Video Size `t: %Field6% [color=red]Frames per second`t: %FPS% Duration `t: %Duration%[/color] Scale `t: %Field7% Rate `t: %Field8% Frames `t: %Field9% Edit Count `t: %Field10% File Type `t: %Field11% ) } Return [color=blue]AviFileInfo(AviFile)[/color] { VarSetCapacity( av, 108, 0 ) ; av = AVIFILEINFO structure DllCall( "avifil32.dll\AVIFileInit" ) DllCall( "avifil32.dll\AVIFileOpenA", Intp,hFile, Str,AVIFile , Int,0, Int,0 ) DllCall( "avifil32.dll\AVIFileInfoA", Int,hFile, Int,&av, Int,108 ) DllCall( "avifil32.dll\AVIFileRelease", Int,hFile ) mb := (*(&av+ [color=red]0[/color]))+(*(&av+ [color=red]1[/color])<<8)+(*(&av+ [color=red]2[/color])<<16)+(*(&av+ [color=red]3[/color])<<24) ; dwMaxBytesPerSec fl := (*(&av+ [color=red]4[/color]))+(*(&av+ [color=red]5[/color])<<8)+(*(&av+ [color=red]6[/color])<<16)+(*(&av+ [color=red]7[/color])<<24) ; dwFlags ca := (*(&av+ [color=red]8[/color]))+(*(&av+ [color=red]9[/color])<<8)+(*(&av+[color=red]10[/color])<<16)+(*(&av+[color=red]11[/color])<<24) ; dwCaps st := (*(&av+[color=red]12[/color]))+(*(&av+[color=red]13[/color])<<8)+(*(&av+[color=red]14[/color])<<16)+(*(&av+[color=red]15[/color])<<24) ; dwStreams sb := (*(&av+[color=red]16[/color]))+(*(&av+[color=red]17[/color])<<8)+(*(&av+[color=red]18[/color])<<16)+(*(&av+[color=red]19[/color])<<24) ; dwSuggBufferSize wi := (*(&av+[color=red]20[/color]))+(*(&av+[color=red]21[/color])<<8)+(*(&av+[color=red]22[/color])<<16)+(*(&av+[color=red]23[/color])<<24) ; dwWidth he := (*(&av+[color=red]24[/color]))+(*(&av+[color=red]25[/color])<<8)+(*(&av+[color=red]26[/color])<<16)+(*(&av+[color=red]27[/color])<<24) ; dwHeight sc := (*(&av+[color=red]28[/color]))+(*(&av+[color=red]29[/color])<<8)+(*(&av+[color=red]30[/color])<<16)+(*(&av+[color=red]31[/color])<<24) ; dwScale ra := (*(&av+[color=red]32[/color]))+(*(&av+[color=red]33[/color])<<8)+(*(&av+[color=red]34[/color])<<16)+(*(&av+[color=red]35[/color])<<24) ; dwRate le := (*(&av+[color=red]36[/color]))+(*(&av+[color=red]37[/color])<<8)+(*(&av+[color=red]38[/color])<<16)+(*(&av+[color=red]39[/color])<<24) ; dwLength ec := (*(&av+[color=red]40[/color]))+(*(&av+[color=red]41[/color])<<8)+(*(&av+[color=red]42[/color])<<16)+(*(&av+[color=red]43[/color])<<24) ; dwEditCount Loop, 64 ft := ft . Chr( *(&av+[color=red]43[/color]+(A_Index)) ) ; szFileType[64] Return mb "|" fl "|" ca "|" st "|" sb "|" wi "x" he "|" sc "|" ra "|" le "|" ec "|" ft } [color=blue]FormatSeconds(NumberOfSeconds)[/color] { ; Taken from AHK Documentation ( FormatTime ) time = 19990101 ; *Midnight* of an arbitrary date. time += %NumberOfSeconds%, seconds FormatTime, mmss, %time%, mm:ss return NumberOfSeconds//3600 ":" mmss }
Snapshots of the message boxes:
______
Edit Note: Do not be discouraged by the bit-shifting seen inside the AviFileInfo() function. It is actually easy to modify. You can keep what you want and delete the rest like the example follows:AviFileInfo(AviFile) { VarSetCapacity( av, 108, 0 ) ; av = AVIFILEINFO structure DllCall( "avifil32.dll\AVIFileInit" ) DllCall( "avifil32.dll\AVIFileOpenA", Intp,hFile, Str,AVIFile , Int,0, Int,0 ) DllCall( "avifil32.dll\AVIFileInfoA", Int,hFile, Int,&av, Int,108 ) DllCall( "avifil32.dll\AVIFileRelease", Int,hFile ) wi := (*(&av+20))+(*(&av+21)<<8)+(*(&av+22)<<16)+(*(&av+23)<<24) ; dwWidth he := (*(&av+24))+(*(&av+25)<<8)+(*(&av+26)<<16)+(*(&av+27)<<24) ; dwHeight Return wi "x" he ; only the video size }
Very nice.
I don't see why you didn't wrapped up the field reading in some function (I would have used my GetNextUInt function to even avoid any offset computing), as all these numbers are hard to read and maintain.
DriveSpace()
Returns the FreeSpace / Capacity of a Drive in bytes.
Parameter 1 should be a valid drive letter.
Parameter 2 should be 1 for fetching the freespace and 2 for retrieving the drive capacity.FreeSpace := DriveSpace("C:\", 1) DiskCapacity := DriveSpace("C:\", 2) MsgBox, 64,Drive C:, % "FreeSpace`t: " FreeSpace "`nDrive Capacity`t: " DiskCapacity Return DriveSpace(Drv="", Free=1) { DriveGet, Drives, List StringLeft, Drv, Drv, 1 If (!InStr(Drives,%Drv%)) Return -1 Drv := Drv . ":\" VarSetCapacity(SPC, 30, 0) ; Sectors Per Cluster VarSetCapacity(BPS, 30, 0) ; Bytes Per Sector VarSetCapacity(FC , 30, 0) ; Free Clusters VarSetCapacity(TC , 30, 0) ; Total Clusters DllCall("GetDiskFreeSpaceA", Str,Drv, UIntp,SPC , UIntp,BPS, UIntp,FC, UIntp,TC) Return Free=1 ? (SPC*BPS*FC) : (SPC*BPS*TC) ; Ternary Operator requires 1.0.46+ }
Requested at Ask For Help Topic : Hard Disk Drive
Thanks to PhiLho. DriveSpaceFreeBytes() was changed to DriveSpace() and now it also retrieves a drive's capacity.
DriveSpace( D="C:", M=1) { If DllCall( "GetDiskFreeSpaceA", Str,Chr(*(&D)) ":", UIntP,S, UIntP,B, UIntP,F, UIntP,T ) Return M ? (S*B*F) : (S*B*T) } FormatByteSize( I=0 ) { VarSetCapacity(F,16), DllCall( "shlwapi.dll\StrFormatByteSize64A", Int64,I,Str,F,Int,16 ) Return F }