Jump to content

"proportional" vaule


Recommended Posts

Hi, if i have:

$a = 1280
$b = 720

and i want to change the $a to:

$a = 752

How to make the $b value proprotional to $a like this?

$a = 752
$b = 423

I'd like also the opposite, if i change $b i want the $a to be proportional to $b

Thanks

Edited by MyEarth
Link to comment
Share on other sites

  • Moderators

Hi, MyEarth. Why not set a third variable, which could even be an inputbox, to do the calculation for you?

$a = 1280
$b = 720
$c = InputBox("Calculate Vars Example", "What would you like the calculation to be?")

$a = $a / $c
$b = $b / $c

MsgBox(0, "", "$a is now " & $a & ". $b is now " & $b)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

$a1 = 1280
$a2 = 752
$b1 = 720
$b2 = $b1 * $a2 / $a1
ConsoleWrite($b2 & @LF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

My example doesn't work when $a1 = 0.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

a2 = (a1xb2)/b1

Simple math.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Mathematics, proportions, the 5th class at school

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollBarConstants.au3>

Global $k = 0
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
$GUI = GUICreate("horis", 1020, 285, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_HSCROLL))

$slider1 = GUICtrlCreateSlider(10, 5, 1000, 30)
GUICtrlSetLimit(-1, 1000, 0)
$hSlider_Handle1 = GUICtrlGetHandle(-1)
GUICtrlSetData(-1, 120)

$slider2 = GUICtrlCreateSlider(10, 35, 1000, 30)
GUICtrlSetLimit(-1, 1000, 0)
$hSlider_Handle2 = GUICtrlGetHandle(-1)
GUICtrlSetData(-1, 72)

$koef = 72/120

$condition = GUICtrlCreateLabel('', 10, 75, 300, 55)
GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF) ; _WinAPI_LoWord
    Local $value = BitShift($wParam, 16) ; _WinAPI_HiWord

    Switch $lParam
        Case $hSlider_Handle1
            $sMsg = 'Slider = 1' & @LF & 'value = '
            Switch $nScrollCode
                Case $SB_THUMBTRACK
                    $sMsg &= $value & @LF & 'mode = Keeping by the left button of a mouse'
                Case $SB_THUMBPOSITION
                    $sMsg &= $value & @LF & 'mode = Trundle mouse'
                Case $SB_LINELEFT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Arrow L/Up'
                Case $SB_LINERIGHT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Arrow R/Down'
                Case $SB_PAGELEFT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Click Left'
                Case $SB_PAGERIGHT
                    $value = GUICtrlRead($slider1)
                    $sMsg &= $value & @LF & 'mode = Click R'
            EndSwitch
            If $nScrollCode <> 8 Then
                GUICtrlSetData($condition, $sMsg)
                GUICtrlSetData($slider2, $value*$koef)
            EndIf
        Case $hSlider_Handle2
            If $nScrollCode = $SB_THUMBTRACK Then
                GUICtrlSetData($condition, '2 - ' & $value)
                GUICtrlSetData($slider1, $value/$koef)
            EndIf
        Case 0
            If $nScrollCode = $SB_THUMBTRACK Then GUICtrlSetData($condition, '3 - ' & $value)
    EndSwitch

    $k += 1
    WinSetTitle($GUI, '', 'call ' & $k & ', c=' & $nScrollCode & ', v=' & $value)

    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...