AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SAP R/3 Scripting with AutoHotkey

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Andi



Joined: 11 Feb 2005
Posts: 173
Location: Germany

PostPosted: Sun Mar 08, 2009 10:51 am    Post subject: SAP R/3 Scripting with AutoHotkey Reply with quote

Hi,
I'm using AutoHotkey since several years at work, to automate processes with our SAP R/3 system.
This works very well, but I think it would be easier and more reliable to talk to the SAP GUI directly over the built in COM interface. When SAP GUI Scripting interface is enabled it's for example possible to read and write fields without using the Send ^c or Send ^v commands.

Has someone experience or examples how to automate the SAP GUI with ahk and the SAP Scripting Interface?

On the AutoIt3 forum Sean Griffin developed a way how to do this with AutoIt3:
http://www.autoitscript.com/forum/index.php?showtopic=86574&st=0

Exists perhaps a tool, that could help to translate AutoIt3 code to ahk?
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Mar 21, 2009 1:56 pm    Post subject: sapgui Reply with quote

Yes the SAPGUI windows seem very difficult to script.
* All sap easy access screens have the same title - and i always have lots of them open.
* there is no hidden text to identify the SAP server SID
* even WMI for messages posts seems to be deviating from lots of other applications

If i could understand the autoit stuff or someone could bring it to AHK i would be very happy!
Back to top
Guest






PostPosted: Sat Mar 21, 2009 2:22 pm    Post subject: require Reply with quote

next to AutoIt v3...
* AutoItX - DLL/COM control. Add AutoIt features to your favorite programming and scripting languages!
* #include <SAP.au3>
Back to top
Guest






PostPosted: Sat Mar 21, 2009 11:37 pm    Post subject: COM object functions Reply with quote

I seem to have found what i was looking for:
http://www.autohotkey.com/forum/topic22923.html&highlight=com+object

The SAP.au3 include does not seem so complex. I even found some stupid assuptions and items for improvement Razz. Will try and reproduce what i need in AHK - if i find the time.
Back to top
Non-SAP-Fan
Guest





PostPosted: Wed Mar 25, 2009 5:24 pm    Post subject: Reply with quote

Hi Andi,

I use SAP for some basic stuff here at work - it falls on me to do things like manually update two thousand prices when they haven't bothered buying the ability to do an upload.

I'd love to automate the process with Autohotkey, you seem to be lightyears ahead of me in this regard - all this talk about COMs and hidden text - it's beyond me - I'm stumped at something quite simple: SAP seems to have different window titles depending on what product you have open at any one time - is there any work around for this?

In other words how to I tell AHK that just because the window title has changed to "Maintain range 4871 - blahblahblah - \\Remote" it doesn't mean it's not the same window as when it was "Maintain range 1271 - dadada - \\Remote"" if that makes sense.

Many thanks and good luck with all your SAP stuff. I've got to say, even the calming water drop has got old at this point...

Jack
Back to top
Andi



Joined: 11 Feb 2005
Posts: 173
Location: Germany

PostPosted: Fri Apr 10, 2009 9:00 pm    Post subject: Reply with quote

Thank you, for your replies. I also think, that it would be valuable to get in hand with COM...

@Non-SAP-Fan,
you may try to solve this problem in making use of the command SetTitleMatchMode, 2. Take a look in ahk's Helpfile: Parameter 2 means:
Quote:
A window's title can contain WinTitle anywhere inside it to be a match.

When you define this in the auto-execute section of your script, every thread (hotkey, hotstring...) applies this default value.
Now you can handle the different windows, when you just look for the part, that does not change.

For example:
Code:

SetTitleMatchMode, 2
return  ;End of the auto-execute section

#z:: ;Your SAP-Hotkey
IfWinActive, Maintain range

   do something...
}
return
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Fri Apr 10, 2009 9:34 pm    Post subject: Reply with quote

Non-SAP-fan wrote:
In other words how to I tell AHK that just because the window title has changed to "Maintain range 4871 - blahblahblah - \\Remote" it doesn't mean it's not the same window as when it was "Maintain range 1271 - dadada - \\Remote"" if that makes sense.


I don't use SAP but I work through a Citrix client daily with the same limitations. The key (for me anyway) is to use SetTitleMatchMode, RegEx and assign the windows to groups once you've found a title that RegEx matches. For example, in your particular case this should match any of the windows with that name:

Code:
Maintain range \d{4} - .* - \\\\Remote


It's a bit more difficult to read but, if done correctly, you won't have to mess with it again. See the RegEx Quick Reference for more information.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
Jinan



Joined: 08 Mar 2010
Posts: 11

PostPosted: Fri Mar 19, 2010 7:02 am    Post subject: Reply with quote

I have search this information for several weeks. I think these are helpfully. Ths!
Back to top
View user's profile Send private message
rani



Joined: 18 Mar 2008
Posts: 192

PostPosted: Sat Apr 02, 2011 12:53 pm    Post subject: SAP GUI windows controls get/set values Reply with quote

Hi Andi,

SAP GUI window 'controls'
1.
can you 'see' with AHK GetControl the controls of SAP and get it's values(text) ?
2.
do you have to change to SAP 'scripting enabled' or just immedietly
you can get/set SAP window controls ?
Back to top
View user's profile Send private message
rhysd17
Guest





PostPosted: Wed Aug 17, 2011 7:48 pm    Post subject: SAP window won't allow Tab in conjunction with other hotkeys Reply with quote

I've been succesfully scripting using AHK in SAP for a while now with fairly good success. The biggest down side is I have to introduce an enormous amount of sleeps or the script gets ahead of SAPs inputs and SAP won't cache input commands. I have had good success with SetTitleMatchMode, 1 so that it only matches the beginning of windows titles.

Currently though I am trying to script a very basic input using shift+tab and no matter what I do the window won't accept any hotkey combinations that include tab. if I introduce a long pause I can even manual conduct the input during the sleep successfully. I can use other shift commands fine and other tab commands fine in the same window. I have other scripts that use shift-tab without trouble in the system as well. Why won't this window recognize shift+tab from a script?

Here's a portion of my code


Code:
WinWait, Change ,
IfWinNotActive, Change , , WinActivate, Change ,
WinWaitActive, Change ,
Send, {TAB 5}
Sleep, 200
Send, {DOWN 8}
Sleep, 200
Send, {F2}
Sleep, 200
Send, +{TAB}
Sleep, 5000
Send, {Space}
Send, repair_text.txt
Sleep, 500
Back to top
stonedcarrot



Joined: 02 Nov 2011
Posts: 2
Location: Northern ireland

PostPosted: Wed Nov 02, 2011 12:14 pm    Post subject: Re: SAP window won't allow Tab in conjunction with other hot Reply with quote

rhysd17 wrote:
I've been succesfully scripting using AHK in SAP for a while now with fairly good success. The biggest down side is I have to introduce an enormous amount of sleeps or the script gets ahead of SAPs inputs and SAP won't cache input commands. I have had good success with SetTitleMatchMode, 1 so that it only matches the beginning of windows titles.

Currently though I am trying to script a very basic input using shift+tab and no matter what I do the window won't accept any hotkey combinations that include tab. if I introduce a long pause I can even manual conduct the input during the sleep successfully. I can use other shift commands fine and other tab commands fine in the same window. I have other scripts that use shift-tab without trouble in the system as well. Why won't this window recognize shift+tab from a script?

Here's a portion of my code


Code:
WinWait, Change ,
IfWinNotActive, Change , , WinActivate, Change ,
WinWaitActive, Change ,
Send, {TAB 5}
Sleep, 200
Send, {DOWN 8}
Sleep, 200
Send, {F2}
Sleep, 200
Send, +{TAB}
Sleep, 5000
Send, {Space}
Send, repair_text.txt
Sleep, 500




Just a thought but have you tried -

{SHIFTDOWN}{TAB}{SHIFTUP}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group