Jump to content

Function


smita
 Share

Recommended Posts

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("Pelco - Login - Microsoft Internet Explorer","Google")

If Not WinActive("Pelco - Login - Microsoft Internet Explorer","Google") Then

WinActivate("Pelco - Login - Microsoft Internet Explorer","Google")

Send("admin") //username - admin

Send("{TAB}")

Send("admin") //password - admin

Send("{TAB}{ENTER}") //Enter the login button

I have recorded this script , now i want to add function for username & password, I don't know how to use function.

Link to comment
Share on other sites

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("Pelco - Login - Microsoft Internet Explorer","Google")

If Not WinActive("Pelco - Login - Microsoft Internet Explorer","Google") Then

WinActivate("Pelco - Login - Microsoft Internet Explorer","Google")

Send("admin") //username - admin

Send("{TAB}")

Send("admin") //password - admin

Send("{TAB}{ENTER}") //Enter the login button

I have recorded this script , now i want to add function for username & password, I don't know how to use function.

look in help file under func.

from help file:

Func functioname ( [Const] [byRef] $param1, ..., [Const] [byRef] $paramN, $optionalpar1 = value, ...)

...

[Return [value]]

EndFunc

; Sample script with three user-defined functions
; Notice the use of variables, ByRef, and Return

$foo = 2
$bar = 5
msgBox(0,"Today is " & today(), "$foo equals " & $foo)
swap($foo, $bar)
msgBox(0,"After swapping $foo and $bar", "$foo now contains " & $foo)
msgBox(0,"Finally", "The larger of 3 and 4 is " & max(3,4))
Exit

Func swap(ByRef $a, ByRef $b) ;swap the contents of two variables
    Local $t
    $t = $a
    $a = $b
    $b = $t
EndFunc

Func today() ;Return the current date in mm/dd/yyyy form
    return (@MON & "/" & @MDAY & "/" & @YEAR)
EndFunc

Func max($x, $y) ;Return the larger of two numbers
    If $x > $y Then
        return $x
    Else
        return $y
    EndIf
EndFunc

;End of sample script
Link to comment
Share on other sites

Another ex...

#include <GuiConstants.au3>

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)

HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "ShowMe")

First()
Second()

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func First()
    WinWait("Pelco - Login - Microsoft Internet Explorer", "Google")
    If Not WinActive("Pelco - Login - Microsoft Internet Explorer", "Google") Then
        WinActivate("Pelco - Login - Microsoft Internet Explorer", "Google")
    EndIf
EndFunc   ;==>First

Func Second()
    $User = InputBox("Title", "Please Type in your User Name")
    Send($User, 1) ;//username - admin
    Send("{TAB}")
    $Pass = InputBox("Title", "Please Type in your Password")
    Send($Pass, 1) ;//password - admin
    Send("{TAB}{ENTER}") ;//Enter the login button
EndFunc   ;==>Second

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMe()
    MsgBox(4096, "Thanks", "    ... Valuater!    ", 2)
EndFunc   ;==>ShowMe

8)

Edited by Valuater

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...