Jump to content

GUICtrlCreateSlider


chazzmani
 Share

Recommended Posts

I am creating a GUI and within the GUI is a slider. I would like to show the current value of the slider within a small box near the slider itself. How do you do that? So here is the code specific to the slider...

GUICreate("Sensitivity", 245, 462)

$Slider = GUICtrlCreateSlider(20, 135, 180, 30)

GUICtrlSetLimit(-1,50,1)

GUICtrlSetData(-1,10)

What lines would I add to put a box that shows the current slider value as the user drags it left and right? Coordinates aren't important, I just don't know how to show the value within the active GUI.

Thanks!

Edited by chazzmani
Link to comment
Share on other sites

I am creating a GUI and within the GUI is a slider. I would like to show the current value of the slider within a small box near the slider itself. How do you do that? So here is the code specific to the slider...

GUICreate("Sensitivity", 245, 462)

$Slider = GUICtrlCreateSlider(20, 135, 180, 30)

GUICtrlSetLimit(-1,50,1)

GUICtrlSetData(-1,10)

What lines would I add to put a box that shows the current slider value as the user drags it left and right? Coordinates aren't important, I just don't know how to show the value within the active GUI.

Thanks!

#include <GUIConstants.au3>

GUICreate("slider",220,100, 100,200)
GUISetBkColor (0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider (10,10,200,20)
GUICtrlSetLimit(-1,200,0)  ; change min/max value
GUISetState()
GUICtrlSetData($slider1,45); set cursor
$lab = GUICtrlCreateLabel("0",70,50,150,28)

$pos = -1
Do
  $n = GUIGetMsg ()
     
   $now = GUICtrlRead($slider1)
   If $now <> $pos Then
       GUICtrlSetData($lab,$now)
       $pos = $now
   EndIf
   
Until $n = $GUI_EVENT_CLOSE
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thank you, but that doesn't quite help me. I am too much of a noob to figure out how to apply a copy/paste from your script and make it work in mine. I tried to copy/paste what I thought was relevant from your suggestion into my script and it didn't work (the GUI just disappeared -- I am guessing we had conflicting means to keep the GUI active toward the bottom). Attached is my full script. What lines can I specifically add to -this script- to make a visible box showing the value of the slider?

#include <GUIConstants.au3>

#include <Misc.au3>

;============================================

; GUI Creation

;============================================

GUICreate("Sensitivity", 245, 462)

GUICtrlCreateGroup("Colors", 0, 55, 245, 135)

$Inputcolor = GUICtrlCreateInput("", 100, 75, 86, 20)

GUICtrlCreateLabel("Color to look for", 9, 80, 83, 17)

GUICtrlCreateLabel("Color sensitivity. Move the slider to the left for a precise match.", 30, 105, 179, 27)

GUICtrlCreateLabel("Precise", 15, 167, 200, 13)

GUICtrlCreateLabel("Fuzzy", 175, 167, 200, 13)

$Slider = GUICtrlCreateSlider(20, 135, 180, 30)

GUICtrlSetLimit(-1,50,1)

GUICtrlSetData(-1,10)

;============================================

; Show GUI on top

;============================================

WinSetOnTop("Color", "", 1)

GUISetState(@SW_SHOW)

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

Edited by chazzmani
Link to comment
Share on other sites

Thank you, but that doesn't quite help me. I am too much of a noob to figure out how to apply a copy/paste from your script and make it work in mine. I tried to copy/paste what I thought was relevant from your suggestion into my script and it didn't work (the GUI just disappeared -- I am guessing we had conflicting means to keep the GUI active toward the bottom). Attached is my full script. What lines can I specifically add to -this script- to make a visible box showing the value of the slider?

#include <GUIConstants.au3>

#include <Misc.au3>

;============================================

; GUI Creation

;============================================

GUICreate("Sensitivity", 245, 462)

GUICtrlCreateGroup("Colors", 0, 55, 245, 135)

$Inputcolor = GUICtrlCreateInput("", 100, 75, 86, 20)

GUICtrlCreateLabel("Color to look for", 9, 80, 83, 17)

GUICtrlCreateLabel("Color sensitivity. Move the slider to the left for a precise match.", 30, 105, 179, 27)

GUICtrlCreateLabel("Precise", 15, 167, 200, 13)

GUICtrlCreateLabel("Fuzzy", 175, 167, 200, 13)

$Slider = GUICtrlCreateSlider(20, 135, 180, 30)

GUICtrlSetLimit(-1,50,1)

GUICtrlSetData(-1,10)

;============================================

; Show GUI on top

;============================================

WinSetOnTop("Color", "", 1)

GUISetState(@SW_SHOW)

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

I think that if you made the script then you should be able to work out what to do with my example. Here is your code but I won't be so generous next time.

#include <GUIConstants.au3>
#include <Misc.au3>
;============================================
;       GUI Creation
;============================================

    GUICreate("Sensitivity", 245, 462)
    GUICtrlCreateGroup("Colors", 0, 55, 245, 135)
    $Inputcolor = GUICtrlCreateInput("", 100, 75, 86, 20)
    GUICtrlCreateLabel("Color to look for", 9, 80, 83, 17)
    GUICtrlCreateLabel("Color sensitivity. Move the slider to the left for a precise match.", 30, 105, 179, 27)
    


    GUICtrlCreateLabel("Precise", 15, 167, 200, 13)
    GUICtrlCreateLabel("Fuzzy", 175, 167, 200, 13)
    $Slider = GUICtrlCreateSlider(20, 135, 180, 30)
    GUICtrlSetLimit(-1,50,1)
    GUICtrlSetData(-1,10)
    $lab = GUICtrlCreateLabel("0",100,167,50,28)
    GUICtrlSetColor(-1,0xff0000)
    GUICtrlCreateGroup ("",-99,-99,1,1) ;close group
    
;============================================
;       Show GUI on top
;============================================
    WinSetOnTop("Color", "", 1)
    GUISetState(@SW_SHOW)
    
    $pos = -1
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
         $now = GUICtrlRead($slider)
   If $now <> $pos Then
       GUICtrlSetData($lab,$now)
       $pos = $now
   EndIf
    Wend
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...