Sign in to follow this  
Followers 0
tsue

assigning values to inputs troube

2 posts in this topic

#1 ·  Posted (edited)

hello, i have a gui in which im using a button to enter a loop until control key is pressed, but i have trouble when im pressing more than one time the button

problems i have found:

1. if i press more than once the button it will get me all the loops until i get out from each one of them

2. if i press one button and then another one it does not kill the first loop so i have to get out from all the loops created

3. if i press the button and then i keep pressing the control key it will assign values more than once even after i specifically declare that it will exit the loop once control key is pressed, i have tried this without a loop but i receive almost the same ressult

i believe its because of ma programming and i need to change or use another parameters.

here is my code

$acti=0
While 1

;THIS IS THE SECOND TRY WITH OUT LOOPS by replacing all the func in the button so just leaving $acti=1 when pressed
If _IsPressed("11") And $acti=1 Then
;~   TrayTip("hey", "1", 2)
  $pos = MouseGetPos()
  $var = PixelGetColor( $pos[0] , $pos[1] )

  GUICtrlSetData($inpin1x, $pos[0])
  GUICtrlSetData($inpin1y, $pos[1])
  GUICtrlSetData($inpin1color, Hex($var, 6))
  $acti=0
  ;MsgBox(0,"The hex color is", Hex($var, 6) & @CRLF & $pos[0] & "," & $pos[1] )
;~   ExitLoop
EndIf
;end of alter tray

$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit


  case $btentrando2pixelsa
   ;control key 11
   While 1
    If _IsPressed("11") Then
     TrayTip("hey", "1", 2)
     $pos = MouseGetPos()
   ;~   MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
     $var = PixelGetColor( $pos[0] , $pos[1] )
   ;~   MsgBox(0,"The decimal color is", $var)
     GUICtrlSetData($inpin1x, $pos[0])
     GUICtrlSetData($inpin1y, $pos[1])
     GUICtrlSetData($inpin1color, Hex($var, 6))
     ;MsgBox(0,"The hex color is", Hex($var, 6) & @CRLF & $pos[0] & "," & $pos[1] )
     ExitLoop
    EndIf
    ;shift
    If _IsPressed("10") Then
     ExitLoop
    EndIf
;~  WEnd
  case $btentrando2pixelsb
   ;control key 11
   while 1
    If _IsPressed("11") Then
     TrayTip("hey", "2", 2)
     $pos = MouseGetPos()
     $var = PixelGetColor( $pos[0] , $pos[1] )
     GUICtrlSetData($inpin2x, $pos[0])
     GUICtrlSetData($inpin2y, $pos[1])
     GUICtrlSetData($inpin2color, Hex($var, 6))
     ExitLoop
    EndIf
    If _IsPressed("10") Then
     ExitLoop
    EndIf
;~   Sleep(100)
   WEnd

endswitch
sleep(100)
wend
Edited by tsue

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello tsue,

There is more than one way to interrupt a running function. This Link: Interrupting a running function will guide you to the section in the online helpfile and wiki. This page will better explain your options along with providing examples, so that you may choose which way works best for you.

Realm

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

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  
Followers 0