Sign in to follow this  
Followers 0
t0ddie

help with a small problem?

7 posts in this topic

#include <GUIConstants.au3>
#include <Constants.au3>
$spacer = "."
$nCurEdit = 0






$GUI = GUICreate("dope", 510, 390)
Dim $input[8]
$input[0] = GUICtrlCreateInput("", 140, 140, 30, 20)
GUICtrlSetLimit($input[0], 4)
$input[1] = GUICtrlCreateInput("", 175, 140, 30, 20)
GUICtrlSetLimit($input[1], 4)
$input[2] = GUICtrlCreateInput("", 210, 140, 30, 20)
GUICtrlSetLimit($input[2], 4)
$input[3] = GUICtrlCreateInput("", 245, 140, 30, 20)
GUICtrlSetLimit($input[3], 4)
$input[4] = GUICtrlCreateInput("", 140, 180, 30, 20)
GUICtrlSetLimit($input[4], 4)
$input[5] = GUICtrlCreateInput("", 175, 180, 30, 20)
GUICtrlSetLimit($input[5], 4)
$input[6] = GUICtrlCreateInput("", 210, 180, 30, 20)
GUICtrlSetLimit($input[6], 4)
$input[7] = GUICtrlCreateInput("", 245, 180, 30, 20)
GUICtrlSetLimit($input[7], 4)
$add = GUICtrlCreateButton("Add To List", 165, 215, 85)
$mylist = GUICtrlCreateList("", 305, 139, 200, 173, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $ES_AUTOVSCROLL, $WS_EX_WINDOWEDGE))
GUICtrlSetLimit(-1, 200)
GUICtrlSetState($add, $GUI_DISABLE)

$msg = 0
GUISetState()
While $msg <> $GUI_EVENT_CLOSE
  $msg = GUIGetMsg()
  $ip = _IsPressedMod()
    If $ip > 0 Then
        $res = GUICtrlRead($input[$nCurEdit])
        If (StringLen($res) = 4) and not ($ip = 8) Then
            If $nCurEdit = UBound($input) - 1 Then ContinueLoop
            $nCurEdit = $nCurEdit + 1
            GUICtrlSetState($input[$nCurEdit], $GUI_FOCUS)
            ContinueLoop
        Endif
        If (StringLen($res) = 0) and ($ip = 8) Then
            If $nCurEdit = 0 Then ContinueLoop
            $nCurEdit = $nCurEdit - 1
            GUICtrlSetState($input[$nCurEdit], $GUI_FOCUS)
            GUICtrlSetData($input[$nCurEdit], GUICtrlRead($input[$nCurEdit]))
            ContinueLoop
        Endif
    Endif
    
   
   Select
         Case $msg = $add
         $i = GUICtrlRead ($input[0])
         $j = GUICtrlRead ($input[1])
         $k = GUICtrlRead ($input[2])
         $l = GUICtrlRead ($input[3])
         $m = GUICtrlRead ($input[4])
         $n = GUICtrlRead ($input[5])
         $o = GUICtrlRead ($input[6])
         $p = GUICtrlRead ($input[7])
         
         GUICtrlSetData($mylist,$i & "-" & $j & "-" & $k & "-" & $l)
         GUICtrlSetData($mylist,$m & "-" & $n & "-" & $o & "-" & $p)
         GUICtrlSetData($mylist, $spacer)
         
         GUICtrlSetData($input[0], "")
         GUICtrlSetData($input[1], "")
         GUICtrlSetData($input[2], "")
         GUICtrlSetData($input[3], "")
         GUICtrlSetData($input[4], "")
         GUICtrlSetData($input[5], "")
         GUICtrlSetData($input[6], "")
         GUICtrlSetData($input[7], "")
         GUICtrlSetState($input[0], $GUI_FOCUS)
         
     EndSelect
     
   $var1 = StringLen(GuiCtrlRead ($input[0]))
   $var2 = StringLen(GuiCtrlRead ($input[1]))
   $var3 = StringLen(GuiCtrlRead ($input[2]))
   $var4 = StringLen(GuiCtrlRead ($input[3]))
   $var5 = StringLen(GuiCtrlRead ($input[4]))
   $var6 = StringLen(GuiCtrlRead ($input[5]))
   $var7 = StringLen(GuiCtrlRead ($input[6]))
   $var8 = StringLen(GuiCtrlRead ($input[7]))
   
If $var1 = 4 And $var2 = 4 And $var3 = 4 And $var4 = 4 _
         And $var5 = 4 And $var6 = 4 And $var7 = 4 And $var8 = 4 And Not ControlCommand($GUI, "", $add, "IsEnabled", "") Then
      GUICtrlSetState($add, $GUI_ENABLE)
          
     ElseIf $var1 <> 4 And $var2 <> 4 And $var3 <> 4 And $var4 <> 4 And $var5 <> 4 And _
         $var6 <> 4 And $var7 <> 4 And $var8 <> 4 And ControlCommand($GUI, "", $add, "IsEnabled", "") Then
      GUICtrlSetState($add, $GUI_DISABLE)
   EndIf
Wend

Func _IsPressedMod()
  Local $aR, $bRv
  For $i = 8 to 128
      $hexKey = '0x' & Hex($i, 2)
      $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
      If $aR[0] <> 0 Then Return $i
  Next
  Return 0
EndFunc

this is some code that i have, that will go advance to the next input when the previous one is full, and will go back to previous inputs when backspace is pressed.

however, once you click the "add to list" button it no longer works.

i was trying to figure it out, and i noticed when i press backspace that it will start working again, but sending backspace from the script didnt work.

i was wondering how i could fix this?

also... wondering how i could have the script detect which input the cursor was currently on?

and finally, when i enter something into the list, if its already on the list it wont write to it, and theres no message or response telling you that you made a mistake.

i want to be able to check the list BEFORE i write to it and if the top 4 inputs (xxxx-xxxx-xxxx-xxxx for example) are already on the list, have a messagebox come up

saying you matched line ... and whatever line xxxx-xxxx-xxxx-xxxx is on.

and the same thing for the bottom 4 inputs. lets say i entered oooo-oooo-oooo-oooo

it would check the entire list before writing to it, and if it found oooo-oooo-oooo-oooo on any line it would say, match! on line 7 or something similar

i hope this isnt too many questions for one post!


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites



if there was a way to just make the script think that backspace was pressed,

i dont know how, but doing this: send ("{bs}") did not work, although it did send a backspace on the gui, it did not fix the problem.

thats just one workaround i was thinking of, there is probably a better way.

any ideas?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <Constants.au3>
$spacer = "."
$nCurEdit = 0






$GUI = GUICreate("dope", 510, 390)
Dim $input[8]
$input[0] = GUICtrlCreateInput("", 140, 140, 30, 20)
GUICtrlSetLimit($input[0], 4)
$input[1] = GUICtrlCreateInput("", 175, 140, 30, 20)
GUICtrlSetLimit($input[1], 4)
$input[2] = GUICtrlCreateInput("", 210, 140, 30, 20)
GUICtrlSetLimit($input[2], 4)
$input[3] = GUICtrlCreateInput("", 245, 140, 30, 20)
GUICtrlSetLimit($input[3], 4)
$input[4] = GUICtrlCreateInput("", 140, 180, 30, 20)
GUICtrlSetLimit($input[4], 4)
$input[5] = GUICtrlCreateInput("", 175, 180, 30, 20)
GUICtrlSetLimit($input[5], 4)
$input[6] = GUICtrlCreateInput("", 210, 180, 30, 20)
GUICtrlSetLimit($input[6], 4)
$input[7] = GUICtrlCreateInput("", 245, 180, 30, 20)
GUICtrlSetLimit($input[7], 4)
$add = GUICtrlCreateButton("Add To List", 165, 215, 85)
$mylist = GUICtrlCreateList("", 305, 139, 200, 173, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $ES_AUTOVSCROLL, $WS_EX_WINDOWEDGE))
GUICtrlSetLimit(-1, 200)
GUICtrlSetState($add, $GUI_DISABLE)

$msg = 0
GUISetState()
While $msg <> $GUI_EVENT_CLOSE
  $msg = GUIGetMsg()
  $ip = _IsPressedMod()
    If $ip > 0 Then
        $res = GUICtrlRead($input[$nCurEdit])
        If (StringLen($res) = 4) and not ($ip = 8) Then
            If $nCurEdit = UBound($input) - 1 Then ContinueLoop
            $nCurEdit = $nCurEdit + 1
            GUICtrlSetState($input[$nCurEdit], $GUI_FOCUS)
            ContinueLoop
        Endif
        If (StringLen($res) = 0) and ($ip = 8) Then
            If $nCurEdit = 0 Then ContinueLoop
            $nCurEdit = $nCurEdit - 1
            GUICtrlSetState($input[$nCurEdit], $GUI_FOCUS)
            GUICtrlSetData($input[$nCurEdit], GUICtrlRead($input[$nCurEdit]))
            ContinueLoop
        Endif
    Endif
    
   
   Select
         Case $msg = $add
         $i = GUICtrlRead ($input[0])
         $j = GUICtrlRead ($input[1])
         $k = GUICtrlRead ($input[2])
         $l = GUICtrlRead ($input[3])
         $m = GUICtrlRead ($input[4])
         $n = GUICtrlRead ($input[5])
         $o = GUICtrlRead ($input[6])
         $p = GUICtrlRead ($input[7])
         
         GUICtrlSetData($mylist,$i & "-" & $j & "-" & $k & "-" & $l)
         GUICtrlSetData($mylist,$m & "-" & $n & "-" & $o & "-" & $p)
         GUICtrlSetData($mylist, $spacer)
         
         GUICtrlSetData($input[0], "")
         GUICtrlSetData($input[1], "")
         GUICtrlSetData($input[2], "")
         GUICtrlSetData($input[3], "")
         GUICtrlSetData($input[4], "")
         GUICtrlSetData($input[5], "")
         GUICtrlSetData($input[6], "")
         GUICtrlSetData($input[7], "")
         GUICtrlSetState($input[0], $GUI_FOCUS)
        ;***********************************
            $nCurEdit = 0
        ;***********************************

     EndSelect
     
   $var1 = StringLen(GuiCtrlRead ($input[0]))
   $var2 = StringLen(GuiCtrlRead ($input[1]))
   $var3 = StringLen(GuiCtrlRead ($input[2]))
   $var4 = StringLen(GuiCtrlRead ($input[3]))
   $var5 = StringLen(GuiCtrlRead ($input[4]))
   $var6 = StringLen(GuiCtrlRead ($input[5]))
   $var7 = StringLen(GuiCtrlRead ($input[6]))
   $var8 = StringLen(GuiCtrlRead ($input[7]))
   
If $var1 = 4 And $var2 = 4 And $var3 = 4 And $var4 = 4 _
         And $var5 = 4 And $var6 = 4 And $var7 = 4 And $var8 = 4 And Not ControlCommand($GUI, "", $add, "IsEnabled", "") Then
      GUICtrlSetState($add, $GUI_ENABLE)
          
     ElseIf $var1 <> 4 And $var2 <> 4 And $var3 <> 4 And $var4 <> 4 And $var5 <> 4 And _
         $var6 <> 4 And $var7 <> 4 And $var8 <> 4 And ControlCommand($GUI, "", $add, "IsEnabled", "") Then
      GUICtrlSetState($add, $GUI_DISABLE)
   EndIf
Wend

Func _IsPressedMod()
  Local $aR, $bRv
  For $i = 8 to 128
      $hexKey = '0x' & Hex($i, 2)
      $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
      If $aR[0] <> 0 Then Return $i
  Next
  Return 0
EndFunc


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

cool, i had $ip at the end of add before.

ok, i get it now. thanks.


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

also... wondering how i could have the script detect which input the cursor was currently on?

and i can probably eventually figure out on my own how to check for duplicates before i write to the list.

ty in advance :)


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

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