Jump to content

Running a Macro within a ShellExecute


Recommended Posts

I am currently creating a automation daily logon script. Basically, this will open all of my necessary applications, run a report and then close a window. However, I am having issues running a macro, (.rma) within a previously opened shell command.

I need to open all applicable windows first, WinActive my primary macro window, run the macro, (macro runs, waits 10 seconds for me to type in my name and select file, then continues, opens Excel pastes info in), after macro it will then close the primary macro window and continue on it's way starting the rest of the programs. So any help would be much appreciated, thanks!

So with that said, this is what I have so far,

ShellExecute("F:\RIBM32\wa-mod5.rsf")

sleep(1000)

ShellExecute("F:\RIBM32\wa-mod4.rsf")

sleep(500)

ShellExecute("F:\RIBM32\wa-mod4.rsf")

sleep(500)

ShellExecute("F:\RIBM32\wa-mod4.rsf")

sleep(500)

ShellExecute("F:\RIBM32\wa-mod4.rsf")

sleep(1000)

ShellExecute("F:\RIBM32\wa-mod2.rsf")

sleep(2000)

WinActivate("wa-mod5.rsf");Mod-5 Window becomes active

MouseClick("left", 568, 80, 1, 1) ; Click the Login button on Mod-5

Sleep(3000)

MouseClick("left", 678, 82, 1, 1) ;Click the Aging macro button on the Mod-5

WinActivate("wa-mod5.rsf")

Sleep(2000)

Send("jeff")

Send("{ENTER}")

sleep(1000)

Send("{TAB 3}")

Send("s")

Send("{ENTER}")

sleep(10000)

WinWaitActive("Microsoft Excel")

MouseClick("left", 313, 263, 1, 1) ;Clicks the "Paste aging button"

WinSetState("Microsoft Excel", "", @SW_RESTORE)

Sleep(1000)

ShellExecuteWait("F:\Data\Production Tracking\Coordinator 2010 Production Sheet.xlsx")

Sleep(500)

ShellExecuteWait("F:\Production Sheet\DOL Timeliness Tracking TEMPLATE.xlsx")

Sleep(500)

ShellExecuteWait("F:\Data\Production Tracking\Time Tracker 2010.xlsx")

Sleep(500)

MouseClick("left", 138,11 ,1 ,1) ;Clicks Radar in the quick launch

Sleep(5000)

$sametime= ProcessExists("SametimeW80.exe")

If $sametime=0 Then

RunWait("C:\Program Files\IBM\Lotus\Sametime Connect\rcp\rcplauncher.exe")

ElseIf $sametime>1 Then

SplashTextOn("Sametime","Sametime already running", 500, 50)

EndIf

Run("C:\Program Files\IBM\Lotus\Notes\notes.exe")

WinWaitActive("Lotus Notes")

Send("PASSWORD ENTERED {Enter}")

Link to comment
Share on other sites

ShellExecute("F:\RIBM32\wa-mod5.rsf")
sleep(1000)

ShellExecute("F:\RIBM32\wa-mod4.rsf")
sleep(500)
ShellExecute("F:\RIBM32\wa-mod4.rsf")
sleep(500)
ShellExecute("F:\RIBM32\wa-mod4.rsf")
sleep(500)
ShellExecute("F:\RIBM32\wa-mod4.rsf")
sleep(1000)
ShellExecute("F:\RIBM32\wa-mod2.rsf")
sleep(2000)

WinActivate("wa-mod5.rsf");Mod-5 Window becomes active

MouseClick("left", 568, 80, 1, 1) ; Click the Login button on Mod-5
Sleep(3000)

MouseClick("left", 678, 82, 1, 1) ;Click the Aging macro button on the Mod-5


WinActivate("wa-mod5.rsf")

Sleep(2000)
Send("jeff")
Send("{ENTER}")
sleep(1000)
Send("{TAB 3}")
Send("s")
Send("{ENTER}")
sleep(10000)
WinWaitActive("Microsoft Excel")
MouseClick("left", 313, 263, 1, 1) ;Clicks the "Paste aging button"

WinSetState("Microsoft Excel", "", @SW_RESTORE)


Sleep(1000)

ShellExecuteWait("F:\Data\Production Tracking\Coordinator 2010 Production Sheet.xlsx")
Sleep(500)
ShellExecuteWait("F:\Production Sheet\DOL Timeliness Tracking TEMPLATE.xlsx")
Sleep(500)
ShellExecuteWait("F:\Data\Production Tracking\Time Tracker 2010.xlsx")
Sleep(500)


MouseClick("left", 138,11 ,1 ,1) ;Clicks Radar in the quick launch 
Sleep(5000)

$sametime= ProcessExists("SametimeW80.exe") 
            
            
If $sametime=0 Then
    RunWait("C:\Program Files\IBM\Lotus\Sametime Connect\rcp\rcplauncher.exe")
ElseIf $sametime>1 Then
    SplashTextOn("Sametime","Sametime already running", 500, 50)
EndIf
    

Run("C:\Program Files\IBM\Lotus\Notes\notes.exe")
WinWaitActive("Lotus Notes")

Send("PASSWORD ENTERED {Enter}")

Please add '

' tags, it makes it much easier on the eyes [img]http://www.autoitscript.com/forum/public/style_emoticons/autoit/geek.gif[/img]

I can't really see any obvious errors, so without more info there's not much I can tell you. Where is it not doing what you want? How is it not doing what you want?

The only advice I can give is that you might want to put a WinWaitActive after your WinActivate calls, to give the macro time to appear. Once in a great while, I encounter an application that is stubborn about not showing up so I'll beat it over the head with this snippet of code:[code]Local $targetApp = "someApp"
Local $counter = 0
Do
    WinActivate ($targetApp)
    $counter += 1
    Sleep (20)
Until WinActive ($targetApp) or $counter = 100
    
If $counter = 100 Then
    ErrorBox ($targetApp & " Window Timed Out on Activate")
    Return
EndIf

But that's not very often and it's a rather ugly little bit of code, so avoid it if you can. :/

Edit: English is not my friend today :(

Edited by Fulano

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...