AutoHotkey Community

It is currently May 27th, 2012, 6:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: March 8th, 2009, 11:51 am 
Offline

Joined: February 11th, 2005, 6:31 am
Posts: 174
Location: Germany
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: sapgui
PostPosted: March 21st, 2009, 2:56 pm 
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!


Report this post
Top
  
Reply with quote  
 Post subject: require
PostPosted: March 21st, 2009, 3:22 pm 
next to AutoIt v3...
* AutoItX - DLL/COM control. Add AutoIt features to your favorite programming and scripting languages!
* #include <SAP.au3>


Report this post
Top
  
Reply with quote  
 Post subject: COM object functions
PostPosted: March 22nd, 2009, 12:37 am 
I seem to have found what i was looking for:
http://www.autohotkey.com/forum/topic22 ... com+object

The SAP.au3 include does not seem so complex. I even found some stupid assuptions and items for improvement :P. Will try and reproduce what i need in AHK - if i find the time.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2009, 6:24 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2009, 10:00 pm 
Offline

Joined: February 11th, 2005, 6:31 am
Posts: 174
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2009, 10:34 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
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.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 8:02 am 
Offline

Joined: March 8th, 2010, 3:55 pm
Posts: 11
I have search this information for several weeks. I think these are helpfully. Ths!


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 2nd, 2011, 1:53 pm 
Offline

Joined: March 18th, 2008, 4:04 am
Posts: 193
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 ?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 17th, 2011, 8:48 pm 
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


Report this post
Top
  
Reply with quote  
PostPosted: November 2nd, 2011, 1:14 pm 
Offline

Joined: November 2nd, 2011, 1:11 pm
Posts: 2
Location: Northern ireland
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}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, Bing [Bot], Exabot [Bot], JSLover and 62 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group