0
votes

I'm writing a small script with autohotkey.

  1. Opens App 2. Type in Login & Pass 3. Login 4. Do some Clicking.

I had some trouble of sending text to the application, only way it worked was "send {A}" which is like clicking a keyboard button.

I would like to create a loop around this steps and change Login each time. Standard procedure would be to have a text file a read from it but i don't know how i could do this with my send. Worst case would be to type a function for every login.

So is there a smart way to dynamically change the type on each loop interval? For example in the idea, i don't know how i can build the loop which changes the function each time, so on loop 1 = fn_login , login 2 = fn_login1 ...

    Loop
    {
        FN_OpenApp()
        FN_Login()
    }
ExitApp
    ===================================

    FN_OpenApp()
    {
        Click, 100, 100
    }

    FN_Login()
    {
        Click, 100, 100
        Send {U}
        Send {S}
        Send {E}
        Send {R}

        Click, 111, 111
        Send {P}
        Send {A}
        Send {S}
        Send {S}
    }


    ;idea__________________________________________


    Loop
    {
        FN_OpenApp()
        FN_LoginLoop()
    }

ExitApp    

    FN_OpenApp()
    {
        Click, 100, 100
    }

    FN_Login01()
    {
        Click, 100, 100
        Send {U}
        Send {S}
        Send {E}
        Send {R}

        Click, 111, 111
        Send {P}
        Send {A}
        Send {S}
        Send {S}
    }


    FN_Login02()
    {
        Click, 100, 100
        Send {U}
        Send {S}
        Send {E}
        Send {R}

        Click, 111, 111
        Send {P}
        Send {A}
        Send {S}
        Send {S}
    }

FN_LoginLoop()
{
 login := Object (FN_Login01(), FN_Login02())
 for ....
}
1
You know, you can actually send: Send {USER} instead. I suggest you take a look at arrays and strings in the official autohotkey documentation.2501
Yes i tried this but somehow the application doesn't respond to this, might try again.Kermit Christmas

1 Answers

1
votes

Does this help?

; Press F2 to run program
F2:: main()

main()
{
  credentials := [["user001","pass001"], ["user002","pass002"]]

  for i,cred in credentials
  {
    user     := cred[1]
    password := cred[2]
    FN_Login( user, password )
  }
}


FN_Login( user, password )
{
  MsgBox DEBUG: FN_Login(%user%`,%password%)

  click 100,100
  Send %user%
  click 111,111
  Send %password%
}