Leaderboard
Popular Content
Showing content with the highest reputation on 01/11/2012 in all areas
-
Just to say, I think LazyCat did an awesome job on this. Anytime I need to create a GUI, I always start off with KODA. I don't build the entire GUI with it, but it's a great starting point and has saved a lot of time in the building process. 1. Project requests from others: Use KODA to get the basic layout that they want. 2. Save the Form so I can reuse on future GUI builds, or to go back and rearrange if called for. 3. Create additional Child GUI's a lot quicker by using KODA In a nutshell, thank you very much to LazyCat and all the others involved with it's creation.4 points
-
Permanent block. When I get up and find I have 3 PMs from somebody I've never heard of complaining because they were warned for breaking our rules (when they were breaking our rules)... well, you're going to go away. The PMs were real gems, though. So the user admits they lack intelligence. Can't think on the fly? Hah. Apparently can't think when given all the time in the world, either, or they wouldn't have PMed the person voted most likely to block your ass. Second PM was just a copy/paste of the PM the user received from a moderator. The third one is pretty good, though: "Bad accusing"? Seems pretty good accusing to me. The only thing bad the moderator did was not listen to his gut instinct to make this nutter go away from the start. That's the "mess" that I've cleaned up.1 point
-
1 point
-
Compare OS Version
Chris_1013 reacted to wraithdu for a topic
This should be a future proof OS version compare function. I've been burned a few times with old scripts using @OSVersion to do version detection when a new OS (like Windows 7) comes out, since @OSVersion tests are usually done explicitly (If @OSVersion = "WIN_VISTA"...). I've had this laying around for a bit but didn't release it due to a bug in AutoIt < 3.3.1.0. But then it meant it would only work with >= 3.3.1.0, and older versions of AutoIt would get incorrect results, but no errors. Many people still run old versions of AutoIt so that's not cool. I came up with a suitable workaround today so here it is. It can easily be extended to test all kinds of OS properties: Build Number, Platform ID, Product Type, Suite Name. But this is solely aimed at testing version info: major and minor version, service pack major and minor version. In fact according to MSDN, all four of these must be tested at once, not individually. Usage is pretty straight forward, decide on a test and which version numbers you are interested in. If not @error, 0 means the comparison is false, 1 means the comparison is true. If the function returns @error, check the return: 1 means check @Extended for the source of the error, 2 means GetLastError failed which means the outcome of the function is unknowable. Value of @extended: 1 means the error is from DllCall, 2 means the error is from GetLastError. #include-once #cs Windows 7 6.1 Windows Server 2008 R2 6.1 Windows Server 2008 6.0 Windows Vista 6.0 Windows Server 2003 R2 5.2 Windows Server 2003 5.2 Windows XP 5.1 Windows 2000 5.0 #ce ;*** Constants ; dwTypeBitMask Global Const $VER_BUILDNUMBER = 0x0000004 Global Const $VER_MAJORVERSION = 0x0000002 Global Const $VER_MINORVERSION = 0x0000001 Global Const $VER_PLATFORMID = 0x0000008 Global Const $VER_PRODUCT_TYPE = 0x0000080 Global Const $VER_SERVICEPACKMAJOR = 0x0000020 Global Const $VER_SERVICEPACKMINOR = 0x0000010 Global Const $VER_SUITENAME = 0x0000040 ; dwConditionMask Global Const $VER_EQUAL = 1 Global Const $VER_GREATER = 2 Global Const $VER_GREATER_EQUAL = 3 Global Const $VER_LESS = 4 Global Const $VER_LESS_EQUAL = 5 ; if dwTypeBitMask is VER_SUITENAME Global Const $VER_AND = 6 Global Const $VER_OR = 7 ; #FUNCTION# ;=============================================================================== ; ; Name...........: _OsVersionTest ; Description ...: Compares OS Version Info ; Syntax.........: _OsVersionTest($iTest, $osMajor, $osMinor = 0, $spMajor = 0, $spMinor = 0) ; Parameters ....: $iTest - type of test to perform ; $osMajor - OS major version number ; $osMinor - OS minor version number ; $spMajor - service pack major version number ; $spMinor - service pack minor version number ; Return values .: Success - Returns nonzero value if the comparison is true, 0 if it is false ; Failure - Sets @Error ; Return values: ; | 1 - Check @Extended ; | 2 - GetLastError failed, we have no way to know the outcome of the function ; @Extended holds the source of @Error: ; | 1 - DllCall error ; | 2 - Function error from GetLastError ; Author ........: Erik Pilsits ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; ; ;========================================================================================== Func _OsVersionTest($iTest, $osMajor, $osMinor = 0, $spMajor = 0, $spMinor = 0) Local Const $OSVERSIONINFOEXW = "dword dwOSVersionInfoSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformId;" & _ "wchar szCSDVersion[128];ushort wServicePackMajor;ushort wServicePackMinor;ushort wSuiteMask;byte wProductType;byte wReserved" Local $dwlConditionalMask = 0 ; initialize structure Local $OSVI = DllStructCreate($OSVERSIONINFOEXW) DllStructSetData($OSVI, "dwOSVersionInfoSize", DllStructGetSize($OSVI)) ; set data we want to compare DllStructSetData($OSVI, "dwMajorVersion", $osMajor) DllStructSetData($OSVI, "dwMinorVersion", $osMinor) DllStructSetData($OSVI, "wServicePackMajor", $spMajor) DllStructSetData($OSVI, "wServicePackMinor", $spMinor) ; check AutoIt version ; -1 = version 2 is greater...this is bad, DllCall() int64 return was fixed in 3.3.1.0 Local $IsBadAutoIt = (__VersionCompare(@AutoItVersion, "3.3.1.0") = -1) ; initialize and set the mask VerSetConditionMask($VER_MAJORVERSION, $iTest, $dwlConditionalMask, $IsBadAutoIt) VerSetConditionMask($VER_MINORVERSION, $iTest, $dwlConditionalMask, $IsBadAutoIt) VerSetConditionMask($VER_SERVICEPACKMAJOR, $iTest, $dwlConditionalMask, $IsBadAutoIt) VerSetConditionMask($VER_SERVICEPACKMINOR, $iTest, $dwlConditionalMask, $IsBadAutoIt) ; perform test Return VerifyVersionInfo(DllStructGetPtr($OSVI), BitOR($VER_MAJORVERSION, $VER_MINORVERSION, $VER_SERVICEPACKMAJOR, $VER_SERVICEPACKMINOR), $dwlConditionalMask) EndFunc ;;;INTERNAL;;; Func VerSetConditionMask($dwTypeBitMask, $dwConditionMask, ByRef $dwlConditionalMask, $IsBadAutoIt) Local $ret = DllCall("kernel32.dll", "uint64", "VerSetConditionMask", "uint64", $dwlConditionalMask, "dword", $dwTypeBitMask, "byte", $dwConditionMask) If Not @error Then If $IsBadAutoIt Then ; fix for bad DllCall() int64 return value $dwlConditionalMask = _ReOrderULONGLONG($ret[0]) Else $dwlConditionalMask = $ret[0] EndIf EndIf EndFunc Func VerifyVersionInfo($lpVersionInfo, $dwTypeMask, $dwlConditionalMask) Local Const $ERROR_OLD_WIN_VERSION = 1150 ; dwTypeMask is a BitOR'd combination of the conditions we want to test Local $ret = DllCall("kernel32.dll", "int", "VerifyVersionInfoW", "ptr", $lpVersionInfo, "dword", $dwTypeMask, "uint64", $dwlConditionalMask) If Not @error Then ; test for function error If $ret[0] Then Return $ret[0] ; comparison is true Else ; function returned 0, we have to check GetLastError to see if there was an error $ret = DllCall("kernel32.dll", "dword", "GetLastError") If Not @error Then If $ret[0] = $ERROR_OLD_WIN_VERSION Then Return 0 ; no error, the version comparison was false Else Return SetError($ret[0], 2, 1) ; we have a real error EndIf Else Return SetError(1, 0, 2) ; this would suck, but shouldn't happen EndIf EndIf Else Return SetError(@error, 1, 1) ; DllCall error EndIf EndFunc Func _ReOrderULONGLONG($UINT64) Local $s_uint64 = DllStructCreate("uint64") Local $s_ulonglong = DllStructCreate("ulong;ulong", DllStructGetPtr($s_uint64)) DllStructSetData($s_uint64, 1, $UINT64) Local $val = DllStructGetData($s_ulonglong, 1) DllStructSetData($s_ulonglong, 1, DllStructGetData($s_ulonglong, 2)) DllStructSetData($s_ulonglong, 2, $val) Return DllStructGetData($s_uint64, 1) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _VersionCompare ; Description ...: Compares two file versions for equality ; Syntax.........: _VersionCompare($sVersion1, $sVersion2) ; Parameters ....: $sVersion1 - IN - The first version ; $sVersion2 - IN - The second version ; Return values .: Success - Following Values: ; | 0 - Both versions equal ; | 1 - Version 1 greater ; |-1 - Version 2 greater ; Failure - @error will be set in the event of a catasrophic error ; Author ........: Valik ; Modified.......: ; Remarks .......: This will try to use a numerical comparison but fall back on a lexicographical comparison. ; See @extended for details about which type was performed. ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func __VersionCompare($sVersion1, $sVersion2) If $sVersion1 = $sVersion2 Then Return 0 Local $sep = "." If StringInStr($sVersion1, $sep) = 0 Then $sep = "," Local $aVersion1 = StringSplit($sVersion1, $sep) Local $aVersion2 = StringSplit($sVersion2, $sep) If UBound($aVersion1) <> UBound($aVersion2) Or UBound($aVersion1) = 0 Then ; Compare as strings SetExtended(1) If $sVersion1 > $sVersion2 Then Return 1 ElseIf $sVersion1 < $sVersion2 Then Return -1 EndIf Else For $i = 1 To UBound($aVersion1) - 1 ; Compare this segment as numbers If StringIsDigit($aVersion1[$i]) And StringIsDigit($aVersion2[$i]) Then If Number($aVersion1[$i]) > Number($aVersion2[$i]) Then Return 1 ElseIf Number($aVersion1[$i]) < Number($aVersion2[$i]) Then Return -1 EndIf Else ; Compare the segment as strings SetExtended(1) If $aVersion1[$i] > $aVersion2[$i] Then Return 1 ElseIf $aVersion1[$i] < $aVersion2[$i] Then Return -1 EndIf EndIf Next EndIf ; This point should never be reached Return SetError(2, 0, 0) EndFunc ;==>_VersionCompare Example: ConsoleWrite("Is Vista or Greater: " & _OsVersionTest($VER_GREATER_EQUAL, 6) & @CRLF) ConsoleWrite("Is Win7: " & _OsVersionTest($VER_EQUAL, 6, 1) & @CRLF) ConsoleWrite("Is Less that XP SP2: " & _OsVersionTest($VER_LESS, 5, 1, 2) & @CRLF)1 point -
Excel LockAspectRatio in AutoIt
footswitch reacted to PsaltyDS for a topic
Try the following to see what works in that context: .LockAspectRatio = msoTrue ; This doesn't work !!! .LockAspectRatio = True ; Or .LockAspectRatio = -1 ; Or .LockAspectRatio = 1 I'm betting on -1 working, and maybe the native AutoIt "True" keyword. Edit: Fixed code tags1 point