Roebie Posted September 5, 2008 Posted September 5, 2008 Hi, I'm very new to AutoIt: I've just started my first script. I want my script to open an application (Axapta) and that works. On opening Axapta shows a login window. The script sends login and password. This also works (or at least it seems to). Then the script clicks to Logon button. This also works as Axapta replies. It's the reply that troubles me. Axapta says the password is wrong, which I doubt. If I copy it from the script and paste it into the password textbox, Axapta does accept it. I've gone through both the manual and lots of topics on passwords in this subforum, but to no avail. Could anyone help me out on what I'm doing wrong, please? My code so far: Dim $filename Dim $params Dim $error $filename = "C:\Program Files\Navision\Axapta Client 3SP4\Bin\ax32.exe" $params = "\\leuven1\data\apps\axaptacl\iconen\2T\dolmen\Axapta_Dolmen_ENG_2T_new.axc" Run($filename & " " & $params) Sleep(3000) AutoItSetOption("WinTitleMatchMode", 4) $handle = WinGetHandle("classname=AxaptaClientClassName") If $error Then MsgBox(4096, "Error", "Could not find the correct window") Exit EndIf WinWaitActive($handle) ControlSend($handle, "", "Edit1", "mylogin") ControlSend($handle, "", "Edit2", "mypassword") ControlClick($handle, "", "Button1") Thanks very much in advance.
martin Posted September 5, 2008 Posted September 5, 2008 Hi, I'm very new to AutoIt: I've just started my first script. I want my script to open an application (Axapta) and that works. On opening Axapta shows a login window. The script sends login and password. This also works (or at least it seems to). Then the script clicks to Logon button. This also works as Axapta replies. It's the reply that troubles me. Axapta says the password is wrong, which I doubt. If I copy it from the script and paste it into the password textbox, Axapta does accept it. I've gone through both the manual and lots of topics on passwords in this subforum, but to no avail. Could anyone help me out on what I'm doing wrong, please? My code so far: Dim $filename Dim $params Dim $error $filename = "C:\Program Files\Navision\Axapta Client 3SP4\Bin\ax32.exe" $params = "\\leuven1\data\apps\axaptacl\iconen\2T\dolmen\Axapta_Dolmen_ENG_2T_new.axc" Run($filename & " " & $params) Sleep(3000) AutoItSetOption("WinTitleMatchMode", 4) $handle = WinGetHandle("classname=AxaptaClientClassName") If $error Then MsgBox(4096, "Error", "Could not find the correct window") Exit EndIf WinWaitActive($handle) ControlSend($handle, "", "Edit1", "mylogin") ControlSend($handle, "", "Edit2", "mypassword") ControlClick($handle, "", "Button1") Thanks very much in advance.I don't know, but your script is not quite right. $error is not ever going to be true; you need to remove the declaration and instead use @error. (See the help for WinGetHandle) Is the title of the window actually "classname=AxaptaClientClassName"? Or are you intending to have "[CLASS:AxaptaClientClassName]"? But presumably you have got that correct if the login name is entered ok. Maybe the password has special characters in it which are interpreted by ControlSend, (assuming that "mypassword" is not what you actually use.) in which case you need ControlSend($handle,"","Edit2","my+password",1) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Roebie Posted September 5, 2008 Author Posted September 5, 2008 Hi Martin, I don't know, but your script is not quite right. $error is not ever going to be true; you need to remove the declaration and instead use @error. (See the help for WinGetHandle)You're right of course about $error being wrong. Is the title of the window actually "classname=AxaptaClientClassName"? Or are you intending to have "[CLASS:AxaptaClientClassName]"? But presumably you have got that correct if the login name is entered ok.No, the title is not "classname=AxaptaClientClassName". According to the example in the help for WinGetHandle this code is correct. After reading "Windows Titles and Text (Advanced)" in the help (see the link Title special definition in the help for WinGetHandle), I suppose my way of writing it is deprecated. I should probably use Dim $filename Dim $params $filename = "C:\Program Files\Navision\Axapta Client 3SP4\Bin\ax32.exe" $params = "\\leuven1\data\apps\axaptacl\iconen\2T\dolmen\Axapta_Dolmen_ENG_2T_new.axc" Run($filename & " " & $params) Sleep(3000) $handle = WinGetHandle("[CLASS:AxaptaClientClassName]") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Exit EndIf WinWaitActive($handle) ControlSend($handle, "", "Edit1", "mylogin") ControlSend($handle, "", "Edit2", "mypassword") ControlClick($handle, "", "Button1") Maybe the password has special characters in it which are interpreted by ControlSend, (assuming that "mypassword" is not what you actually use.) in which case you need ControlSend($handle,"","Edit2","my+password",1)LOL, it's not "mypassword". But as in "mypassword" it does not contain any special characters, only the range [a-zA-Z0-9]. I've tried the 1 flag anyway, but that didn't help. I also tried a suggestion made by the help on ControlSend to give focus to my Edit2 control first and that helped. So the code looks like this now: ... WinWaitActive($handle) ControlSend($handle, "", "Edit1", "mylogin") ControlFocus($handle, "", "Edit2") ControlSend($handle, "", "Edit2", "mypassword") ControlClick($handle, "", "Button1") Thanks for you suggestions. They put me on the right track.
Roebie Posted September 5, 2008 Author Posted September 5, 2008 (edited) In case anyone has use for this, I made the code even shorter. This works too: Dim $filename Dim $params $filename = "C:\Program Files\Navision\Axapta Client 3SP4\Bin\ax32.exe" $params = "\\leuven1\data\apps\axaptacl\iconen\2T\dolmen\Axapta_Dolmen_ENG_2T_new.axc" Run($filename & " " & $params) WinWaitActive("[CLASS:AxaptaClientClassName]") ControlSend("[LAST]", "", "Edit1", "mylogin") ControlFocus("[LAST]", "", "Edit2") ControlSend("[LAST]", "", "Edit2", "mypassword") ControlClick("[LAST]", "", "Button1") Edited September 5, 2008 by Roebie
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