Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Programming Help in VB 6!! Need 1 tip or 2  (Read 15704 times)

0 Members and 1 Guest are viewing this topic.

drago87

    Topic Starter


    Rookie
    Programming Help in VB 6!! Need 1 tip or 2
    « on: December 16, 2007, 02:55:16 PM »
    Need to write a file that.

    1. After started wait fore 10 sek
    2. Clicks the 'u' button
    3. Waits 0,5 sek
    4. Set a loop for about 9999 times then another loop fore 30
    5. Clicks the '1' button
    6. Waits 4 sek
    7. Clicks the '2' button
    8. Then run the next loop
    9. After 30 loops clicks the 'p' button
    10. then restart from steep 5 after 10 sek

    this is what i hawed made but it is sent working at all.

    @echo on
    delay(10000)
    KB_CLK(u)
    delay(500)
    loop(9999)
    loop(30)
    KB_CLK(1)
    delay(4000)
    KB_CLK(2)
    delay(4000)
    nextloop()
    KB_CLK(p)
    delay(10000)
    nextloop()
    PAUSE

    If you don't want to make the code you can just give me some pointers. I'm still new to this.

    I'm writing it in an text doc that i'm converting to a *.bat file.

    I could always start whit another prog but i don't now witch.

    Hawe chose tho make it in Visual Basic.
    « Last Edit: December 20, 2007, 04:04:36 PM by drago87 »

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Programming Help in VB!! Need 1 tip or 2
    « Reply #1 on: December 17, 2007, 01:31:33 PM »
    With all the loops and delays, all I see is a total of 4 key entries. Please explain what you are trying to accomplish and what application are you using to create the text doc.

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    drago87

      Topic Starter


      Rookie
      Re: Programming Help in VB!! Need 1 tip or 2
      « Reply #2 on: December 17, 2007, 01:38:25 PM »
      I hawed done this so fare.


      KeyAscii 170 is x but i want use ascii for F11
      KeyAscii 172 is z but i want use ascii for F10
      PS1C is a text box that will set what key it will press
      PS2C is a text box that will set what key it will press
      AS1C is a text box that will set what key it will press
      AS2C is a text box that will set what key it will press
      AS1T is a text box that will set the delay between the key presses
      AS2T is a text box that will set the delay between the key presses
      kb_cl is meant to be the clicking command (but i doupe it work)


      ------------------------------------
      KeyAscii As Integer
      Private Sub Form_Load()

      If KeyAscii = 170 Then
          press 'u'
          delay 500
          If PS1C <> empty Then
              kb_cl = PS1C
          End If
          If PS2C <> empty Then
              kb_cl = PS2C
              End If
      Loop Until KeyAscii = 172
      Loop Until 30
          If AS1C <> empty Then
              kb_cl = AS1C
              delay = AS1T
          End If
          If AS2C <> empty Then
              kb_cl = AS2C
              delay = AS1T
          End If
      next loop
      kb_cl 'p'
      delay 10000
      next loop

      End Sub

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Programming Help in VB!! Need 1 tip or 2
      « Reply #3 on: December 17, 2007, 02:28:53 PM »
      Still not really sure where this is going.

      Never did it this way before, but you might be able to use the sendkeys function to get a value into a text box. I guess I would ensure the textbox has focus first. The sendkeys functon has a wait parameter so you can build in your delays there.

      Usually it's easier to set the text property of the textbox to a value: psc1.text = value. There is also a sleep function in VB but I seem to remember it in the API:

      Code: [Select]
      Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

      Use as: sleep nnnnn where nnnnn is measured in milliseconds (1 sec = 1000 milliseconds)

      As far as I know a loop statement must be matched with a do or do while statement.

      Are you trying to automate a process. If we had the whole picture, there might be other ways of doing it.

       8)

      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      drago87

        Topic Starter


        Rookie
        Re: Programming Help in VB!! Need 1 tip or 2
        « Reply #4 on: December 17, 2007, 02:52:01 PM »
        Dont know how to insert a pic from my hard drive but i vill see if i can draw a pic
        betveen the 2 |         |  is the text box whid the name off the box


        ---------------------------------------------------------

                                      Start F11
                                      Stop F10

                                Skill Slott                Time (mS)

        Passive Skill 1 |   PS1C     |
        Passive Skill 2 |   PS2C     |

        Aktive Skill 1   |    AS1C    |           |     AS1T   |
        Aktive Skill 2   |    AS2C    |           |     AS2T   |



        ---------------------------------------------------------

        The PS1C and PS2C is going to start after i hawe pressed the F11 key and 0,5 sek after the prog hawe pressed the 'u' key
        example:    PS1C = 1 and PS2C = 2 the prog will press the 1 key then wait fore 0,5 sek then presses the 2 key.

        The AS1C and AS2C is the same but the AS1T and AS2T sets a time
        example AS1C is 3 and AS2C is 4 the AS1T is 5000 and AS2T is 3000
        The prog presses the 3 key waits fore 5 sek then press 4 waits 3 sek then press 3 agen.
        After 30st 3 presses and 30 4 presses the prog presses the 'p' key waits fore 10 sek then begins to press 3 and 4 agen fore 30 times.

        think that is all.

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: Programming Help in VB!! Need 1 tip or 2
        « Reply #5 on: December 18, 2007, 07:16:53 AM »
        Quote
        Dont know how to insert a pic from my hard drive

        Try using an image control on your form. The snippet shows how it works:

        Code: [Select]
        Image1.Picture = LoadPicture("c:\image00A.jpg")

        I've lost track of the status of this post. Be sure to get back to us if you have any more questions.

         8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        drago87

          Topic Starter


          Rookie
          Re: Programming Help in VB!! Need 1 tip or 2
          « Reply #6 on: December 18, 2007, 09:01:17 AM »
          What is the code so that the prog uses the 1 2 3 4 u p andso i can start/stop whid  the F11 F10 buttons??

          i ment on the forum  ::)

          This is what i hawe done now

          If KeyAscii = 170 Then 'start running the prog when press the x button (want it to be the F11 button)
              Asc passiv1 = PS1C
              SendKeys u ' press the u key
              'sleep 500 ' wait for 0,5 sek 'this line generates the error Sub or Funktion not defined
              If PS1C <> Empty Then 'If the txt box PS1C is not empty then contineu
                  SendKeys PS1C 'press the button that is assigned to PS1C ex 1
                  sleep 500 ' wait for 0,5 sek 'this line generates the error Sub or Funktion not defined
              End If
              If PS2C <> Empty Then 'If the txt box PS2C is not empty then contineu
                  SendKeys PS2C 'press the button that is assigned to PS2C ex 2
                  sleep 500 ' wait 0,5 sek 'this line generates the error Sub or Funktion not defined
                  End If
          Do Until KeyAscii = 172 'stop running the prog when press the z button (want it to be the F10 button)
              Do While lop < 30 'run this part 30 times
                  If AS1C = Empty Then
                      SendKeys AS1C 'press the button that is assigned to PS1C ex 3
                      sleep = AS1T 'wait for the number in mS assigned in AS1T ex 5000 (5 sek) 'this line generates the error Sub or Funktion not defined
                  End If
                  If AS2C = Empty Then
                      SendKeys AS2C 'press the button that is assigned to PS1C ex 4
                      sleep = AS2T 'wait for the number in mS assigned in AS1T ex 3000 (3 sek) 'this line generates the error Sub or Funktion not defined
                  End If
                  Set lop = lop + 1
              Loop
          SendKeys p ' press the p key
          sleep 10000 'wait 10 sek 'this line generates Sub or Funktion not defined
          Set lop = 1 ' resett the lop ' this line generats a error "objekt required
          Loop
          « Last Edit: December 18, 2007, 10:00:45 AM by drago87 »

          drago87

            Topic Starter


            Rookie
            Re: Programming Help in VB!! Need 1 tip or 2
            « Reply #7 on: December 18, 2007, 02:23:19 PM »
            Hawe done some changes

             This is what i loock like
            betveen the 2 / / is a text box whid the name off the box


            ---------------------------------------------------------

                                          Start F11
                                          Stop F10

                                    Skill Slott Time (mS)

            Passive Skill 1 / PS1C /
            Passive Skill 2 / PS2C /

            Aktive Skill 1 / AS1C / / AS1T /
            Aktive Skill 2 / AS2C / / AS2T /


            Times to repet / repete /



            ---------------------------------------------------------

            The PS1C and PS2C is going to start after i hawe pressed the F11 key and 0,5 sek after the prog hawe pressed the 'u' key
            example: PS1C = 1 and PS2C = 2 the prog will press the 1 key then wait fore 0,5 sek then presses the 2 key.

            The AS1C and AS2C is the same but the AS1T and AS2T sets a time
            example AS1C is 3 and AS2C is 4 the AS1T is 5000 and AS2T is 3000
            The prog presses the 3 key waits fore 5 sek then press 4 waits 3 sek then press 3 agen.
            After 30st 3 presses and 30 4 presses the prog presses the 'p' key waits fore 10 sek then begins to press 3 and 4 agen fore 30 times.

            that if i hawe inputet 30 in the "Times to repet" txt box.

            think that is all.


            this is waht i hawe done. (hawent got it to wurk att all)

            After a ' it is a coment on what i want the line to do.

            Dim lop As Integer
            Dim PS1 As Integer
            Dim PS2 As Integer
            Dim AS1 As Integer
            Dim AS2 As Integer
            Dim AS1a As Integer
            Dim AS2a As Integer
            Dim SendKeys As String

            Dim repetetimes As Integer

            Private Sub Form_Load()

            Me.KeyPreview = True

            End Sub


            Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

            Debug.Print KeyCode, Shift
            Select Case KeyCode

            Case vbKeyF11

                lop = 1
                PS1 = PS1C.Text
                PS2 = PS2C.Text
                AS1 = AS1C.Text
                AS2 = AS2C.Text
                AS1a = AS1T.Text
                AS2a = AS2T.Text
                repetetimes = repet.Text
               
               
                object.SendKeys "u" ' press the u key
                object.sleep 500 ' wait for 0,5 sek
               
                If PS1C <> "Input" Then 'If the txt box PS1C is not empty then contineu
                   ' SendKeys 1 'press the button that is assigned to PS1C ex 1
                    object.sleep 500 ' wait for 0,5 sek
                End If
               
                If PS2C <> "Input" Then 'If the txt box PS2C is not empty then contineu
                    object.SendKeys PS2 'press the button that is assigned to PS2C ex 2
                    object.sleep 500 ' wait 0,5 sek
                End If
            'Do Until Case vbKeyF10 'stop running the prog when press the F10 button
            start:
             
                Do While lop < repetetimes 'run this part the times specified in the "Times to repet" txt box
                   
                    If AS1C <> "Input" Then
                        object.SendKeys AS1 'press the button that is assigned to PS1C ex 3
                        object.sleep = AS1a 'wait for the number in mS assigned in AS1T ex 5000 (5 sek)
                    End If
                   
                    If AS2C <> "Input" Then
                        object.SendKeys AS2 'press the button that is assigned to PS1C ex 4
                        object.sleep = AS2a 'wait for the number in mS assigned in AS1T ex 3000 (3 sek)
                   
                    End If
                   
                    lop = lop + 1
               
                Loop

            object.SendKeys "p" ' press the p key
            object.sleep 10000 'wait 10 sek
            lop = 1 ' resett the lop
            Case vbKeyF10 = DoEvents
            GoTo start
            'Loop

            End Sub


            I want to be able to press the F11 key in eny prog to start the prosess.


            This is wahat it loocks like
            « Last Edit: December 19, 2007, 11:49:00 AM by drago87 »

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: Programming Help in VB!! Need 1 tip or 2
            « Reply #8 on: December 18, 2007, 04:28:02 PM »
            Glad to see you moved your code out of the load event and into the keypress event. Check out the DoEvents command. This will allow the program to breakout of the loop and check for pending interrupts (F10 in your case). It's sort of like allowing the program to come up for air.  :D
            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            drago87

              Topic Starter


              Rookie
              Re: Programming Help in VB!! Need 1 tip or 2
              « Reply #9 on: December 18, 2007, 10:13:28 PM »
              Ok. But i still hawent got it to respond to the F11 button or the x.
              Do you now a site wher they hawe exeples of codes??
              I want to make it respond to the F11 before moving on. like making

              press F11 a messagebox aprere then press F10 to make it diapere. then i can use that code and alter it to make it wurk im my case.

              Sidewinder



                Guru

                Thanked: 139
              • Experience: Familiar
              • OS: Windows 10
              Re: Programming Help in VB!! Need 1 tip or 2
              « Reply #10 on: December 19, 2007, 04:49:55 AM »
              I was always told, when I find myself in a hole to stop digging. Ever the optimist, I'm looking for the light at the end of the tunnel.

              Try using the _KeyUp or _KeyDown events. This example may prove helpful.

               8)
              The true sign of intelligence is not knowledge but imagination.

              -- Albert Einstein

              drago87

                Topic Starter


                Rookie
                Re: Programming Help in VB!! Need 1 tip or 2
                « Reply #11 on: December 19, 2007, 09:12:33 AM »
                The code you linked to will be off much use. Now yust to implement it in mine.

                I'l Skream if i hawe some more problems.

                Edit...

                Uppdated the last post vhid the new code.

                How can i make the PS1 Integer hawe the content of PS1C??
                « Last Edit: December 19, 2007, 11:49:40 AM by drago87 »

                Sidewinder



                  Guru

                  Thanked: 139
                • Experience: Familiar
                • OS: Windows 10
                Re: Programming Help in VB!! Need 1 tip or 2
                « Reply #12 on: December 19, 2007, 12:48:42 PM »
                From your code, I can only guess that PS1C never had a value of "Input" so you used SendKeys to put it's value to 1. Try using the CInt function:

                PS1 = CInt(PS1C.Text)

                 8)

                By the way, whatever happened to the pictures?


                The true sign of intelligence is not knowledge but imagination.

                -- Albert Einstein

                drago87

                  Topic Starter


                  Rookie
                  Re: Programming Help in VB!! Need 1 tip or 2
                  « Reply #13 on: December 19, 2007, 01:16:43 PM »
                  What pic do you mean??
                  The "Hand" written pic or the scr shot??

                  now the only thing i got a prob (that i now of) is the object.SendKeys
                  and i dont know if the stopp command wurks jet.

                  Sidewinder



                    Guru

                    Thanked: 139
                  • Experience: Familiar
                  • OS: Windows 10
                  Re: Programming Help in VB!! Need 1 tip or 2
                  « Reply #14 on: December 19, 2007, 04:05:15 PM »
                  Couple of points:

                  1. object.SendKeys...you do not need an object reference;

                  Code: [Select]
                  Sendkeys "{enter}"

                  2. Case vbKeyF10 = DoEvents...DoEvents is a function, not a value

                  Code: [Select]
                  Case vbKeyF10
                      DoEvents()
                      .
                      .
                      .

                  3. There is no stop statement. Are you referring to ending the program or exiting a loop?

                  Are you using the VB IDE to develop this project? If so, you can use the F1 key liberally for most of the help you need.
                  The true sign of intelligence is not knowledge but imagination.

                  -- Albert Einstein

                  drago87

                    Topic Starter


                    Rookie
                    Re: Programming Help in VB!! Need 1 tip or 2
                    « Reply #15 on: December 20, 2007, 08:54:23 AM »
                    If i press the F1 i get "The MSDN collection does not exist. Please reinstall MSDN.
                    But i cant find MSDN. So i can't install it.

                    And Sendkeys "{enter}" can i write Sen keys "{u}" instead??
                    and how do i do to take the information from the text boxes and use that key??

                    By stop i mean to end the loop And Wait fore the F11 key to be pressed agen.

                    Both the F10 and F11 i want to be accessed even if i hawnt got my own prog selected.
                    « Last Edit: December 20, 2007, 10:08:46 AM by drago87 »

                    drago87

                      Topic Starter


                      Rookie
                      Re: Programming Help in VB!! Need 1 tip or 2
                      « Reply #16 on: December 20, 2007, 10:52:59 AM »
                      This is what it locks like

                      Whid this i get a infernal loop when i press the F11 that i hawe to ctrl+alt+delet to get out off

                      still dont now if i kan stop the loop whid the F10 button but it started whid the F11

                      Code: (vb) [Select]
                      Dim lop As Integer
                      Dim PS1 As Integer
                      Dim PS2 As Integer
                      Dim AS1 As Integer
                      Dim AS2 As Integer
                      Dim AS1a As Integer
                      Dim AS2a As Integer
                      Dim repetetimes As Integer
                      Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

                      Private Sub AS1C_GotFocus()
                      AS1C = ""
                      End Sub

                      Private Sub AS1T_GotFocus()
                      AS1T = ""
                      End Sub

                      Private Sub AS2C_GotFocus()
                      AS2C = ""
                      End Sub

                      Private Sub AS2T_GotFocus()
                      AS2T = ""
                      End Sub

                      Private Sub Form_Load()

                      Me.KeyPreview = True

                      End Sub

                      Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)


                      start:
                      Debug.Print KeyCode, Shift
                      Select Case KeyCode

                      Case vbKeyF11

                          lop = 1
                          PS1 = CInt(PS1C.Text)
                          PS2 = CInt(PS2C.Text)
                          AS1 = CInt(AS1C.Text)
                          AS2 = CInt(AS2C.Text)
                          AS1a = CInt(AS1T.Text)
                          AS2a = CInt(AS2T.Text)
                          repetetimes = CInt(repet.Text)
                         
                         
                          SendKeys "{u}" ' press the u key
                          Sleep (500) ' wait for 0,5 sek

                          If PS1C <> "Input" Then 'If the txt box PS1C is not empty then contineu
                              SendKeys PS1 'press the button that is assigned to PS1C ex 1
                              Sleep (500) ' wait for 0,5 sek
                          End If
                         
                          If PS2C <> "Input" Then 'If the txt box PS2C is not empty then contineu
                              SendKeys PS2 'press the button that is assigned to PS2C ex 2
                              Sleep (500) ' wait 0,5 sek
                          End If
                      'Do Until Case vbKeyF10 'stop running the prog when press the F10 button

                       
                          Do While lop < repetetimes 'run this part the times specified in the "Times to repet" txt box
                             
                              If AS1C <> "Input" Then
                                  SendKeys AS1 'press the button that is assigned to PS1C ex 3
                                  Sleep (AS1a) 'wait for the number in mS assigned in AS1T ex 5000 (5 sek)
                              End If
                             
                              If AS2C <> "Input" Then
                                  SendKeys AS2 'press the button that is assigned to PS1C ex 4
                                  Sleep (AS2a) 'wait for the number in mS assigned in AS1T ex 3000 (3 sek)
                             
                              End If
                             
                              lop = lop + 1
                         
                          Loop

                      SendKeys "{p}" ' press the p key
                      Sleep (10000) 'wait 10 sek
                      lop = 1 ' resett the lop
                      Case vbKeyF10
                      'DoEvents() ' if i delet the ' before the DoEvents() i get a "syntax error"
                      GoTo start
                      'Loop
                      End Select
                      End Sub

                      Private Sub PS1C_GotFocus()
                      PS1C = ""
                      End Sub

                      Private Sub PS2C_GotFocus()
                      PS2C = ""
                      End Sub

                      Private Sub repet_GotFocus()
                      repet = ""
                      End Sub

                      Sidewinder



                        Guru

                        Thanked: 139
                      • Experience: Familiar
                      • OS: Windows 10
                      Re: Programming Help in VB!! Need 1 tip or 2
                      « Reply #17 on: December 20, 2007, 01:20:15 PM »
                      You had it right originally:

                      1. SendKeys "u"

                      I used a bad example, the curly braces are for keys on the keyboard that do not produce a character  (like enter, tab, backspace, etc).

                      2. Do Until Case vbKeyF10 is illegal syntax; try Do Until vbKeyF10

                      Case is part of the Select construct.

                      3. Try using the DoEvents without the parenthesis. Not sure how helpful DoEvents will actually be; most times it's in a loop so the form can be updated. Hey! you never know.

                      I probably should have asked this a lot sooner, but what version of VB are you using? If you're using an IDE, you can set checkpoints and then step into the code line by line to see how the program flows and what values the variables have.

                       8)

                      Maybe we should change the title of this post: "Re: Programming Help in VB!! Need 1 tip or 2"  ;D

                      The true sign of intelligence is not knowledge but imagination.

                      -- Albert Einstein

                      drago87

                        Topic Starter


                        Rookie
                        Re: Programming Help in VB 6!! Need 1 tip or 2
                        « Reply #18 on: December 20, 2007, 04:28:28 PM »
                        The stop was only to inplement that i want the prog to stop running when the F10 was pressed
                        i kant make the DoEvents to wurk
                        i am using VB 6.0

                        and i gotten to prog to youst lock fore a few sek then write u12 (in the box i had seleckted) and make the num lock go on and off once

                        i still can't run the prog in eny other prog (like word)
                         
                        This is the whole code now

                        Code: (vb) [Select]
                        Dim lop As Integer
                        Dim PS1 As Integer
                        Dim PS2 As Integer
                        Dim AS1 As Integer
                        Dim AS2 As Integer
                        Dim AS1a As Integer
                        Dim AS2a As Integer
                        Dim repetetimes As Integer
                        Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

                        Private Sub AS1C_GotFocus()
                        AS1C = ""
                        End Sub

                        Private Sub AS1T_GotFocus()
                        AS1T = ""
                        End Sub

                        Private Sub AS2C_GotFocus()
                        AS2C = ""
                        End Sub

                        Private Sub AS2T_GotFocus()
                        AS2T = ""
                        End Sub

                        Private Sub Form_Load()

                        Me.KeyPreview = True

                        End Sub

                        Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

                        'start:
                        Debug.Print KeyCode, Shift
                        Select Case KeyCode

                        Case vbKeyF11

                            lop = 1
                            If PS1C > -1 And PS1C < 10 Then
                                PS1 = CInt(PS1C.Text)
                            End If
                            If PS2C > -1 And PS2C < 10 Then
                                PS2 = CInt(PS2C.Text)
                            End If
                            If AS1C > -1 And PS1C < 1 Then
                                AS1 = CInt(AS1C.Text)
                            End If
                            If AS2C > -1 And AS2C < 10 Then
                                AS2 = CInt(AS2C.Text)
                            End If
                            If AS1T > 0 Then
                                AS1a = CInt(AS1T.Text)
                            End If
                            If AS2T > 0 Then
                                AS2a = CInt(AS2T.Text)
                            End If
                            If repet > 0 Then
                                repetetimes = CInt(repet.Text)
                            Else
                            MsgBox "You hawe to set more then that", vbInformation
                            End If
                           
                           
                            SendKeys "u" ' press the u key
                            Sleep (500) ' wait for 0,5 sek

                            If PS1C <> "Input" Then 'If the txt box PS1C is not empty then contineu
                                SendKeys PS1 'press the button that is assigned to PS1C ex 1
                                Sleep (500) ' wait for 0,5 sek
                            End If
                           
                            If PS2C <> "Input" Then 'If the txt box PS2C is not empty then contineu
                                SendKeys PS2 'press the button that is assigned to PS2C ex 2
                                Sleep (500) ' wait 0,5 sek
                            End If
                        Do Until vbKeyF10 'stop running the prog when press the F10 button

                         
                            Do While lop < repetetimes 'run this part the times specified in the "Times to repet" txt box
                               
                                If AS1C <> "Input" Then
                                    SendKeys AS1 'press the button that is assigned to PS1C ex 3
                                    Sleep (AS1a) 'wait for the number in mS assigned in AS1T ex 5000 (5 sek)
                                End If
                               
                                If AS2C <> "Input" Then
                                    SendKeys AS2 'press the button that is assigned to PS1C ex 4
                                    Sleep (AS2a) 'wait for the number in mS assigned in AS1T ex 3000 (3 sek)
                               
                                End If
                               
                                lop = lop + 1
                           
                            Loop

                        SendKeys "p" ' press the p key
                        Sleep (10000) 'wait 10 sek
                        lop = 1 ' resett the lop
                        'Case vbKeyF10
                        DoEvents
                        'GoTo start
                        Loop
                        End Select
                        End Sub

                        Private Sub PS1C_GotFocus()
                        PS1C = ""
                        End Sub

                        Private Sub PS2C_GotFocus()
                        PS2C = ""
                        End Sub

                        Private Sub repet_GotFocus()
                        repet = ""
                        End Sub

                        Im i missing somthing??

                        If i change the 3 first wait commands it locks fore a longer period of time then write ute the u12 is there a sulution to make it right after line
                        Code: (vb) [Select]
                        SendKeys "u" it uses it not wait untill it hawe done all?

                        Sidewinder



                          Guru

                          Thanked: 139
                        • Experience: Familiar
                        • OS: Windows 10
                        Re: Programming Help in VB 6!! Need 1 tip or 2
                        « Reply #19 on: December 20, 2007, 06:03:46 PM »
                        You have a set of nested do loops but the outer loop is incomplete unless the Case vbKeyF10 line is commented out. I suspect you'll eventually need that case statement.

                        I may be missing something, but shouldn't PS1C and PS2C be initialized with values before you check to see if they are > -1 and < 10 ???

                        The SendKeys "u" is correct syntax but the keystroke is at the cursor position. Where is the cursor? (I don't know either)

                        Quote
                        i still can't run the prog in eny other prog (like word)
                        I'm not sure where you're going with this but to run this within the Word application you'd need to run it as a macro.

                        VB is an event driven language which makes it perfect for interactive applications. Your program seems to be acting as both a program and a user in that it's creating the events and then running code in response. I know I'm a little slow on the uptake, but I still have no idea what you're trying to accomplish.

                         8)
                        The true sign of intelligence is not knowledge but imagination.

                        -- Albert Einstein

                        drago87

                          Topic Starter


                          Rookie
                          Re: Programming Help in VB 6!! Need 1 tip or 2
                          « Reply #20 on: December 21, 2007, 01:21:04 AM »
                          word was just a exp i want to run it in 9Dragons a MMORPG

                          tis is what it locks like before i press the F11

                                                        Start F11
                                                        Stop F10

                                                     Skill Slot     Time (mS)

                          Passive Skill 1         / 1 /
                          Passive Skill 2         / 2 /

                          Active Skill 1           / 3 /            / 2000 /
                          Active Skill 2           / 4 /            / 3000 /


                          Times to repeat       / 5/

                          and if the cursor is located at the Times to repetwhen i press F11 it locks like this


                          Times to repeat      /5u12/

                          if i hawe it at the Active Skill 1 it looks like this

                          Active skill 1          /1u12/

                          so the check
                              If PS1C > -1 And PS1C < 10 Then
                                  PS1 = CInt(PS1C.Text)
                              End If
                          seems to work

                          Well i'm going on wecation now so i cant complet it before new year.

                          but i'l bump this later if i need more help

                          So werry christmas and a happy new year.

                          drago87

                            Topic Starter


                            Rookie
                            Re: Programming Help in VB 6!! Need 1 tip or 2
                            « Reply #21 on: January 06, 2008, 11:34:24 AM »
                            Well i'm back and hawe the same problem.

                            What is does so far.

                            When i press the F11 button it locks fore about 1-3 sek and then it writes u and what i hawe wrutten in the first 2 text boxes then nothing more.

                            What i want it to do.

                            I want to be able to start it in eny program.
                            It wont lock when i press F11.(whrites the u and the first 2 boxes whidout locking)
                            It start writing the 3 and 4 text boxes(like this 3 wait 4 wait 3 wait 4 wait 3 wait 4 wait)
                            The 3 and 4 from the last example can be change to enyting betwene 0 and 9 and the wait can be changed seperatly in the 2 boxes on the right
                            The last box is for how meny times box 3 and 4 shell run before the prog press p
                            The F10 button whill stop the loop
                            All this whidout locking the computer betwene the writings.

                            drago87

                              Topic Starter


                              Rookie
                              Re: Programming Help in VB 6!! Need 1 tip or 2
                              « Reply #22 on: January 07, 2008, 02:30:47 AM »
                              Well i made som changes.

                              Now it writes the 3 and 4 txt box and the p also but it still locks but i can move the mouse betveen the loops  and i still can't start it whidout having it marked.

                              i think it can be the SendKeys command or the wait command


                              Code: (vb) [Select]
                              Dim lop As Integer
                              Dim PS1 As Integer
                              Dim PS2 As Integer
                              Dim AS1 As Integer
                              Dim AS2 As Integer
                              Dim AS1a As Integer
                              Dim AS2a As Integer
                              Dim repetetimes As Integer
                              Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
                              Dim bCancel As Boolean

                              Private Sub AS1C_GotFocus()
                              AS1C = ""
                              End Sub

                              Private Sub AS1T_GotFocus()
                              AS1T = ""
                              End Sub

                              Private Sub AS2C_GotFocus()
                              AS2C = ""
                              End Sub

                              Private Sub AS2T_GotFocus()
                              AS2T = ""
                              End Sub

                              Private Sub Form_Load()

                              Me.KeyPreview = True

                              End Sub

                              Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)


                              Debug.Print KeyCode, Shift
                              Select Case KeyCode

                              Case vbKeyF11
                                  bCancel = False

                                  PS1C.Enabled = False 'So that you dont change it when it runns
                                 
                                  lop = 1
                                  If PS1C <> "Input" And PS1C <> "" Then
                                      PS1 = CInt(PS1C.Text)
                                  End If
                                  If PS2C <> "Input" And PS2C <> "" Then
                                      PS2 = CInt(PS2C.Text)
                                  End If
                                  If AS1C <> "Input" And PS1C <> "" Then
                                      AS1 = CInt(AS1C.Text)
                                  End If
                                  If AS2C <> "Input" And AS2C <> "" Then
                                      AS2 = CInt(AS2C.Text)
                                  End If
                                  If AS1T <> "Input" And AS1T <> "" Then
                                      AS1a = CInt(AS1T.Text)
                                  End If
                                  If AS2T <> "Input" And AS2T <> "" Then
                                      AS2a = CInt(AS2T.Text)
                                  End If
                                  If repet <> "Input" And repet <> "" And repet > 0 Then
                                      repetetimes = CInt(repet.Text)
                                  Else
                                  MsgBox "You hawe to set more then that", vbInformation
                                  End If
                                 
                                 
                                  SendKeys "u" ' press the u key
                                  Sleep (500) ' wait for 0,5 sek

                                  If PS1C <> "Input" And PS1C <> "" Then 'If the txt box PS1C is not empty then contineu
                                      SendKeys PS1 'press the button that is assigned to PS1C ex 1
                                      Sleep (500) ' wait for 0,5 sek
                                  End If
                                 
                                  If PS2C <> "Input" And PS2C <> "" Then 'If the txt box PS2C is not empty then contineu
                                      SendKeys PS2 'press the button that is assigned to PS2C ex 2
                                      Sleep (500) ' wait 0,5 sek
                                  End If
                                  DoEvents
                              Do While Not bCancel 'stop running the prog when press the F10 button

                               
                                  Do While lop < repetetimes 'run this part the times specified in the "Times to repet" txt box
                                     
                                      If AS1C <> "Input" Then
                                          SendKeys AS1 'press the button that is assigned to PS1C ex 3
                                          Sleep (AS1a) 'wait for the number in mS assigned in AS1T ex 5000 (5 sek)
                                      End If
                                     
                                      If AS2C <> "Input" Then
                                          SendKeys AS2 'press the button that is assigned to PS1C ex 4
                                          Sleep (AS2a) 'wait for the number in mS assigned in AS1T ex 3000 (3 sek)
                                     
                                      End If
                                     
                                      lop = lop + 1
                                      DoEvents
                                  Loop

                              SendKeys "p" ' press the p key
                              Sleep (10000) 'wait 10 sek
                              lop = 0 ' resett the lop
                              'Case vbKeyF10
                              DoEvents
                              'GoTo start
                              Loop

                              Case vbKeyF10
                                  bCancel = True
                                  PS1C.Enabled = True
                                 
                              End Select

                              End Sub

                              Private Sub PS1C_GotFocus()
                              PS1C = ""
                              End Sub

                              Private Sub PS2C_GotFocus()
                              PS2C = ""
                              End Sub

                              Private Sub repet_GotFocus()
                              repet = ""
                              End Sub


                              drago87

                                Topic Starter


                                Rookie
                                Re: Programming Help in VB 6!! Need 1 tip or 2
                                « Reply #23 on: January 15, 2008, 05:13:31 AM »
                                -:Bump:-

                                Still need help

                                drago87

                                  Topic Starter


                                  Rookie
                                  Re: Programming Help in VB 6!! Need 1 tip or 2
                                  « Reply #24 on: January 22, 2008, 07:00:54 AM »
                                  -:Bump:-