effer Posted December 6, 2005 Share Posted December 6, 2005 Hi I've created a macro with AutoIt 3 which types in your username and password for the intranet on my work. My work has 18 different servers which the intranet is located on, and i've noticed that the macro not always works because of slightly different setups on the servers. My macro works like this: - check if the name of the intranet login window is active - When it is active, enter username and password The problem is that the title of the login windows differs on some of the servers.. My macro looks like this (the important part): $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) WinWaitActive("Opret forbindelse til BMKC01") WinActivate("Opret forbindelse til BMKC01") Send($user) Send("{TAB}") Send($kode) Send("{ENTER}") WEnd My question is: How do i make my while loop so I can check for more than one window name? Hope you can figure it out, then I will be very happy /Effer Link to comment Share on other sites More sharing options...
rambo3889 Posted December 6, 2005 Share Posted December 6, 2005 i cant find a solution but i know you are a dansker My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youre the best in town Fight! Link to comment Share on other sites More sharing options...
effer Posted December 6, 2005 Author Share Posted December 6, 2005 i cant find a solution but i know you are a dansker Busted ! I've just noticed an error in my script (because i tried to translate it into english before getting help, and I missed a translation): The script should look like this: $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) WinWaitActive("Opret forbindelse til BMKC01") WinActivate("Opret forbindelse til BMKC01") Send($user) Send("{TAB}") Send($pass) Send("{ENTER}") WEnd Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 6, 2005 Share Posted December 6, 2005 is there any part in the windowtitle that stays the same this part is not supposed to be in any other wintitle Opt("WinTitleMatchMode", 2) if winexists("forbindelse", "") then winactivate("forbindelse", "") send ($user&"{tab}"&$kode&"{enter}") endif hope this helps you my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 6, 2005 Share Posted December 6, 2005 you can even do controlsend i think just look for the controlid's of the window your looking for (autoitwindowinfo) could be a bit faster my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
JerryD Posted December 6, 2005 Share Posted December 6, 2005 Unless all the windows are identical except how they behave (UGG!), you might try something like this: $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) If WinExists ("Opret forbindelse til BMKC01") then WinActivate("Opret forbindelse til BMKC01") Send($user) Send("{TAB}") Send($kode) Send("{ENTER}") ElseIf WinExists ( "Second Window Title", "Second Window Text" ) WinActivate ( "Second Window Title", "Second Window Text" ) Send($user) Send("{TAB}{TAB}") Send($kode) Send("{ENTER}") ElseIf WinExists ( "Third Window Title", "Third Window Text" ) WinActivate ( "Third Window Title", "Third Window Text" ) Send($user) Send("{TAB}{TAB}{TAB}") Send($kode) Send("{ENTER}") Endif WEnd Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 6, 2005 Share Posted December 6, 2005 to update jerryd's idea $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) $a = WinExists ("Opret forbindelse til BMKC01") then $b = WinExists ( "Second Window Title", "Second Window Text" ) $c = WinExists ( "Third Window Title", "Third Window Text" ) if $a = 1 or $b = 1 or $c = 1 then select case $a = 1 WinActivate ( $a) send ($user&"{tab}"&$kode&"{enter}") case $b = 1 winactivate ($b) send ($user&"{tab}"&$kode&"{enter}") case $c = 1 winactivate ($c) send ($user&"{tab}"&$kode&"{enter}") endselect Endif WEnd to make it a bit cleaner $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) $a = WinExists ("Opret forbindelse til BMKC01") then $b = WinExists ( "Second Window Title", "Second Window Text" ) $c = WinExists ( "Third Window Title", "Third Window Text" ) select case $a = 1 typeme($a) case $b = 1 typeme($b) case $c = 1 typeme($c) endselect WEnd func typeme($window) winactivate ($window) send ($user&"{tab}"&$kode&"{enter}") endfunc this should do the job (for title with not a part of similar string) the other version is in my first post my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
effer Posted December 6, 2005 Author Share Posted December 6, 2005 Unless all the windows are identical except how they behave (UGG!), you might try something like this: $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) If WinExists ("Opret forbindelse til BMKC01") then WinActivate("Opret forbindelse til BMKC01") Send($user) Send("{TAB}") Send($kode) Send("{ENTER}") ElseIf WinExists ( "Second Window Title", "Second Window Text" ) WinActivate ( "Second Window Title", "Second Window Text" ) Send($user) Send("{TAB}{TAB}") Send($kode) Send("{ENTER}") ElseIf WinExists ( "Third Window Title", "Third Window Text" ) WinActivate ( "Third Window Title", "Third Window Text" ) Send($user) Send("{TAB}{TAB}{TAB}") Send($kode) Send("{ENTER}") Endif WEnd This is what i tried ealier too, but i couldn't get it to work. But i've tried your code, and it works like a charm now , don't know what I did wrong. So I guess I'm done... for now. I might have some questions later, because I'm planing to add more functions. But thanks for your help guys Link to comment Share on other sites More sharing options...
effer Posted December 6, 2005 Author Share Posted December 6, 2005 to update jerryd's idea $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) $a = WinExists ("Opret forbindelse til BMKC01") then $b = WinExists ( "Second Window Title", "Second Window Text" ) $c = WinExists ( "Third Window Title", "Third Window Text" ) if $a = 1 or $b = 1 or $c = 1 then select case $a = 1 WinActivate ( $a) send ($user&"{tab}"&$kode&"{enter}") case $b = 1 winactivate ($b) send ($user&"{tab}"&$kode&"{enter}") case $c = 1 winactivate ($c) send ($user&"{tab}"&$kode&"{enter}") endselect Endif WEnd to make it a bit cleaner $user = InputBox("BMnet Login", "enter username\") $pass = InputBox("BMnet Login", "enter password","","*") While(1) $a = WinExists ("Opret forbindelse til BMKC01") then $b = WinExists ( "Second Window Title", "Second Window Text" ) $c = WinExists ( "Third Window Title", "Third Window Text" ) select case $a = 1 typeme($a) case $b = 1 typeme($b) case $c = 1 typeme($c) endselect WEnd func typeme($window) winactivate ($window) send ($user&"{tab}"&$kode&"{enter}") endfunc this should do the job (for title with not a part of similar string) the other version is in my first post I'll try your code later on too. The simpler, the better 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