Created a script in SAP and can run it via a macro in excel. This is the code that runs it in Excel Macro. Shell "WScript ""C:\FVFR\Script2.vbs""" This is the actual script,
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]/tbar[1]/btn[21]").press
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI- SELFLAG[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxt/SIE/SMS_DXCAUSE-ISSUE_TYPE").setFocus
session.findById("wnd[1]/usr/ctxt/SIE/SMS_DXCAUSE-ISSUE_TYPE").caretPosition = 0
session.findById("wnd[1]").sendVKey 4
session.findById("wnd[2]/usr/lbl[1,4]").setFocus
session.findById("wnd[2]/usr/lbl[1,4]").caretPosition = 2
session.findById("wnd[2]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[5]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/cntlEDIT_MELD/shellcont/shell").setSelectionIndexes 0,26
session.findById("wnd[0]/usr/cntlTASK_LONG_TEXT/shellcont/shell").setSelectionIndexes 0,26
I want to be able to use this macro in AHK and I have tried Run, Shell "WScript ""C:\FVFR\Script2.vbs""" or just Run, C:\FVFR\Script2.vbs but it will not work at all or it just opens the script code. Would like it if when I press ^!g:: then the SAP marco would run. Not very savy with AHK so require assistance.
UPDATE Was able to get to work with, Run, WScript.exe "C:\FVFR\Script2.vbs"