sebgg Posted September 8, 2011 Posted September 8, 2011 (edited) Hi, Having a little trouble getting my head arround this slider i want, so far i want to have a slider which can be changed by the user, but whos value is displayed in a box, but if the user types a value in the box, then it will also change the slider. at the moment i have it on a loop to read the slider and set its value into the box, but this is means that i can never enter anything into the box, as its constantly being re-written. any ideas on a good way to fix this? Do $msg = GUIGetMsg() $sliderread = GUICtrlRead($slider1, 1) GUICtrlSetData($button, $sliderread) $sliderread2 = GUICtrlRead($slider2, 1) GUICtrlSetData($button4, $sliderread2) if $msg = $GUI_EVENT_CLOSE Then Terminate() endif until $msg = $next needless to mention $button4 is the input box which displays the slider number. Cheers Seb Edited September 8, 2011 by sebgg GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size
BrewManNH Posted September 8, 2011 Posted September 8, 2011 (edited) Only change the value in the input box if the value of the slider has changed, that way you can change the box then change the slider to that value. $sliderread2[/color] = Guictrlread($slider2) If $sliderread2 <> $oldvalue then GuiCtrlSetData($button4,$sliderread2) $oldvalue = $sliderread2 EndIf Just off the top of my head. Edited September 8, 2011 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
GEOSoft Posted September 8, 2011 Posted September 8, 2011 $h_Label = GUICtrlCreateLabel("", 10, 10, 100, 20) $h_Slider = GUICtrlCreateSlider(10, 30, 100, 20) GUISetState() While 1 ;; Message loop or else create an OnEvent function. If GUICtrlRead($h_Slider) <> GUICtrlRead($h_Label) Then GUICtrlSetData($h_Label, GUICtrlRead($h_Slider)) WEND George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
sebgg Posted September 8, 2011 Author Posted September 8, 2011 Ok thanks for the replies, that exactly what i was looking for, so i just set the oldnumber to be basically the default, and now its nice. so the next question is when i type something into the inputbox, i want it to change in the slider, this is no problem usign the same logic. bit messy but works grand. $sliderread = GUICtrlRead($slider1, 1) If $sliderread <> $oldvalue1 then GuiCtrlSetData($button,$sliderread) $oldvalue1 = $sliderread EndIf $sliderread2 = GUICtrlRead($slider2, 1) If $sliderread2 <> $oldvalue2 then GuiCtrlSetData($button4,$sliderread2) $oldvalue2 = $sliderread2 EndIf $input_pixelread = guictrlread ($button,1) if $input_pixelread <> $oldinput1 then GuiCtrlSetData($slider1,$input_pixelread) $oldinput1 = $input_pixelread EndIf $input_angleread = guictrlread ($button4,1) if $input_angleread <> $oldinput2 then GuiCtrlSetData($slider2,$input_angleread) $oldinput2 = $input_angleread EndIf thanks again guys Seb. GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size
GEOSoft Posted September 8, 2011 Posted September 8, 2011 This is another method (not highly recommended) that will use less code to do what you want. $Frm_Main = GUICreate("Test") $h_Input = GUICtrlCreateInput("", 10, 10, 100, 20) $h_Slider = GUICtrlCreateSlider(10, 30, 100, 20) GUISetState() While 1 If ControlGetHandle($Frm_Main, "", ControlGetFocus($Frm_Main)) = GUICtrlGetHandle($h_Slider) Then If GUICtrlRead($h_Slider) <> GUICtrlRead($h_Input) Then GUICtrlSetData($h_Input, GUICtrlRead($h_Slider)) ElseIf ControlGetHandle($Frm_Main, "", ControlGetFocus($Frm_Main)) = GUICtrlGetHandle($h_Input) Then If ControlGetHandle($Frm_Main, "", ControlGetFocus($Frm_Main)) Then GUICtrlSetData($h_Slider, GUICtrlRead($h_Input)) EndIf If GUIGetMsg() = -3 Then Exit WEnd George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now