WOULD YOU BELIEVE, another solution (possibly the best yet - exactly what I originally wanted)
PLEASE NOTE - I've added another section of code (for $num) to the original, hope it makes things clearer.
Please Help Me!
This is an issue (or related) that I've come across many times, and in the past I've settled for a work-a-round, but this time I would really like a solution. And YES I HAVE SEARCHED THE HELP FILE and THE FORUM. One suggestion here for the support forum (I guess it may have been said before, if so I second it), it would be much easier to perform searches, if previous topics where in categories ... even if those categories were as simple as - Buttons, Checkboxes, Messages, Events, GUI, etc. It is very difficult searching the forum at times - very much a hit'n'miss affair ... so hard to know the right search phrases or words, so categories would at least narrow the search result range.
I need help with getting the time a gui button is held down for?
I've tried many different methods - primarydown, etc, but have had no luck. Every event relating to controls on a gui, don't seem to occur until after the primaryup event.
Basically I want to update a stored value, depending on how long a user clicks a button ... in other words if a user clicks on a button (on a gui) for longer than (say) 3 secs, then they want to update the stored default, otherwise they just want to apply the currently stored default. This is a way around having to add an extra button, so the user can change a default.
Here is an extract of the code from my program - this being one of the variations that almost worked -
#include <GuiConstants.au3> Dim $Button_11, $Input_rn, $Label_rn, $Updown_rn Dim $begin, $cnt, $Dialog, $diff, $height, $inifle, $new, $width $inifle = @ScriptDir & "\Template.ini" ;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 $Dialog = $WS_OVERLAPPED + $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS $width = 430 $height = 450 GuiCreate("Script Templates v2.0", $width, $height, _ (@DesktopWidth-$width)/2, (@DesktopHeight-$height-30)/2 , $Dialog + $WS_MINIMIZEBOX) $Input_rn = GUICtrlCreateInput("0", 135, 370, 40, 20) $Updown_rn = GUICtrlCreateUpdown($Input_rn) GUICtrlSetLimit($Updown_rn, 99, 0) $Label_rn = GUICtrlCreateLabel("lines", 180, 373, 30, 20) $Button_11 = GUICtrlCreateButton("", 210, 370, 20, 20) $num = IniRead($inifle, "Line Count", "default", "") If $num = "" Then $num = "11" IniWrite($inifle, "Line Count", "default", $num) EndIf GUICtrlSetData($Button_11, $num) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN If $cnt = "" Then $begin = TimerInit() ;MsgBox(0, "$GUI_EVENT", "PRIMARYDOWN") Case $cnt = 1 $cnt = "" $diff = TimerDiff($begin) ;MsgBox(0, "Time Mouse Down", $diff) If $diff > "3000" Then IniWrite($inifle, "Line Count", "default", $new) GUICtrlSetData($Input_rn, $new) GUICtrlSetData($Button_11, $new) EndIf $begin = "" Case $msg = $Button_11 ; Set Line Count to $num $cnt = 1 $new =GUICtrlRead($Input_rn) $num = IniRead($inifle, "Line Count", "default", "") GUICtrlSetData($Input_rn, $num) Case Else ;;; EndSelect WEnd Exit
Any suggestions, solutions will be greatly appreciated!
Edited by TheSaint, 28 May 2006 - 08:13 AM.






