WladyslawMotyka Posted July 11, 2014 Share Posted July 11, 2014 Hi folks, I need help with connecting to SAPGUI using Lua. I saw that you folks have scripts for connecting and automation of SAP gui. I try to use Lua and its LuaCOM but it did not work for me. Have anybody ever try it? My script bellow always fail on this call application:Children(0) and LuaCOM crash. I don't know what am I doing wrong. Could anybody help me with this? I would be grateful. expandcollapse popup-- If Not IsObject(application) Then -- Set SapGuiAuto = GetObject("SAPGUI") -- Set application = SapGuiAuto.GetScriptingEngine -- End If -- If Not IsObject(connection) Then -- Set connection = application.Children(0) -- End If -- If Not IsObject(session) Then -- Set session = connection.Children(0) -- End If -- If IsObject(WScript) Then -- WScript.ConnectObject session, "on" -- WScript.ConnectObject application, "on" -- End If -- session.findById("wnd[0]").maximize -- session.findById("wnd[0]").restore -- session.findById("wnd[0]").resizeWorkingPane 98,17,false -- session.findById("wnd[0]/tbar[0]/okcd").text = "12" -- session.findById("wnd[0]/tbar[0]/okcd").text = "3" function help(t) for k,v in pairs(t) do print(k,v) end end require("luacom") -- luacom.config.abort_on_API_error = true -- luacom.config.abort_on_error = false print("SapGuiAuto") local Wrp = luacom.CreateObject ("SapROTWr.SapROTWrapper") local SapGuiAuto = Wrp:GetROTEntry ("SAPGUI") --local SapGuiAuto = luacom.GetObject("SAPGUI") if not SapGuiAuto then error("SapGuiAuto missing") else help(SapGuiAuto) end print() print("application") local application = SapGuiAuto:GetScriptingEngine() if not application then error("application failed") else help(application) end print() print("connection") local connection = application:Children(0) if not connection then error("connection failed") else help(connection) end print() print("session") local session = connection:Children(0) if not session then error("session failed") else help(session)end print() -- WScript.ConnectObject session, "on" -- WScript.ConnectObject application, "on" -- session.findById("wnd[0]").maximize print("working") c:\UserParameterSetter>lua.exe SAPconnect.lua SapGuiAuto _USERDATA_REF_ userdata: 01F03828 application _USERDATA_REF_ userdata: 01F03878 connection wm Link to comment Share on other sites More sharing options...
water Posted July 11, 2014 Share Posted July 11, 2014 Welcome to AutoIt and the forum! Why not use AutoIt as it works and LUA doesn't? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
WladyslawMotyka Posted July 14, 2014 Author Share Posted July 14, 2014 Hi, our entire project is based on Lua so ... I am choosing an easier way :-) Link to comment Share on other sites More sharing options...
water Posted July 14, 2014 Share Posted July 14, 2014 I'm not sure you will get a lot of help on this subject. SAPGUI automation using Autoit is not very widely used. And I don't know how many users of this forum do it with LUA. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
WladyslawMotyka Posted July 14, 2014 Author Share Posted July 14, 2014 :-( Ok, but stil, i will wait a little and try my luck with this forum :-) Link to comment Share on other sites More sharing options...
water Posted July 14, 2014 Share Posted July 14, 2014 Good luck My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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