anyday Posted March 12, 2008 Share Posted March 12, 2008 i have a program for work that everytime i open it up, which is like 20 - 30 times a day, it ask's me for my login and password. I have no problems creating script that will enter this information for me, my question is whats the best way to have to loop where it is always looking for the window? ide like the script to always run maybe as a service and always be on the lookout for this window to pop up asking for login info. $user = "username" $pass = "pass" WinWaitActive("Login", "Reset Password") ControlSend("Login", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Login", "Reset Password", "ThunderRT6TextBox3", $pass) Sleep (20000) ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") Link to comment Share on other sites More sharing options...
spudw2k Posted March 12, 2008 Share Posted March 12, 2008 (edited) How 'bout this? $user = "username" $pass = "pass" Login($user,$pass) Func Login($user,$pass) Do Sleep(2000) Until WinExists("Login", "Reset Password") ControlSend("Login", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Login", "Reset Password", "ThunderRT6TextBox3", $pass) Sleep (20000) ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") Login($user,$pass) EndFunc Edited March 12, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
anyday Posted March 12, 2008 Author Share Posted March 12, 2008 seems to be working good, thanks alot Link to comment Share on other sites More sharing options...
anyday Posted March 12, 2008 Author Share Posted March 12, 2008 only drawback i see is that after everytime the script executes the login process, the mem usage increases, so if it is run 30 , 40 times a day 7 days a week that could become a problem, any way of having the script terminate and restart itself after every login? Link to comment Share on other sites More sharing options...
anyday Posted March 12, 2008 Author Share Posted March 12, 2008 (edited) $user = "user" $pass = "pass" Login($user,$pass) Func Login($user,$pass) Do Sleep(2000) Until WinExists("Logon", "Reset Password") ControlSend("Logon", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Logon", "Reset Password", "ThunderRT6TextBox3", $pass) Sleep (2000) ControlClick("Logon", "Reset Password", "ThunderRT6CommandButton3") Run ("login.exe", "") Exit EndFunc prob not the best way to do it but it works, any suggestions would be great also, there are more than one programs that asks for this same login and pass, there are different prompts any ideas? if statements maybe? Edited March 12, 2008 by anyday Link to comment Share on other sites More sharing options...
spudw2k Posted March 12, 2008 Share Posted March 12, 2008 (edited) Is this any better? Otherwise, the Run method you chose should work too. Global $user = "username" Global $pass = "pass" AdlibEnable("Login",500) HotKeySet("^!x","Quit") ;Ctrl+Alt+x to Quit While 1 Sleep(1000) WEnd Func Login() If WinExists("Login", "Reset Password") Then ControlSend("Login", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Login", "Reset Password", "ThunderRT6TextBox3", $pass) Sleep (20000) ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") EndIf EndFunc Func Quit() Exit EndFunc Edited March 12, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
ssubirias3 Posted March 12, 2008 Share Posted March 12, 2008 (edited) It might help if you understood the Sleep() command better. Sleep(1000) pauses the script for 1 second and Sleep(2000) pauses for 2 seconds. Is it necessary for the script to look for the login dialog every few seconds??? I wouldn't think so, but you're the only one that can answer that question. If it were me, I'd try and figure out what causes the login to pop-up. Does it happen every 5 minutes? Is it tied to keyboard/mouse inactivity like a screen saver??? Once you've figured out the trigger for the login you're trying to get around, then set Sleep() to a more CPU friendly interval. For example, if you know the login pops up every 10 minutes then you can have your script look for the window every 60 seconds (60 x 1000 = 60,000) so you'd use Sleep(60000). Things can get complicated in a hurry, but sometimes it best to keep it simple. Another thing to understand is the AdlibEnable(). Spudw2k suggests AdlibEnable("Login",500). However the 500 is milliseconds and would cause the function/script to run every half second. If Sleep(1000) runs every second and AdibEnable("Login",500) runs twice every second ... imagine how this will slow down your CPU. Not that I don't know much about this stuff, because I really don't, but I would have tweaked your original code like this: $user = "username" $pass = "pass" While 1 Sleep(60000) ;pauses script 60 seconds before checking for Login WinWaitActive("Login", "Reset Password") ControlSend("Login", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Login", "Reset Password", "ThunderRT6TextBox3", $pass) Sleep (20000) ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") Wend Hope this helps and good luck. Edited March 12, 2008 by ssubirias3 Link to comment Share on other sites More sharing options...
anyday Posted March 13, 2008 Author Share Posted March 13, 2008 (edited) ok so here's what i got now, im prob doing this all wrong but, here's my problem, i need this script to look out for multiple prompts that use the same password. here's what i have which seems to work sometimes. i just need the script to sit and wait for any of 3 or 4 different prompts any ideas the best way? expandcollapse popup$user = "login" $pass = "pass" $anagent = "Connect to secure.website.com" $fflogin = "fflogin" $ffpass = "ffpass" Sleep (3000) If WinExists("SAGE Logon", "Reset Password") Then WinActivate("SAGE Logon", "Reset Password") WinWaitActive("SAGE Logon", "Reset Password") ControlFocus("SAGE Logon", "Reset Password", "ThunderRT6TextBox4") Sleep(1000) ControlSend("SAGE Logon", "Reset Password", "ThunderRT6TextBox4", $user) ControlFocus("SAGE Logon", "Reset Password", "ThunderRT6TextBox3") Sleep(1000) ControlSend("SAGE Logon", "Reset Password", "ThunderRT6TextBox3", $pass) ControlClick("SAGE Logon", "Reset Password", "ThunderRT6CommandButton3") ElseIf WinExists("Login", "Reset Password") Then WinActivate("Login", "Reset Password") WinWaitActive("Login", "Reset Password") ControlFocus("Login", "Reset Password", "ThunderRT6TextBox1") ;Sleep(1000) Send ($user&"{enter}");ControlSend("Login", "Reset Password", "ThunderRT6TextBox1", $user) ;Sleep(500) ControlFocus("Login", "Reset Password", "ThunderRT6TextBox2") ;Sleep(500) Send ($pass);ControlSend("Login", "Reset Password", "ThunderRT6TextBox1", $pass) ;Sleep(1000) ControlFocus("Login", "Reset Password", "ThunderRT6CommandButton3") Send("{ENTER}") ;ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") ElseIf WinExists($anagent, "") Then WinWaitActive($anagent, "") ControlFocus($anagent, "", "Edit2") ControlSend($anagent, "", "Edit2", $user) ControlFocus($anagent, "", "Edit3") ControlSend($anagent, "", "Edit3", $pass) ControlClick($anagent, "", "Button2") EndIf If WinExists("Choose a digital certificate", "") Then WinWaitActive("Choose a digital certificate", "") ControlClick("Choose a digital certificate", "", "Button2") ElseIf WinExists("Connect to infocenter1.website.com", "") Then WinWaitActive("Connect to infocenter1.website.com", "") ControlFocus("Connect to infocenter1.website.com", "", "Edit2") ControlSend("Connect to infocenter1.website.com", "", "Edit2", $fflogin) ControlFocus("Connect to infocenter1.website.com", "", "Edit3") ControlSend("Connect to infocenter1.website.com", "", "Edit3", $ffpass) ControlClick("Connect to infocenter1.website.com", "", "Button2") EndIf run("logon3.exe", "") Exit Edited March 13, 2008 by anyday Link to comment Share on other sites More sharing options...
anyday Posted March 14, 2008 Author Share Posted March 14, 2008 Global $user = "user" Global $pass = "pass" AdlibEnable("Login", 500) AdLibEnable("TransLogin", 500) HotKeySet("^!x", "Quit"); Ctrl+Alt+X While 1 Sleep (1000) WEnd Func Login() If WinExists("Server Based Rating Logon", "Reset Password") Then ControlSend("Server Based", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Server Based", "Reset Password", "ThunderRT6TextBox3", $pass) ControlFocus("Server Based", "Reset Password", "ThunderRT6CommandButton3") ControlClick("Server Based", "Reset Password", "ThunderRT6CommandButton3") EndIf EndFunc Func TransLogin() If WinExists("Login", "Reset Password") Then ControlFocus("Login", "Reset Password", "ThunderRT6TextBox1") ControlSend("Login", "Reset Password", "ThunderRT6TextBox1", $user) ControlFocus("Login", "Reset Password", "ThunderRT6TextBox2") ControlSend("Login", "Reset Password", "ThunderRT6TextBox2", $pass) ControlFocus("Login", "Reset Password", "ThunderRT6CommandButton3") ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") WinWaitClose("Login", "Reset Password") EndIf EndFunc Func Quit() Exit EndFunc Got a question about the code above, the send function works fine, the TransLogin() function. The Login() function worked fine until i added the TransLogin() function. now the login() function does not work at all any ideas? my idea of how this code would run is ever 500ms it checks the first function then 500ms checks the 2nd and just keeps repeating? Link to comment Share on other sites More sharing options...
anyday Posted March 17, 2008 Author Share Posted March 17, 2008 been going crazy for 2 days now, trying to figure out how to make a script that watchs for up to 4 or 5 different logon prompts with no luck anyone with any fresh ideas? Link to comment Share on other sites More sharing options...
FreeFry Posted March 17, 2008 Share Posted March 17, 2008 I would use an array for it: expandcollapse popupGlobal $user = "user" Global $pass = "pass" Dim $LogonArray[2][3] $LogonArray[0][0] = "Server Based Rating Logon" ; Window Title $LogonArray[0][1] = "Reset Password" ; Window Text $LogonArray[0][2] = "Login" ; Function to call for this window $LogonArray[1][0] = "Login" ; Window Title $LogonArray[1][1] = "Reset Password" ; Window Text $LogonArray[0][2] = "TransLogin" ; Function to call for this window HotKeySet("^!x", "Quit"); Ctrl+Alt+X While 1 For $i = 0 To UBound($LogonArray)-1 If WinExists($LogonArray[$i][0], $LogonArray[$i][1]) Then Call($LogonArray[$i][2]) EndIf Next Sleep (1000) WEnd Func Login() ControlSend("Server Based", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Server Based", "Reset Password", "ThunderRT6TextBox3", $pass) ControlFocus("Server Based", "Reset Password", "ThunderRT6CommandButton3") ControlClick("Server Based", "Reset Password", "ThunderRT6CommandButton3") EndFunc Func TransLogin() ControlFocus("Login", "Reset Password", "ThunderRT6TextBox1") ControlSend("Login", "Reset Password", "ThunderRT6TextBox1", $user) ControlFocus("Login", "Reset Password", "ThunderRT6TextBox2") ControlSend("Login", "Reset Password", "ThunderRT6TextBox2", $pass) ControlFocus("Login", "Reset Password", "ThunderRT6CommandButton3") ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") WinWaitClose("Login", "Reset Password") EndFunc Func Quit() Exit EndFunc Link to comment Share on other sites More sharing options...
anyday Posted March 17, 2008 Author Share Posted March 17, 2008 (edited) thanks for the code and help, doesnt seem to work though, not sure what the prob is, the "Login" screen pops up and nothing happens and whats really weird is if i change out $LogonArray[0][0] with "Login" it executes the TransLogin function. Dim $LogonArray[2][3] $LogonArray[0][0] = "Login" ; Window Title $LogonArray[0][1] = "Reset Password" ; Window Text $LogonArray[0][2] = "Login" ; Function to call for this window $LogonArray[1][0] = "Login" ; Window Title $LogonArray[1][1] = "Reset Password" ; Window Text $LogonArray[0][2] = "TransLogin" ; Function to call for this window HotKeySet("^!x", "Quit"); Ctrl+Alt+X While 1 For $i = 0 To UBound($LogonArray)-1 If WinExists($LogonArray[$i][0], $LogonArray[$i][1]) Then Call($LogonArray[$i][2]) EndIf Next Sleep (1000) WEnd Func Login() ControlSend("Server Based", "Reset Password", "ThunderRT6TextBox4", $user) ControlSend("Server Based", "Reset Password", "ThunderRT6TextBox3", $pass) ControlFocus("Server Based", "Reset Password", "ThunderRT6CommandButton3") ControlClick("Server Based", "Reset Password", "ThunderRT6CommandButton3") EndFunc Func TransLogin() ControlFocus("Login", "Reset Password", "ThunderRT6TextBox1") ControlSend("Login", "Reset Password", "ThunderRT6TextBox1", $user) ControlFocus("Login", "Reset Password", "ThunderRT6TextBox2") ControlSend("Login", "Reset Password", "ThunderRT6TextBox2", $pass) ControlFocus("Login", "Reset Password", "ThunderRT6CommandButton3") ControlClick("Login", "Reset Password", "ThunderRT6CommandButton3") WinWaitClose("Login", "Reset Password") EndFunc Edited March 17, 2008 by anyday Link to comment Share on other sites More sharing options...
anyday Posted March 17, 2008 Author Share Posted March 17, 2008 ahh that work's good, there was a typo in your post Dim $LogonArray[2][3] $LogonArray[0][0] = "Server Based Rating Logon" ; Window Title $LogonArray[0][1] = "Reset Password" ; Window Text $LogonArray[0][2] = "Login" ; Function to call for this window $LogonArray[1][0] = "Login" ; Window Title $LogonArray[1][1] = "Reset Password" ; Window Text $LogonArray[0][2] = "TransLogin" ; Function to call for this window $LogonArray[1][0] = "Login" ; Window Title $LogonArray[1][1] = "Reset Password" ; Window Text $LogonArray[0][2] = "TransLogin" ; Function to call for this window it was calling the same function $LogonArray[0][2] thanks alot for the help! Link to comment Share on other sites More sharing options...
FreeFry Posted March 17, 2008 Share Posted March 17, 2008 (edited) Edit:Oh, nice find. xDGood it works. Edited March 17, 2008 by FreeFry Link to comment Share on other sites More sharing options...
anyday Posted March 17, 2008 Author Share Posted March 17, 2008 ok, next question, any way to make the script restart itself so mem usage does not get to high? i can do it by just an exit then a run of the exe but prob not the best way? Link to comment Share on other sites More sharing options...
FreeFry Posted March 17, 2008 Share Posted March 17, 2008 I don't think is any need to restart it, it shouldn't use that much memory in any case.. Link to comment Share on other sites More sharing options...
Subi Posted March 18, 2008 Share Posted March 18, 2008 write an another script to restart it (Close the existing one and restart it). simple... Link to comment Share on other sites More sharing options...
FreeFry Posted March 18, 2008 Share Posted March 18, 2008 And pointless. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now