proc LaunchApp {appPath} {
set pdir [pwd] cd "$appPath" set pid [::twapi::create_process appclient.exe -fullscreen true] cd $pdir if {[regexp "\[0-9]+(.*?)\[0-9]+" $pid match]} { #logMsg2File Sanity [list "Launch app client" "Successful"] after 10000 LoginToApp $appPath } else { #logMsg2File Sanity [list "Launch app client" "Fail"] }
}
proc LoginToApp {appPath} {
global ip global userid global password global flag set logininfoFlag 0 set appWindowCount 0 set loginWindowCount 0 set status 0 while {$appWindowCount != 10} { set windows [twapi::find_windows -text "2000 APP GUI"] if {[regexp "\[0-9]+(.*?)HWND" $windows match]} { set win [lindex $windows 0] twapi::set_foreground_window $win #logMsg2File Sanity [list "Find App Gui" "Successful"] set appWindowCount 10 set logininfoFlag 1 } else { incr appWindowCount #logMsg2File Sanity [list "attempt $appWindowCount searching \ # App Gui" "Successful"] after 10000 } } if {$logininfoFlag == 1} { while {$loginWindowCount != 3} { set windows [twapi::find_windows -text Login] if {[regexp "\[0-9]+(.*?)HWND" $windows match]} { set win [lindex $windows 0] twapi::set_foreground_window $win #logMsg2File Sanity [list "Find login screen" "Successful"] set loginWindowCount 3 set status 1 } else { incr loginWindowCount #logMsg2File Sanity [list "attempt $appWindowCount Waiting \ # login window" "Successful"] after 10000 } } } else { #logMsg2File Sanity [list "Find App Gui" "Fail"] } if {$status == 1} { if {[twapi::set_foreground_window $win]} { #logMsg2File Sanity [list "set login screen as a foreground" \ # "Successful"] } else { #logMsg2File Sanity [list "set login screen as a foreground" \ #"Fail"] } } else { #logMsg2File Sanity [list "Find login screen" "Fail"] exit } set windows [twapi::find_windows -text "Login settings"] twapi::set_foreground_window $win set win [lindex $windows 0] after 200 foreach {x y} [twapi::get_window_coordinates $win] break twapi::move_mouse [incr x -10] [incr y -30] twapi::click_mouse_button left after 2000 twapi::send_keys {{CLEAR}} after 100 twapi::send_input_text $ip after 100 twapi::send_keys {{TAB}} after 100 twapi::send_input_text $userid after 100 twapi::send_keys {{TAB}} after 100 twapi::send_input_text $userid after 100 twapi::send_keys {{ENTER}} after 7000 set windows [twapi::find_windows -text "Change Password, Current Password Expired"] if {[regexp "\[0-9]+(.*?)HWND" $windows match]} { #logMsg2File Sanity [list "Find chnage password screen" "Successful"] } else { #logMsg2File Sanity [list "Find chnage password screen" "Fail"] } set win [lindex $windows 0] after 2000 if {[twapi::set_foreground_window $win]} { #logMsg2File Sanity [list "set change password screen as a foreground" \ "Successful"] } else { #logMsg2File Sanity [list "set change password screen as a foreground" \ "Fail"] #exit } twapi::click_mouse_button left after 100 twapi::send_input_text $userid after 100 twapi::send_keys {{TAB}} after 1000 twapi::send_input_text $password after 1000 twapi::send_keys {{TAB}} after 1000 after 1000 twapi::send_input_text $password after 1000 twapi::send_keys {{ENTER}} after 20000 AppPluginInstall $appPath
}
LaunchApp "C:/sanity"
# this is a scenario where I am launching exe application, it prompt me for login window, once I login it prompt me another window for password change. # I tried to keep it short but I am sorry still it's a bit long