Jump to content
Sign in to follow this  
retaly

Return to 0 on slider when checkbox is off

Recommended Posts

retaly

hy guys, almost ready this part of my full scrip,

only one small thing what still i couldnt fixing...

my problem is: should to Return to 0 on slider when checkbox is off, and slider change to $GUI_DISABLE, $GUI_UNCHECKED as i wrote below in script.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Global $Slider_hold

Local $slider1, $msg, $lightvalue, $state, $lightslider, $lightlabel, $STATE1

GUICreate("slider", 500, 400)
$STATE1 = 0;"UNCHECKED"
$lightslider = GUICtrlCreateCheckbox("", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, BitOr($GUI_DISABLE, $GUI_UNCHECKED))
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel($state, 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()




While 1
Switch GUIGetMsg()
Case $lightslider
_lightChange()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Func _lightChange()
$State1 = NOT $State1
If $State1 Then
GUICtrlSetState($slider1, BitOr($GUI_ENABLE, $GUI_CHECKED))
slider_opt()
Else
GUICtrlSetState($slider1, BitOr($GUI_DISABLE, $GUI_UNCHECKED))
GUICtrlSetData($lightvalue, "0")
EndIf
EndFunc


Func slider_opt()
Do
$state = GUICtrlRead($slider1)
If $state <> $Slider_hold Then
GUICtrlSetData($lightvalue, $state)
$Slider_hold = $state
EndIf
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
EndFunc
Edited by retaly

Share this post


Link to post
Share on other sites
FireFox

Hi,

You have to keep only one While in your script to be able to receive GUI messages from your main while, plus I don't know why you are using the GUI_CHECKED and GUI_UNCHECKED states for the slider...

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Global $Slider_hold

Local $slider1, $msg, $lightvalue, $state, $lightslider, $lightlabel, $STATE1

GUICreate("slider", 500, 400)
$STATE1 = 0;"UNCHECKED"
$lightslider = GUICtrlCreateCheckbox("0", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel($state, 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()

While 1
Switch GUIGetMsg()
Case $lightslider
_lightChange()
Case $slider1
GUICtrlSetData($lightvalue, GUICtrlRead($slider1))
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Func _lightChange()
$STATE1 = Not $STATE1
If $STATE1 Then
GUICtrlSetState($slider1, $GUI_ENABLE)
Else
GUICtrlSetState($slider1, $GUI_DISABLE)
GUICtrlSetData($slider1, 0)
GUICtrlSetData($lightvalue, "0")
EndIf
EndFunc   ;==>_lightChange

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
retaly

using GUI_CHECKED and GUI_UNCHECKED for checkbox,

tested and now slider doesnt working with 3rd mouse button, its important to me, :(

Share this post


Link to post
Share on other sites
FireFox

using GUI_CHECKED and GUI_UNCHECKED for checkbox,

You were using it for the slider.

tested and now slider doesnt working with 3rd mouse button, its important to me, :(

What do you want it to do? I don't have a mouse on my computer right now.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
retaly

the 3rd button is one roller button, i'd like to use it with mouse click, and with 3rd roller button too

i hope u are understanding me

Edited by retaly

Share this post


Link to post
Share on other sites
retaly

i mean, need there the slider_op() to working 3rd mouse, but in this situation i went one step to forward, and two step to back..

because 3rd mouse button again working, but doesnt return to 0 and gui_disable to slider...

:// i have to find the best way to use both option in one option what works...

try out the two different script then you will understand it if still dont.

Edited by retaly

Share this post


Link to post
Share on other sites
FireFox

You can not trap the slider scroll event in autoit (or nobody has given the solution) so you have to check for its value like you did :

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Local $slider1, $lightvalue, $lightslider, $lightlabel, $STATE1 = False

Local $iSliderValue = -1, $iLastSliderValue = 0

GUICreate("slider", 500, 400)
$lightslider = GUICtrlCreateCheckbox("0", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel("0", 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()

While 1
Switch GUIGetMsg()
Case $lightslider
_lightChange()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch

If $STATE1 Then
$iSliderValue = GUICtrlRead($slider1)

If $iSliderValue <> $iLastSliderValue Then
GUICtrlSetData($lightvalue, $iSliderValue)

$iLastSliderValue = $iSliderValue
EndIf
EndIf
WEnd

Func _lightChange()
$STATE1 = Not $STATE1
If $STATE1 Then
GUICtrlSetState($slider1, $GUI_ENABLE)
Else
GUICtrlSetState($slider1, $GUI_DISABLE)
GUICtrlSetData($slider1, 0)
GUICtrlSetData($lightvalue, "0")
EndIf
EndFunc   ;==>_lightChange

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Melba23

FireFox,

You can not trap the slider scroll event in autoit

Oh yes you can: ;)

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

Opt('MustDeclareVars', 1)

Local $slider1, $lightvalue, $lightslider, $lightlabel, $STATE1 = False

Local $iSliderValue = -1, $iLastSliderValue = 0

GUICreate("slider", 500, 400)
$lightslider = GUICtrlCreateCheckbox("0", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel("0", 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()

GUIRegisterMsg($WM_HSCROLL, "_WM_HSCROLL") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    Switch GUIGetMsg()
        Case $lightslider
            _lightChange()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _lightChange()
    $STATE1 = Not $STATE1
    If $STATE1 Then
        GUICtrlSetState($slider1, $GUI_ENABLE)
    Else
        GUICtrlSetState($slider1, $GUI_DISABLE)
        GUICtrlSetData($slider1, 0)
        GUICtrlSetData($lightvalue, "0")
    EndIf
EndFunc   ;==>_lightChange

; React to slider movement
Func _WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    #forceref $hWnd, $iMsg
    If $lParam = GUICtrlGetHandle($slider1) Then
        If BitAND($wParam, 0xFFFF) = 5 Then ; LoWord = $SB_THUMBTRACK
            GUICtrlSetData($lightvalue, GUICtrlRead($slider1))
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_HSCROLL

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Blue_Drache

GuiCtrlRead() the state of the checkbox and set the slider's value with GuiCtrlSetData() appropriately.

I see I was beat out, slightly.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
FireFox

@M23

You forgot to add "or nobody has given the solution" in your quote :idiot:

Do you remember the PM I sent you about my scrollbars problem, at least the event problem ?

So, the event is not working for me... f*cking computers.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
retaly

I will try out asap ur fixed versions guys, when im at home, thank you very much

Share this post


Link to post
Share on other sites
retaly

FireFox Thank You Very Much, its working, i wanted that!

Share this post


Link to post
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
Sign in to follow this  

×