Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/18/2019 in all areas

  1. 😀 This is the very first time I have posted anything on this Forum. I have been using AutoIt since 2006 believe it or not I have attached a script here that holds info that may help someone who is having a hard time understanding how to detect double clicking inside a ListView. It has lots (and I mean lots!) of comments through out the script. Hope this helps! DoubleClickListView.au3
    1 point
  2. mikell

    Drove me silly (Solved)

    Hmm. FYI this can be done in one go using SRER (hoping that I understood the whole thing correctly) $sString = @LF & 'Local $idUndo = GUICtrlCreateButton(Chr(76), 359, 44, 25, 24)' & @LF & _ 'GUICtrlSetFont(-1, 13, 601, -1, "WingDings 3")' & @LF & _ 'GUICtrlSetTip($idUndo, "Undo")' & @LF & _ 'Local $idRedo = GUICtrlCreateButton(Chr(80), 386, 44, 23, 24)' & @LF & @LF & _ ;<<<<< 'GUICtrlSetFont(-1, 13, 602, -1, "WingDings 3")' & @LF & " " & @LF & _ ;<<<<< 'GUICtrlSetTip( - 1, "Redo")' & @LF & _ ;<<<<< 'Some other line 1' & @LF & _ 'Local $idtest = GUICtrlCreateButton(Chr(80), 386, 44, 23, 24)' & @LF & _ 'GUICtrlSetFont(-1, 13, 603, -1, "WingDings 3")' & @LF & _ 'GUICtrlSetData( $idtest, "test")' & @LF & _ 'GUICtrlSetData( $idRedo, "Redo")' & @LF & _ ;<<<<< 'GUICtrlSetData( -1, "test")' & @LF & _ 'Some other line 2' $sSearch = 'Local $idRedo = GUICtrlCreateButton(Chr(80), 386, 44, 23, 24)' $var = StringRegExpReplace($sSearch, '.*?(\$[^\h=]+).*', "$1") ;msgbox(0,"", $var) $pattern = '(\Q' & $sSearch & '\E\s+(.*?\(\h*-\h*1\h*,.*\s+)*)|(.*?\(\h*\Q' & $var & '\E.*\s+)' $res = StringRegExpReplace($sString, $pattern, "") msgbox(0,"", $res) But it probably could be done even simpler
    1 point
  3. According to the help file: Send - Sends simulated keystrokes to the active window. To send data to inactive windows you can either try to automate the GUI by using Control* functions or use COM to directly interact with the programs API and avoid the GUI. It would help if you could tell us which program you REALLY try to automate at the end.
    1 point
  4. I don't know the purpose of this code but please note some details : with your example the multiline option is useless, grouping is not necessary because you don't use backreferences, and \n+\n+ is redundant $sString = "Test" & @LF & _ 'Local $Clear_Button = GUICtrlCreateButton("Clear", 313, 211, 50, 20")' & @LF& @LF & _ '(GUICtrlSetTip(-1, "Clear all Check Boxes")' $s = 'Local \$Clear_Button = GUICtrlCreateButton\("Clear", 313, 211, 50, 20"\)\n+\(GUICtrlSetTip\(\-1, "Clear all Check Boxes"\)' $sString = StringRegExpReplace($sString, $s, "") MsgBox(0, '', $sString)
    1 point
  5. wingethandle("[ACTIVE]") will return current active window handle (can return handle for another window than notebad ) ,so use this code instead $VAR_NotepadHWND =WinGetHandle("[CLASS:Notepad]") second , dont forget the Control ID in ControlSend so it should be :- Func Sim() Return ControlSend($VAR_NotepadHWND, "", "Edit1" , "Hello World !!") ;ControlID EndFunc
    1 point
  6. @Deye Modifiers must be enclosed by separated round parentheses, so, (?m:Local should be (?m)(Local...)
    1 point
  7. @kompass22 In order to try HotKeySet() you should set a While loop in which you just put a Sleep(100), so the script handles since you do something (press a key, for example). Take a look at the examples about HotKeySet() in the Help file
    1 point
  8. czardas

    Fraction

    Perform accurate division using real fractions and convert floating point numbers to fractions. Floating point arithmetic often introduces small inaccuracies. Most of the time this is not a problem, but sometimes it can be. As a workaround, many programmers decide to only use whole numbers for specific calculations - ones which need to return exact results. The fraction 1/3 cannot be represented using a float. You would need a decimal (or floating point variant) of infinite length to give an accurate representation of 1/3. Working with fractions is not entirely straight forward, and at times this can be a little frustrating. With the functions in this library, there is potential for internal calculations to produce numbers which are out of range. Not withstanding oversights: both input numbers should be less than 16 digits and the difference between the denominator and the divisor should be an order of magnitude less than 10^16, otherwise the function will return an error. With the exception of Fraction(), all included functions take array parameters. All return values are either arrays or boolean values. Documentation and examples pending. NEW VERSION requires operator64.au3 found here: https://www.autoitscript.com/forum/topic/176620-operator64/ This is an alpha release -see post 33. #include-once #include 'operator64.au3' ; #INDEX# ====================================================================================================================== ; Title .........: Fraction ; AutoIt Version : 3.3.14.0 ; Language ......: English ; Description ...: Maths functions intended to be used with vulgar fractions. ; Notes .........: In this library, a fraction is defined as two integers stored in a two element array. ; Several functions use approximation when internal calculations go out of range. ; When an approximation occurs, @extended is set to 1. This return value should be checked in most instances. ; ----------------------------------------------------------------------------------------------------------- ; Input Size Limits for _Fraction() ; Unlimited within the confines of AutoIt (approximately) between -1e+308 and +1e+308 ; Smallest value (approximately) 1e-323 ; -------------------------------------------------------------------- ; Negative Output Size Limits for All Functions That Return a Fraction ; 9223372036854775807 /-1 To -1/ 9223372036854775807 negative range ; - 2^63 /1 Out of range ; tiny negative values are either rounded down to -1/ 9223372036854775807 or rounded up to 0/-1 ; ---------------------------------------------------------------- ; Positive Output Size Limits for Functions That Return a Fraction ; 1/ 9223372036854775807 To 9223372036854775807 /1 positive range ; 2^63 /1 Out of range ; tiny positive values are either rounded up to 1/ 9223372036854775807 or rounded down to 0/1 ; Author(s) .....: czardas, Pheonix XL ; ============================================================================================================================== ; #CURRENT# ==================================================================================================================== ; _Fraction ; _FractionAbs ; _FractionAdd ; _FractionApproximate ; _FractionCeiling ; _FractionDivide ; _FractionFloor ; _FractionMod ; _FractionMultiply ; _FractionPower ; _FractionRoot ; _FractionSubtract ; _IsFraction ; _IsFractionNegative ; _Reciprocal ; ============================================================================================================================== ; #INTERNAL_USE_ONLY#=========================================================================================================== ; __GCD ; __FloatRatio ; __FloatToDigits ; __Quotient ; __Simplify ; ============================================================================================================================== ; #FUNCTION# =================================================================================================================== ; Name...........: _Fraction ; Description ...: Conversion from float to fraction and whole number division. ; Syntax.........: _Fraction($nDividend [, $nDivisor = 1]) ; Parameters.....; $iDividend - Top fractional part ; $iDivisor - [Optional] Lower fractional part. The default value is 1. ; Return Values ; Success - Returns an array of two elements. The first element is the dividend, and the second is the divisor. ; Sets @Extended to 1 if rounding or approximation occurs, or if one of the input parameters is a float. ; Failure sets @error as follows ; |@error = 1 Input contains non-numeric or undefined data. ; |@error = 2 The divisor cannot be zero. ; |@error = 3 Out of range. ; Author ........: czardas ; Comments ......; Accepts Int32, Int64 and floats. Output ranges are shown in the main header. ; ============================================================================================================================== Func _Fraction($nDividend, $nDivisor = 1) If Not IsNumber($nDividend) Or StringInStr($nDividend, '#') Or _ Not IsNumber($nDivisor) Or StringInStr($nDivisor, '#') Then Return SetError(1) ; non-numeric input or undefined value If $nDivisor = 0 Then Return SetError(2) ; division by zero produces meaningless results Local $iExtended = 0 ; will be set to 1 if rounding or approximation occurs, or if one of the input parameters is a float $nDividend = __Integer64($nDividend) If @error Or $nDividend = 0x8000000000000000 Then $iExtended = 1 $nDivisor = __Integer64($nDivisor) If @error Or $nDivisor = 0x8000000000000000 Then $iExtended = 1 Local $aFraction[2] ; if both the dividend and divisor are negative, then both output values will be positive $aFraction[0] = ($nDividend < 0 And $nDivisor > 0) ? -1 : 1 $aFraction[1] = ($nDivisor < 0 And $nDividend > 0) ? -1 : 1 If $iExtended Then ; float parameters require preprocessing $nDividend = Number($nDividend, 3) $nDivisor = Number($nDivisor, 3) __FloatRatio($nDividend, $nDivisor) If @error Then Return SetError(3) ; out of range EndIf If $nDividend = 0 Then $aFraction[0] = 0 $aFraction[1] = $nDivisor > 0 ? 1 : -1 ; a fraction may have a value of negative zero (purpose unknown) Return $aFraction EndIf $nDividend = _Abs64($nDividend) $nDivisor = _Abs64($nDivisor) If $nDividend <> 0 Then __Simplify($nDividend, $nDivisor) ; division by the greatest common divisor $aFraction[0] *= $nDividend ; return values may be negative $aFraction[1] *= $nDivisor ; as above. Return SetExtended($iExtended, $aFraction) EndFunc ;==> _Fraction ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionAbs ; Description ...: Calculates the absolute value of a fraction. ; Syntax.........: _FractionAbs($aFraction) ; Parameters.....; $aFraction - A two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array containing the absolute values of both dividend and divisor. ; Failure sets @error to 1 if the input is not a valid array containing both a dividend and a divisor. ; Author ........: czardas ; ============================================================================================================================== Func _FractionAbs($aFraction) If Not _IsFraction($aFraction) Then Return SetError(1) $aFraction[0] = _Abs64($aFraction[0]) $aFraction[1] = _Abs64($aFraction[1]) Return $aFraction EndFunc ;==> _FractionAbs ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionAdd ; Description ...: Calculates the sum of two fractions. ; Syntax.........: _FractionAdd($aFraction1, $aFraction2) ; Parameters.....; $aFraction1 - The first two element array containing a dividend and a divisor. ; $aFraction2 - The second two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array containing the sum of the two fractions. ; Sets @Extended to 1 if rounding or approximation occurs. ; Failure sets @error as follows ; |@error = 1 Invalid input. ; |@error = 2 The divisor cannot become zero. ; |@error = 3 Out of range. ; Author ........: czardas ; ============================================================================================================================== Func _FractionAdd($aFraction1, $aFraction2) If Not (_IsFraction($aFraction1) And _IsFraction($aFraction2)) Then Return SetError(1) Local $iValue_1, $iValue_2, $iDividend, $iDivisor, $iExtended = 0 If __OverflowDetect('*', $aFraction1[0], $aFraction2[1], $iValue_1) Then $iExtended = 1 If __OverflowDetect('*', $aFraction1[1], $aFraction2[0], $iValue_2) Then $iExtended = 1 If __OverflowDetect('+', $iValue_1, $iValue_2, $iDividend) Then $iExtended = 1 If __OverflowDetect('*', $aFraction1[1], $aFraction2[1], $iDivisor) Then $iExtended = 1 Local $aAddition = _Fraction($iDividend, $iDivisor) If @extended Then $iExtended = 1 Return SetError(@error, $iExtended, $aAddition) EndFunc ;==> _FractionAdd ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionApproximate ; Description ...: Approximates the value of a fraction according to limits imposed on the size of the divisor. ; Syntax.........: _FractionApproximate($aFraction, $iMaxDivisor) ; Parameters.....; $aFraction - A two element array containing a valid dividend and divisor. ; $iMaxDivisor - The maximum numeric limit for the divisor. ; Return values .: Success - Returns a two element array containing the approximated fraction. ; Failure sets @error as follows ; |@error = 1 Invalid input for $aFraction. ; |@error = 2 Invalid input for $iMaxDivisor. ; Author ........: czardas ; Comments ......; Approximates fractions using the method of continued fractions. ; ============================================================================================================================== Func _FractionApproximate($aFraction, $iMaxDivisor) If Not _IsFraction($aFraction) Then Return SetError(1) Local $bNegative = @extended $iMaxDivisor = _Abs64($iMaxDivisor) If @extended Then Return SetError(2, 0, $aFraction) Local $aCurrentFraction = _FractionAbs($aFraction) If $iMaxDivisor < 1 Or $iMaxDivisor >= $aCurrentFraction[1] Or $aCurrentFraction[1] <= 1 Then Return SetError(2, 0, $aFraction) ; determine the terms of the continued fraction Local $sFractionOfFraction = '' Do $sFractionOfFraction &= __Quotient($aCurrentFraction[0], $aCurrentFraction[1]) & ',' $aCurrentFraction[0] = Mod($aCurrentFraction[0], $aCurrentFraction[1]) $aCurrentFraction = _Reciprocal($aCurrentFraction) Until @error Local $aContinued = StringSplit(StringTrimRight($sFractionOfFraction, 1), ',', 2) Local $iTry, $iRange, $iMin = 0, $iMax = Ubound($aContinued) -1, $aConvergence[2] ; binary search algorithm Do $aConvergence[0] = 0 $aConvergence[1] = 1 $iRange = $iMax - $iMin +1 $iTry = $iMin + Floor($iRange/2) If $iTry > $iMax Then $iTry = $iMax ; added patch ; evaluate the significant first few terms of the continued fraction If $iTry > 0 Then For $i = $iTry To 1 Step -1 $aConvergence = _FractionAdd($aConvergence, _Fraction(Number($aContinued[$i]))) $aConvergence = _Reciprocal($aConvergence) Next EndIf $aConvergence = _FractionAdd($aConvergence, _Fraction(Number($aContinued[0]))) If $aConvergence[1] > $iMaxDivisor Then ; aim was too high - target is lower $iMax = $iTry -1 Else ; aim was too low - target may be higher ; log low entry $aCurrentFraction = $aConvergence $iMin = $iTry +1 EndIf Until $iRange <= 1 If $bNegative Then $aCurrentFraction[(($aFraction[0] < 0) ? 0 : 1)] *= -1 Return $aCurrentFraction EndFunc ;==> _FractionApproximate ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionCeiling ; Description ...: Calculates the ceiling value of a fraction. ; Syntax.........: _FractionCeiling($aFraction) ; Parameters.....; $aFraction - A two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array ==> The first element is the ceiling value, and the divisor is always 1. ; Failure sets @error as follows ; |@error = 1 The input is not a valid array containing a dividend and a divisor. ; Author ........: czardas ; Comments ......; If the fraction is negative, then its ceiling value represents the integer part of the fraction. ; ============================================================================================================================== Func _FractionCeiling($aFraction) If Not _IsFraction($aFraction) Then Return SetError(1) Local $bNegative = @extended If $aFraction[0] = 0 Then Return $aFraction ; for this to work we need to simplify the fraction $aFraction = _FractionAbs($aFraction) Local $iDividend = $aFraction[0], $iDivisor = $aFraction[1] __Simplify($iDividend, $iDivisor) If $iDivisor = 1 Then Return _Fraction($iDividend * ($bNegative = 0 ? 1 : -1)) Local $iCeiling = __Quotient($iDividend, $iDivisor) If $bNegative Then Return _Fraction($iCeiling * -1) Return _Fraction($iCeiling + 1) EndFunc ;==> _FractionCeiling ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionDivide ; Description ...: Divides the first fraction by the second. ; Syntax.........: _FractionDivide($aDividend, $aDivisor) ; Parameters.....; $aDividend - The first two element array containing a dividend and a divisor. ; $aDivisor - The second two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array containing the result after division. ; Sets @Extended to 1 if rounding or approximation occurs. ; Failure sets @error as follows ; |@error = 1 Invalid input. ; |@error = 2 The divisor cannot become zero. ; |@error = 3 Out of range. ; Author ........: czardas ; ============================================================================================================================== Func _FractionDivide($aDividend, $aDivisor) If Not (_IsFraction($aDividend) And _IsFraction($aDivisor)) Then Return SetError(1) Local $iValue_1, $iValue_2, $iExtended = 0 If __OverflowDetect('*', $aDividend[0], $aDivisor[1], $iValue_1) Then $iExtended = 1 If __OverflowDetect('*', $aDividend[1], $aDivisor[0], $iValue_2) Then $iExtended = 1 If $aDivisor[0] = 0 Then Return SetError(2) Local $aDivision = _Fraction($iValue_1, $iValue_2) If @extended Then $iExtended = 1 Return SetError(@error, $iExtended, $aDivision) EndFunc ;==> _FractionDivide ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionFloor ; Description ...: Calculates the floor value of a fraction. ; Syntax.........: _FractionFloor($aFraction) ; Parameters.....; $aFraction - A two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array ==> The first element is the floor value, and the divisor is always 1. ; Failure sets @error as follows ; |@error = 1 The input is not a valid array containing a dividend and a divisor. ; Author ........: czardas ; Comments ......; If the fraction is positive, then its floor value represents the integer part of the fraction. ; ============================================================================================================================== Func _FractionFloor($aFraction) If Not _IsFraction($aFraction) Then Return SetError(1) Local $bNegative = @extended If $aFraction[0] = 0 Then Return $aFraction ; for this to work we need to simplify the fraction $aFraction = _FractionAbs($aFraction) Local $iDividend = $aFraction[0], $iDivisor = $aFraction[1] __Simplify($iDividend, $iDivisor) If $iDivisor = 1 Then Return _Fraction($iDividend * ($bNegative = 0 ? 1 : -1)) Local $iFloor = __Quotient($iDividend, $iDivisor) If Not $bNegative Then Return _Fraction($iFloor) Return _Fraction($iFloor * -1 - 1) EndFunc ;==> _FractionFloor ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionMod ; Description ...: Performs the modulus operation with two fractions. ; Syntax.........: _FractionMod($aDividend, $aDivisor) ; Parameters.....; $aDividend - The first fraction is the dividend array. ; $aDivisor - The second fraction is the divisor array. ; Return values .: Success - Returns a two element array containing the modulus of $aDividend and $aDivisor. ; Sets @Extended to 1 if rounding or approximation occurs. ; Failure sets @error to: ; |@error = 1 Out of bounds - Fraction division failure. ; |@error = 2 Out of bounds - Fraction multiplication failure. ; |@error = 3 Out of bounds - Fraction subtraction failure. ; Author ........: czardas ; ============================================================================================================================== Func _FractionMod($aDividend, $aDivisor) Local $iExtended = 0, $aDivision = _FractionDivide($aDividend, $aDivisor) If @error Then Return SetError(1) If @extended Then $iExtended = @extended Local $aModulus[2] If $aDividend[0] = 0 Then $aModulus[0] = 0 $aModulus[1] = ($aDividend[0] < 0) ? -1 : 1 Return $aModulus EndIf Local $aMultiple = _FractionMultiply(_FractionAbs($aDivisor), _FractionFloor(_FractionAbs($aDivision))) If @error Then Return SetError(2) If @extended Then $iExtended = @extended $aModulus = _FractionSubtract(_FractionAbs($aDividend), $aMultiple) If @error Then Return SetError(3) If @extended Then $iExtended = @extended If _IsFractionNegative($aDividend) Then If $aDividend[0] < 0 Then $aModulus[0] *= -1 Else $aModulus[1] *= -1 EndIf EndIf Return SetExtended($iExtended, $aModulus) EndFunc ;==> _FractionMod ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionMultiply ; Description ...: Calculates the product of two fractions. ; Syntax.........: _FractionMultiply($aFraction1, $aFraction2) ; Parameters.....; $aFraction1 - The first two element array containing a dividend and a divisor. ; $aFraction2 - The second two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array containing the product of the two fractions. ; Sets @Extended to 1 if rounding or approximation occurs. ; Failure sets @error as follows ; |@error = 1 Invalid input. ; |@error > 1 Internal calculations went out of range. ; Author ........: czardas ; ============================================================================================================================== Func _FractionMultiply($aFraction1, $aFraction2) If Not (_IsFraction($aFraction1) And _IsFraction($aFraction2)) Then Return SetError(1) Local $iValue_1, $iValue_2, $iExtended = 0 If __OverflowDetect('*', $aFraction1[0], $aFraction2[0], $iValue_1) Then $iExtended = 1 If __OverflowDetect('*', $aFraction1[1], $aFraction2[1], $iValue_2) Then $iExtended = 1 Local $aProduct = _Fraction($iValue_1, $iValue_2) If @extended Then $iExtended = 1 Return SetError(@error, $iExtended, $aProduct) EndFunc ;==> _FractionMultiply ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionPower ; Description ...: Raises a fraction to the power of a fraction. ; Syntax.........: _FractionPower($aFraction, $aPower) ; Parameters.....; $aFraction - The first two element array containing a dividend and a divisor. ; $aPower - The second two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array containing $aFraction to the power of $aPower. ; Sets @Extended to 1 if rounding or approximation occurs. ; Failure sets @error as follows ; |@error = 1 Invalid input. ; |@error = 3 Out of range. ; |@error = 5 Imaginary fraction detected. ; Author ........: czardas ; Comments ......; Calculating fractional powers of approximated negative fractions leads to ambiguity. ; ============================================================================================================================== Func _FractionPower($aFraction, $aPower) If Not _IsFraction($aPower) Then Return SetError(1) Local $bNegative = _IsFractionNegative($aFraction) If @error Then Return SetError(1) If $bNegative And Mod($aPower[1], 2) = 0 Then Return SetError(5) Local $iSign = ($bNegative And Mod($aPower[0], 2) <> 0) ? -1 : 1 $aFraction = _FractionAbs($aFraction) Local $iExtended, $iPower = __WholeNumberDivision($aPower[0], $aPower[1]) If @extended Then $iExtended = 1 Local $iDividend If $iExtended Then $iDividend = $aFraction[0] ^ $iPower Else $iDividend = _Power64($aFraction[0], $iPower) If @extended Then $iExtended = 1 EndIf Local $iDivisor If $iExtended Then $iDivisor = $aFraction[1] ^ $iPower Else $iDivisor = _Power64($aFraction[1], $iPower) If @extended Then $iExtended = 1 EndIf $aPower = _Fraction($iSign * $iDividend, $iDivisor) If @extended Then $iExtended = 1 Return SetError(@error, $iExtended, $aPower) EndFunc ;==> FractionPower ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionRoot ; Description ...: Calculates the fractional root of a fraction. ; Syntax.........: _FractionRoot($aFraction, $aRoot) ; Parameters.....; $aFraction - The first two element array containing a dividend and a divisor. ; $aRoot - The second two element array containing a dividend and a divisor. ; Return values .: Success - Returns a two element array containing $aFraction to the power of the reciprocal of $aRoot. ; Sets @Extended to 1 if rounding or approximation occurs. ; Failure sets @error as follows ; |@error = 1 Invalid input. ; |@error = 3 Out of range. ; |@error = 5 Imaginary fraction detected. ; Author ........: czardas ; Comments ......; Calculating fractional roots of approximated negative fractions leads to ambiguity. ; ============================================================================================================================== Func _FractionRoot($aFraction, $aRoot) If Not _IsFraction($aRoot) Then Return SetError(1) Local $bNegative = _IsFractionNegative($aFraction) If @error Then Return SetError(1) If $bNegative And Mod($aRoot[0], 2) = 0 Then Return SetError(5) Local $iSign = ($bNegative And Mod($aRoot[1], 2) <> 0) ? -1 : 1 $aFraction = _FractionAbs($aFraction) Local $iExtended, $iRoot = __WholeNumberDivision($aRoot[0], $aRoot[1]) If @extended Then $iExtended = 1 Local $iDividend If $iExtended Then $iDividend = $aFraction[0] ^ (1 / $iRoot) Else $iDividend = _Root64($aFraction[0], $iRoot) If @extended Then $iExtended = 1 EndIf Local $iDivisor If $iExtended Then $iDivisor = $aFraction[1] ^ (1 / $iRoot) Else $iDivisor = _Root64($aFraction[1], $iRoot) If @extended Then $iExtended = 1 EndIf $aRoot = _Fraction($iSign * $iDividend, $iDivisor) If @extended Then $iExtended = 1 Return SetError(@error, $iExtended, $aRoot) EndFunc ;==> FractionRoot ; #FUNCTION# =================================================================================================================== ; Name...........: _FractionSubtract ; Description ...: Subtracts the second fraction from the first. ; Syntax.........: _FractionSubtract($aFraction1, $aFraction2) ; Parameters.....; $aFraction1 - The first two element array containing a dividend and a divisor. ; $aFraction2 - The second two element array containing a dividend and a divisor (subtracted from $aFraction1). ; Return values .: Success - Returns a two element array containing the resulting fraction. ; Sets @Extended to 1 if rounding or approximation occurs. ; Failure sets @error as follows ; |@error = 1 Invalid input. ; |@error = 2 The divisor cannot become zero. ; |@error = 3 Out of range. ; Author ........: czardas ; ============================================================================================================================== Func _FractionSubtract($aFraction1, $aFraction2) If Not (_IsFraction($aFraction1) And _IsFraction($aFraction2)) Then Return SetError(1) Local $iValue_1, $iValue_2, $iDividend, $iDivisor, $iExtended = 0 If __OverflowDetect('*', $aFraction1[0], $aFraction2[1], $iValue_1) Then $iExtended = 1 If __OverflowDetect('*', $aFraction1[1], $aFraction2[0], $iValue_2) Then $iExtended = 1 If __OverflowDetect('-', $iValue_1, $iValue_2, $iDividend) Then $iExtended = 1 If __OverflowDetect('*', $aFraction1[1], $aFraction2[1], $iDivisor) Then $iExtended = 1 Local $aSubtraction = _Fraction($iDividend, $iDivisor) If @extended Then $iExtended = 1 Return SetError(@error, $iExtended, $aSubtraction) EndFunc ;==> _FractionSubtract ; #FUNCTION# =================================================================================================================== ; Name...........: _IsFraction ; Description ...: Checks if the input is an array containing two valid integers ==> representing dividend and divisor. ; Syntax.........: _IsFraction($aFraction) ; Parameters.....; $aFraction - A two element array containing a dividend and a divisor. ; Return values .: Returns True if the input matches the criteria, otherwise returns False. ; Author.........: czardas ; Comments ......; Sets @extended to 1 if the fraction is negative. ; ============================================================================================================================== Func _IsFraction($aFraction) If Not IsArray($aFraction) Then Return False If Ubound($aFraction,0) <> 1 Or Ubound($aFraction) <> 2 Then Return False If Not StringInStr(VarGetType($aFraction[0]), 'Int') Or $aFraction[0] = 0x8000000000000000 Then Return False If Not StringInStr(VarGetType($aFraction[1]), 'Int') Or $aFraction[1] = 0x8000000000000000 Then Return False Return SetExtended((($aFraction[0] < 0 And $aFraction[1] > 0) Or ($aFraction[0] >= 0 And $aFraction[1] < 0)) ? 1 : 0, True) EndFunc ;==> _IsFraction ; #FUNCTION# =================================================================================================================== ; Name...........: _IsFractionNegative ; Description ...: Checks if the input array is a negative fraction. ; Syntax.........: _IsFractionNegative($aFraction) ; Parameters.....; $aFraction - A two element array containing a dividend and a divisor. ; Return values .: Returns True if the dividend and the divisor are of the opposite sign, othewise returns False. ; Failure sets @error to 1 if the input is not a valid array containing a dividend and a divisor. ; Author.........: czardas ; ============================================================================================================================== Func _IsFractionNegative($aFraction) Local $bNegative, $bIsFraction = _IsFraction($aFraction) $bNegative = @extended Return SetError(1 - $bIsFraction, 0, ($bNegative = 1)) EndFunc ;==> _IsFractionNegative ; #FUNCTION# =================================================================================================================== ; Name...........: _Reciprocal ; Description ...: Inverts a fraction by swapping the dividend and the divisor. ; Syntax.........: _Reciprocal($aFraction) ; Parameters.....; $aFraction - A two element array containing a dividend and a divisor. ; Return values .: Returns the reciprocal of the fraction. ; Failure sets @error as follows ; |@error = 1 The input is not a valid array containing a dividend and a divisor. ; |@error = 2 The divisor cannot become zero. ; Author.........: czardas ; ============================================================================================================================== Func _Reciprocal($aFraction) If Not _IsFraction($aFraction) Then Return SetError(1) Local $iDivisor = $aFraction[0] If $iDivisor = 0 Then Return SetError(2) $aFraction[0] = $aFraction[1] $aFraction[1] = $iDivisor Return $aFraction EndFunc ;==> _Reciprocal ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __FloatRatio ; Description ...: Helper function for Fraction() - preprocessing of float parameters to generate two proportional integers. ; Syntax.........: __FloatRatio([ByRef] $nDividend, [ByRef] $nDivisor) ; Parameters.....; $iDividend - Top fractional part ; $iDivisor - Lower fractional part ; Return values .: Success - Integer values are returned ByRef. ; Failure sets @error as follows ; |@error = 1 Out of bounds. ; Author ........: czardas ; Comments ......; No attempt has been made to accomodate for any double precision limitations. ; Small innacuracies can affect the 17th and (sometimes) the 16th digit in double precision. ; Using floats can easily be avoided by only passing integers to the function _Fraction(). ; Input positive floats only ; ============================================================================================================================== Func __FloatRatio(ByRef $nDividend, ByRef $nDivisor) If $nDivisor < 0 Then $nDividend *= -1 $nDivisor *= -1 EndIf If $nDivisor <> 1 Then $nDividend /= $nDivisor Local $nSignificand, $iExponent, $iDigits = 16 ; might as well grab as many digits as are available $nSignificand = __FloatToDigits($nDividend, $iDigits) $iExponent = @extended $nSignificand = Number($nSignificand, 2) ; Int-64 While $iExponent < - 18 ; divide the significand by powers of 10 $iDigits -= 1 If $iDigits < 0 Then ; too small If $nDividend < 1 / (2 * 10 ^ 18) Then ; round down to 0 / 1 $nSignificand = 0 $iExponent = 0 Else ; round up to 1 / 1000000000000000000 $nSignificand = 1 $iExponent = 18 EndIf ExitLoop EndIf $nSignificand = __FloatToDigits($nDividend, $iDigits) $iExponent = @extended ; adjust the exponent to accomodate division of the significand $nSignificand = Number($nSignificand, 2) ; Int-64 WEnd While $iExponent > 0 ; multiply the significand by powers of 10 If __OverflowDetect('*', $nSignificand, 10, $nSignificand) Then Return SetError(1) ; too large ~ out of bounds $iExponent -= 1 ; adjust the exponent to accomodate multiplication of the significand If $iExponent = 0 Then ExitLoop WEnd $nDividend = $nSignificand ; range 0 to 1000000000000000000 $nDivisor = _Power64(10, Abs($iExponent)) ; range 10 ^ (0 to 18) ==> powers of 10 only EndFunc ;==> __FloatRatio ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __FloatToDigits ; Description ...: Extracts a specified number of digits from a float. ; Syntax.........: __FloatToDigits($fFloat, $iDigits) ; Parameters.....; $fFloat - The float to extract the digits from. ; $iDigits - The number of digits to extract after the floating point (exponential representation). ; Return values .: Success - Returns a 32-bit or 64-bit signed integer. ; Sets @extended to the decimal exponent. ==> $fFloat = return value * 10 ^ exponent ; Failure sets @error to 1 if the input is not a float or undefined. ; Author ........: czardas ; ============================================================================================================================== Func __FloatToDigits($fFloat, $iDigits = 14) If VarGetType($fFloat) <> 'Double' Or StringInStr($fFloat, '#') Then Return SetError(1) Local $iSign = ($fFloat < 0) ? -1 : 1 ; machine epsilon = 5 × 10^-15, so the final two digits (16 and 17) could be highly innacurate $fFloat = StringFormat('%.' & $iDigits & 'e', $fFloat) ; rounds to the specified number of decimal places Local $aFloat = StringSplit($fFloat, "e", 2) ; zero-based array If $iSign < 0 Then $aFloat[0] = StringTrimLeft($aFloat[0], 1) ; remove the minus sign ; remove the decimal point and trailing zeros $aFloat[0] = StringLeft($aFloat[0], 1) & StringRegExpReplace(StringRight($aFloat[0], $iDigits), '(0+\z)', '') $aFloat[1] += 1 - StringLen($aFloat[0]) ; adjust the exponent to accommodate changes Return SetExtended($aFloat[1], Int($aFloat[0]) * $iSign) ; add back the minus sign EndFunc ;==> __FloatToDigits ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __GCD ; Description ...: Calculates the greatest common divisor of two integers. Original function name ==> _Greatest_Common_Factor() ; Syntax.........: __GCD($iValue1, $iValue2) ; Parameters.....; $iValue1 - First Integer. ; $iValue2 - Second Integer. ; Return values .: Success - Returns the greatest common divisor of $iValue1 and $iValue2. ; Author.........: Pheonix XL ; Modified.......; czardas ; Comments ......; IMPORTANT - Error checks have been removed. You must run the checks if you use this function yourself. ; ============================================================================================================================== Func __GCD($iValue1, $iValue2) ; Only accepts positive integers greater than zero. ; If Not (IsInt($iValue1) And IsInt($iValue2)) Or $iValue1 < 1 Or $iValue2 < 1 Then Return SetError(1) Local $iToggle If $iValue1 < $iValue2 Then ; Switch values. $iToggle = $iValue1 $iValue1 = $iValue2 $iValue2 = $iToggle EndIf Local $iModulus While 1 ; Method of Euclid. $iModulus = Mod($iValue1, $iValue2) If $iModulus = 0 Then ExitLoop $iValue1 = $iValue2 $iValue2 = $iModulus WEnd Return $iValue2 EndFunc ;==> __GCD ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __Quotient ; Description ...: Returns the quotient after division ~(the whole number part of a fraction). ; Syntax.........: __Quotient($nDividend, $nDivisor) ; Parameters.....; $iDividend - The integer to divide ; $iDivisor - The integer to divide by ; Return values .: Returns the quotient. ; Author ........: czardas ; Comments ......; Uses the same correction method as __WholeNumberDivision() in operator64.au3. ; ============================================================================================================================== Func __Quotient($nDividend, $nDivisor) Local $iQuotient = Floor($nDividend / $nDivisor), $iDifference, $iIntegral While $iQuotient * $nDivisor > $nDividend ; division is overstated $iDifference = ($nDivisor * $iQuotient) - $nDividend $iIntegral = Floor($iDifference / $nDivisor) ; avoid shooting beyond the target If $iIntegral = 0 Then $iIntegral = 1 ; prevents hanging in an infinite loop $iQuotient -= $iIntegral WEnd While $iQuotient * $nDivisor < $nDividend ; division is understated $iDifference = $nDividend - ($nDivisor * $iQuotient) $iIntegral = Floor($iDifference / $nDivisor) ; as above If $iIntegral = 0 Then ExitLoop ; we have found the floor already $iQuotient += $iIntegral WEnd Return $iQuotient EndFunc ;==> __Quotient ; #INTERNAL_USE_ONLY# ========================================================================================================== ; Name...........: __Simplify ; Description ...: Simplification by division. ; Syntax.........: __Simplify($iDividend, $iDivisor) ; Parameters.....; $iDividend - Top fractional part. ; $iDivisor - Lower fractional part. ; Author ........: czardas ; ============================================================================================================================== Func __Simplify(ByRef $iDividend, ByRef $iDivisor) Local $iGCD = __GCD($iDividend, $iDivisor) If $iGCD > 1 Then $iDividend = __WholeNumberDivision($iDividend, $iGCD) $iDivisor = __WholeNumberDivision($iDivisor, $iGCD) EndIf EndFunc ;==> __SimplifyExamples - currently testing for accuracy and possible bugs. #include 'Fraction.au3' Local $aFraction = _Fraction(3.1416) If @error Then Exit ; ==> Error handling. ConsoleWrite("3.1416 = " & $aFraction[0] & " / " & $aFraction[1] & @LF) $aFraction = _Fraction(0.125 , 2) ConsoleWrite("0.125 / 2 = " & $aFraction[0] & " / " & $aFraction[1] & @LF) $aFraction = _Fraction(0.00125, -0.32) ConsoleWrite("0.00125 / -0.32 = " & $aFraction[0] & " / " & $aFraction[1] & @LF) $aFraction = _Fraction(86418753, 2977963408767) ConsoleWrite("86418753 / 2977963408767 = " & $aFraction[0] & " / " & $aFraction[1] & @LF) ; Multiply two fractions (27 / 28 x 374 / 555) using whole number arithmetic: Local $aProduct = _FractionMultiply(_Fraction(27, 28), _Fraction(374, 555)) ConsoleWrite("27 / 28 x 374 / 555 = " & $aProduct[0] & " / " & $aProduct[1] & @LF) ; The modulus of two fractions: Local $aMod = _FractionMod(_Fraction(-1, 2), _Fraction(1, 3)) ConsoleWrite("Mod(-1/2, 1/3) = " & $aMod[0] & "/" & $aMod[1] & @LF) ; Represent pi (as accurately as possible) using a fraction with denominator of no more than thirteen digits. Local $aPi = _FractionApproximate(_Fraction(3.14159265358979), 1e+013 -1) ConsoleWrite($aPi[0] & " / " & $aPi[1] & " = " & $aPi[0] / $aPi[1] & " ~ Pi" & @LF) Local $aR2 = _FractionApproximate(_Fraction(2^.5), 1.0e+13 -1) ConsoleWrite($aR2[0] & " / " & $aR2[1] & " = " & $aR2[0] / $aR2[1] & " ~ 2^(1/2)" & @LF) Local $aLarge = _Fraction(1.23456789e+017,100000000000000100) If @error Then MsgBox(0, "", @error) ConsoleWrite(@extended & @LF) ConsoleWrite($aLarge[0] & " / " & $aLarge[1] & " = " & $aLarge[0] / $aLarge[1] & " = " & 1.23456789e+017 / 100000000000001000 & @LF) Local $aSmall = _Fraction(1.23456789e-200,8.64197523e-192) If @error Then MsgBox(0, "", @error) ConsoleWrite(@extended & @LF) ConsoleWrite($aSmall[0] & " / " & $aSmall[1] & " = " & $aSmall[0] / $aSmall[1] & " = " & 1.23456789e-200 / 8.64197523e-192 & @LF) Local $aTooSmall = _Fraction(1.23456789e-200,100000000000000100) If @error Then MsgBox(0, "", @error) ConsoleWrite("@extended = " & @extended & @LF) ConsoleWrite($aTooSmall[0] & " / " & $aTooSmall[1] & " = " & $aTooSmall[0] / $aTooSmall[1] & " = " & 1.23456789e-200 / 100000000000001000 & @LF) Local $aTooLarge = _Fraction(100000000000000100, 1.23456789e-200) ConsoleWrite("@error = " & @error & @LF) Local $aAddApprox = _FractionAdd(_Fraction(134567890000, 999999999999), _Fraction(987654321000, 777777777777777)) ConsoleWrite("@extended = " & @extended & @LF) ConsoleWrite($aAddApprox[0] & " / " & $aAddApprox[1] & " = " & $aAddApprox[0] / $aAddApprox[1] & " = " & (134567890000/999999999999 + 987654321000/777777777777777) ; See post 33 for information on the latest update.
    1 point
  9. LoL: inactive notepad ! Ok, how about you tell us what application you are trying to automate, and what is the goal of your issue...
    1 point
  10. Based on sysexporter you can get this as a demo started with basesource of simplespy combined with treewalker example 1 treewalker function extended with starting element using index in descriptions and showing in same loop (quick and dirty) how to iterate the textconttols in the whole table search virtual listviews and examples ad done by LarsJ in other thread if lists are long and not visible fully on screen ;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=SysExporter;controltype:=UIA_WindowControlTypeId;class:=SysExporter") ;SysExporter _UIA_setVar("oP2","Title:=;controltype:=UIA_ListControlTypeId;class:=SysListView32") ; _UIA_setVar("oP3","Title:=;controltype:=UIA_ListItemControlTypeId;class:=") ; ;~ $oUIElement=_UIA_getObjectByFindAll("Label.mainwindow", "title:=Label;ControlType:=UIA_TextControlTypeId", $treescope_subtree) _UIA_setVar("oUIElement","controltype:=UIA_TextControlTypeId;index:=2") ;ControlType:=UIA_TextControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles ;~ _UIA_Action("oP1","highlight") _UIA_Action("oP1","setfocus") ;~ _UIA_Action("oP2","highlight") _UIA_Action("oP2","setfocus") ;~ _UIA_Action("oP3","highlight") ;~ _UIA_Action("oP3","setfocus") _UIA_action("oUIElement","highlight") ;~_UIA_action("oUIElement","click") local $oUIElement=_UIA_action("oUIElement","getobject") ;~ consolewrite(_UIA_getAllPropertyValues($oUIElement) & @CRLF) ;~ Just iterate 10 rows for $i=1 to 10 local $oRow=_UIA_action("controltype:=UIA_ListItemControlTypeId;class:=;index:=" & $i,"getobject") _UIA_action($oRow,"highlight") local $rowtitle=_UIA_getPropertyValue($oRow,$UIA_NamePropertyId) consolewrite($rowtitle) ;~ Walk some items that are child sampletw(1,$oRow) $oUIElement=_UIA_Action("controltype:=UIA_TextControlTypeId;index:=" & $i,"getobject") local $title=_UIA_getPropertyValue($oUIElement,$UIA_NamePropertyId) consolewrite($title) Next Func sampleTW($t, $el) ConsoleWrite("initializing tw " & $t & @CRLF) Local $hTimer = TimerInit() Local $i=0 ;~ ' Lets show all the items of the desktop with a treewalker If $t = 1 Then $UIA_oUIAutomation.RawViewWalker($UIA_pTW) If $t = 2 Then $UIA_oUIAutomation.ControlViewWalker($UIA_pTW) If $t = 3 Then $UIA_oUIAutomation.ContentViewWalker($UIA_pTW) local $oTW = ObjCreateInterface($UIA_pTW, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker) If IsObj($oTW) = 0 Then MsgBox(1, "UI automation treewalker failed", "UI Automation failed failed", 10) EndIf $oTW.GetFirstChildElement($el, $UIA_pUIElement) local $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) While IsObj($oUIElement) = True ConsoleWrite($i & "Title is: " & _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId) & @TAB & "Handle=" & Hex(_UIA_getPropertyValue($oUIElement, $UIA_NativeWindowHandlePropertyId)) & @TAB & "Class=" & _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid) & @CRLF) $oTW.GetNextSiblingElement($oUIElement, $UIA_pUIElement) $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $i=$i+1 WEnd Local $fDiff = TimerDiff($hTimer) Consolewrite("Sample tw " & $t & " took: " & $fDiff & " milliseconds" & @CRLF & @CRLF) EndFunc ;==>sampleTW
    1 point
  11. You made an assumption that sysexporter listview is same as in your application which is apparently not the case. Its hard to say if uia can read but if inspect.exe is not showing its unlikely. You should try with tryout versions of ranorex or testcomplete how far they reach. If uia is not giving the info in either simplespy or inspect.exe you have to check with commercial tools. Only alternative I can think of is. Select closest element with uia to your row of interest Sendkeys with send functions and send ctrl c to copy info and get it back with clip functions of autoit. Even harder could be ocr with tesseract or commercial ocr engine.
    1 point
  12. Record 12-y necropost.
    1 point
  13. czardas

    Fraction

    Thanks Draygoes, the idea is to keep the original information intact and basically do maths with whole numbers. This way absolute accuracy is pretty much guaranteed, even when the whole numbers form part of a fraction. I think it's useful for small closed systems which use a lot of calculation. Only at the end of a number of precise calculations should the result be converted back to a float. This is the best way to maintain accuracy throughout a long winded calculation - where small inacuracies will have a knock on effect.
    1 point
  14. This may not be the method of choice, but it does make an effective screen dimmer without flashing in the taskbar. I got the dimmer functions from Autoit.de. #include <GUIConstantSex.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("GUIOnEventMode", 1) $rgb = 128 $dimBoGUI = GUICreate("DesktopDimmer", 162, 260, 1, @DesktopHeight * .3, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetStyle($WS_POPUP, $WS_EX_COMPOSITED + $WS_EX_LAYERED, $dimBoGUI) _WinAPI_SetLayeredWindowAttributes($dimBoGUI, 0xABCDEF, 255) GUISetBkColor(0xABCDEF);(0xffffff)while messing with gui. Else, (0xABCDEF) $dimButton = GUICtrlCreateButton("dimmer", 0, 10, 15, 15) GUICtrlSetBkColor($dimButton, 0x7f001f) GUICtrlSetColor($dimButton, 0x7f001f) GUICtrlSetOnEvent($dimButton, "dimmer") $normButton = GUICtrlCreateButton("return to normal", 0, 30, 15, 15) GUICtrlSetBkColor($normButton, 0x7f703f) GUICtrlSetColor($normButton, 0x7f703f) GUICtrlSetOnEvent($normButton, "normal") $brightButton = GUICtrlCreateButton("brighter", 0, 50, 15, 15) GUICtrlSetBkColor($brightButton, 0x42177f) GUICtrlSetColor($brightButton, 0x42177f) GUICtrlSetOnEvent($brightButton, "brighter") $closeButton = GUICtrlCreateButton("X", 0, 80, 17, 25) GUICtrlSetBkColor($closeButton, 0xff0000) GUICtrlSetTip($closeButton, "shut this silly thing down") GUICtrlSetOnEvent($closeButton, "xIt") $sourceButton = GUICtrlCreateButton("spit-out a source file", 0, 0, 8, 8) GUICtrlSetBkColor($sourceButton, 0xcc0088) GUICtrlSetColor($sourceButton, 0xcc0088) GUICtrlSetOnEvent($sourceButton, "install") GUISetState(@SW_SHOW) AdlibRegister("getThePos1", 500) _ReduceMemory() While 1 Sleep(10) WEnd Func xIt() normal();return brightness to normal Exit EndFunc ;==>xIt Func getThePos1() $CI = GUIGetCursorInfo($dimBoGUI) If $CI[4] = $dimButton Then dimGetBig() Else dimShrink() EndIf getThePos2() EndFunc ;==>getThePos1 Func getThePos2() $CI = GUIGetCursorInfo($dimBoGUI) If $CI[4] = $normButton Then normGetBig() Else normShrink() EndIf getThePos3() EndFunc ;==>getThePos2 Func getThePos3() $CI = GUIGetCursorInfo($dimBoGUI) If $CI[4] = $brightButton Then brightGetBig() Else brightShrink() EndIf getThePos4() EndFunc ;==>getThePos3 Func getThePos4() $CI = GUIGetCursorInfo($dimBoGUI) If $CI[4] = $sourceButton Then sourceGetBig() Else sourceShrink() EndIf EndFunc ;==>getThePos4 Func dimGetBig() ControlMove("", "dimmer", $dimButton, Default, Default, 160, 200) GUICtrlSetColor($dimButton, 0x000000) EndFunc ;==>dimGetBig Func dimShrink() ControlMove("", "dimmer", $dimButton, Default, Default, 15, 15) GUICtrlSetColor($dimButton, 0x7f001f) EndFunc ;==>dimShrink ;>>>>>>>>>>>>>> Func normGetBig() ControlMove("", "return to normal", $normButton, Default, Default, 160, 200) GUICtrlSetColor($normButton, 0x000000) EndFunc ;==>normGetBig Func normShrink() ControlMove("", "return to normal", $normButton, Default, Default, 15, 15) GUICtrlSetColor($normButton, 0x7f703f) EndFunc ;==>normShrink ;>>>>>>>>>>>>>> Func brightGetBig() ControlMove("", "brighter", $brightButton, Default, Default, 160, 200) GUICtrlSetColor($brightButton, 0x000000) EndFunc ;==>brightGetBig Func brightShrink() ControlMove("", "brighter", $brightButton, Default, Default, 15, 15) GUICtrlSetColor($brightButton, 0x42177f) EndFunc ;==>brightShrink ;>>>>>>>>>>>>>> Func sourceGetBig() ControlMove("", "spit-out a source file", $sourceButton, Default, Default, 160, 45);200 GUICtrlSetColor($sourceButton, 0x000000) EndFunc ;==>sourceGetBig Func sourceShrink() ControlMove("", "spit-out a source file", $sourceButton, Default, Default, 8, 8) GUICtrlSetColor($sourceButton, 0xcc0088) EndFunc ;==>sourceShrink ;>>>>>>>>>>>>>> ;got the below from autoit.de. I modified only the func names. Func dimmer() If $rgb > 0 Then $rgb = $rgb - 10 _SetGamma($rgb, $rgb, $rgb) EndIf EndFunc ;==>dimmer Func normal() $rgb = 128 _SetGamma($rgb, $rgb, $rgb) EndFunc ;==>normal Func brighter() If $rgb < 286 Then $rgb = $rgb + 10 _SetGamma($rgb, $rgb, $rgb) EndIf EndFunc ;==>brighter Func _SetGamma($vRed = 128, $vGreen = 128, $vBlue = 128) Local $n_ramp, $rVar, $gVar, $bVar, $Ret, $i, $dc If $vRed < 0 Or $vRed > 386 Then SetError(1) Return -1 ;Invalid Red value EndIf If $vGreen < 0 Or $vGreen > 386 Then SetError(2) Return -1 ;Invalid Green value EndIf If $vBlue < 0 Or $vBlue > 386 Then SetError(3) Return -1 ;Invalid Blue value EndIf $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) $n_ramp = DllStructCreate("short[" & (256 * 3) & "]") For $i = 0 To 256 $rVar = $i * ($vRed + 128) If $rVar > 65535 Then $rVar = 65535 $gVar = $i * ($vGreen + 128) If $gVar > 65535 Then $gVar = 65535 $bVar = $i * ($vBlue + 128) If $bVar > 65535 Then $bVar = 65535 DllStructSetData($n_ramp, 1, Int($rVar), $i) ;red DllStructSetData($n_ramp, 1, Int($gVar), $i + 256) ;green DllStructSetData($n_ramp, 1, Int($bVar), $i + 512) ;blue Next $Ret = DllCall("gdi32.dll", "int", "SetDeviceGammaRamp", _ "int", $dc[0], "ptr", DllStructGetPtr($n_ramp)) $dc = 0 $n_ramp = 0 EndFunc ;==>_SetGamma ;>>>>>>>>>>>>>> Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory Func install() ; this is a literal filepath & must be changed to where your script is located FileInstall("Q:\au3 projects\desktop dimmer\desktop dimmer.au3", @ScriptDir & "\desktop dimmer.au3");check path>>fix EndFunc ;==>install
    1 point
  15. mikell

    Drove me silly (Solved)

    Here is a funny variation - should work too ... $var = "$idRedo" $pattern = '[\w\h]*(\Q' & $var & '\E.*\s+)(.*?\(\h*-\h*1\h*,.*\s+)*|(.*?\(\h*(?1))' $res = StringRegExpReplace($sString, $pattern, "") msgbox(0,"", $res)
    0 points
×
×
  • Create New...