In the function I switch from one database to another, by either using the combination !m{enter 2}{down}{enter}{up}
or !m{enter 3}. I'm putting this combination into a SEQ (sequence) parameter, and then use
Send, %SEQ% to execute the keys.
It works perfectly, but I could imagine there could be situation when the load on the processor is
a little high(er), it might be saver to put a sleep in between these keys.
How could I go about this ?
Function:
Code: Select all
SwitchDatabase(wintitle, fKey, BGR, BGR2, DB1, DB2, SEQ) ; window title, function key, color to match, other valid color, database 1, database 2, sequence
{
WinWait, %wintitle%, , 1
if errorlevel
{
MsGbox, SAP is niet gestart. Start SAP op !
WinWait, %wintitle%
}
else
{
Loop
{
WinActivate, %wintitle%
WinMaximize, %wintitle%
PixelGetColor, SearchColor, 431, 141
if (SearchColor = BGR)
{
WinActivate, %wintitle%
break
}
if (SearchColor = BGR2)
{
MsgBox, 4096, FOUT, Dit is de %DB2% database !
Send, %SEQ%
WinWaitNotActive, %wintitle%
WinActivate, %wintitle%
Sleep, 100
continue
}
else
{
Send, {%fKey%}
Sleep, 2000
continue
}
}
}
}
Code: Select all
Script1:
SwitchDatabase("SAP Business One", "F11","0xF7F7F7", "0xDEFBFF","SRT","TSI", "!m{enter 2}{down}{enter}{up}")
Loop
{
IfWinNotExist, SRT Cloud afmelden.ahk
run, %PathToScript1%
Sleep, 500
break
}
SendLevel,1
Send, {LWin down}{a down}
Send, {LWin up}{a up}
return
Script2:
SwitchDatabase("SAP Business One", "F11","0xDEFBFF","0xF7F7F7","TSI","SRT", "!m{enter 3}")
Loop
{
IfWinNotExist, TSI Cloud afmelden.ahk
run, %PathToScript2%
Sleep, 500
break
}
SendLevel,1
Send, {LWin down}{t down}
Send, {LWin up}{t up}
return