Sign in to follow this  
Followers 0
cpezie

Auto Refresh for Service Center 6.1.5

15 posts in this topic

#1 ·  Posted (edited)

Hey All,

I've been tasked with the job of using AutoIT to automatically refresh Peregrine Service Center every 10 minutes. We are running Service Center 6.1.5.0 build 0025. I was looking at an old post from 2007 were someone was using AutoIT to auto refresh SC version 5.1. Since I'm pretty much clues as to how this works your help would be greatly appreciated.

Thanks,

Here's the code from the 2007 post.

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.8.1

Author: Allen

Date: 10/3/2007

Purpose: Cause the Peregrine application to refresh every 10 minutes during the daytime

Script Function:

Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

MsgBox(64,"Peregrine Refresh Display","When Peregrine comes up, logon and it will select the proper display"" button",120)

; Bring up the logon display

run("C:\Program Files\Peregrine\ServiceCenter 5.1.5\RUN\scguiw32.exe","C:\Program Files\Peregrine\ServiceCenter 5.1.5\RUN" )

; Title of display will be: ServiceCenter 5.1.5 Express - [Login]

; Force focus on this display

WinActivate("ServiceCenter")

; set to advanced mode so it can use regular expressions.

Opt("WinTitleMatchMode", 4)

; after the person logs on and hits enter, wait for next display

; the display title will slightly different for each person: ServiceCenter 5.1.5 Express - [XZMRCP]

; so you have to wait for the title that doesn't have login

WinWaitActive("[REGEXPTITLE:ServiceCenter \d+\.\d*\.*\d* Express - \[(?!Login).*?\]]","",30)

; cause the display to select the incidents display

Send("{TAB 2}{ENTER}")

; now the display will have the title: Service Center 5.1.5 Express - [incidents in inbox: Incidents by Assignment Group]

; change the rest to Mode 2 - Matches any substring in the title

Opt("WinTitleMatchMode", 2)

; Wait for new display to come up

WinWaitActive("Incidents","",10)

; every 10 minutes send commands to cause the display to refresh

while 1

if @HOUR < 18 then ;quit after 6:00 pm

; make sure the "incidents" display is still running - no one has closed it

if WinActivate("Incidents")=1 then

; force the focus on this display

WinActivate("Incidents")

; commands to refresh the display

Send("!p")

Send("RR")

Send("{ENTER}")

Else

; close down if the application is no longer running

ExitLoop

endif

Else

; after 6:00 pm close the application and stop script

WinClose("Service Center 5.1.5 Express - [incidents in inbox: Incidents by Assignment Group]")

ExitLoop

EndIf

Sleep(600000) ;10 min

wend

MsgBox(1,"Finished","Peregrine is done",2)

Edited by cpezie

Share this post


Link to post
Share on other sites



Well, few things to remake this script is to find the title of "Peregrine Service Center" for the Win* functions. Also, the Regular Expression is probably not fitting your needs and Send('RR')? You need to collect a few hints to see how to trace the refresh routine. Use "AutoIt Window Info" to get these hints.

Share this post


Link to post
Share on other sites

Okay well I just started for scratch b/c that script seemed to have a lot more that what I needed.

I'm currently trying to set the controlclick code but receving a error:

Line 13 error

Error parsing function call.

ControlClick ( "ServiceCenter - Main Menu: username@abc.com - Peregrine ServiceCenter Client", "", 8455690 ^ERROR

I'm sure I didn't correctly form this string but I don't know how to correct it.

Here's what I have thus far:

>>>

;

; AutoIt Version: 3.0

; Language: English

; Platform: WinXP

; Author: CPezie

;

; Script Function:

; Counts to 5 using a "while" loop

Line 10>>> WinActive ( "ServiceCenter - Main Menu: username@abc.com - Peregrine ServiceCenter Client" )

; every 10 minutes send commands to cause the display to refresh

Line 13>>> ControlClick ( "ServiceCenter - Main Menu: username@abc.com - Peregrine ServiceCenter Client", "", 8455690 [, "" [, 1 [, 34 [, 7 ]]]] )

>>>

Thanks,

Share this post


Link to post
Share on other sites

So here's what I'm trying to accomplish.

I just need autoIT to auto press the "refresh" button every 10 mins. I want it to run until the Service Center application is terminated or pc shuts off.

I'm trying to use the ControlClick command but some of the fields aren't jiving.

Does anyone know how to make this happen?

thx

Share this post


Link to post
Share on other sites

Well it doesn't look like I'm going to get any help which is discouraging but I'm going to post an update anyhow.

I was able to correct the error I was receiving but now once the .exe runs it shuts down. My goal is the have the .exe run continuously until it no longer recognizes the presents of Service Center or the pc is shutdown.

Here's my code as it stands.

; AutoIt Version: 3.0

; Language: English

; Platform: WinXP

; Author: CPezie

;

; Script Function:

; Every 10 minutes send commands to cause the Service Center display to refresh.

ControlClick ( "ServiceCenter - Main Menu: username@abc.com - Peregrine ServiceCenter Client", "", "[iD:5571664]", "[x:35]", "[y:5]" )

;Sleeps for 10 mins and runs again

Sleep(600000)

Share this post


Link to post
Share on other sites

Here's my latest code. It runs but Service Center is still timing out.???? I used AutoIT v3 Window Info to find the info needed.

What am I missing to cause script not to recognize the SC window. Or is it the Sleep command that's not working?

; Every 10 minutes send command to cause the Service Center to refresh

ControlClick ( "ServiceCenter - Main Menu: username@abc.com - Peregrine ServiceCenter Client", "", "[CLASS:ToolbarWindow32; INSTANCE:13; Click:1; X:35; Y:5]" )

;Sleeps for 10 mins and runs again

While 1

Sleep(60000)

WEnd

;Finish

Thanks in advance

Share this post


Link to post
Share on other sites

...

Well it doesn't look like I'm going to get any help which is discouraging but I'm going to post an update anyhow. ...

Welcome to the forum.

Thanks for your patience and for not bumping your thread too often. About once a day is great.

Have you worked thru the tutorials, that might help you out faster that this thread.

AutoIt 1-2-3

http://www.autoitscript.com/forum/index.php?showtopic=21048

Learning To Script with AutoIt V3

http://www.autoitscript.com/forum/index.php?showtopic=84960

This part of your ControlClick line seems in error to me

"[CLASS:ToolbarWindow32; INSTANCE:13; Click:1; X:35; Y:5]"

If you are not using the full (free) version of SciTE4AutoIt3...

http://www.autoitscript.com/autoit3/scite/downloads.shtml

...please consider installing it.

It should give you prompts on how to complete that ControlClick line. When you see square brackets, that usually means that the parameter is optional.

You might try this:

ControlClick("ServiceCenter - Main Menu:", "", "[CLASS:ToolbarWindow32; INSTANCE:13]", "left", 35, 5)

or this

ControlClick("ServiceCenter - Main Menu:", "", "[CLASS:ToolbarWindow32; INSTANCE:13]")

This code should let you see if AutoIt is finding the control of interest to you.

WinActivate("ServiceCenter - Main Menu:")
WinWaitActive("ServiceCenter - Main Menu:")
$ret = ControlClick("ServiceCenter - Main Menu:", "", "[CLASS:ToolbarWindow32; INSTANCE:13]")
MsgBox(0, "$ret", $ret)
A return of zero means that it did not.

I shortened the title of the window for the forum posts, you can use the entire title if you wish. Also, I've activated the window because (like the help files says) that helps for some apps.

If you are still unable to get the script to work as desired, please post the entire contents of the AU3Info tool summary tab to let us see what AutoIt is seeing and then maybe we can write the line for you.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks for the reply and info.

I've worked thru the tutorials but didn't see info on the Control ID specifically the controlclick.

I've made sure that I'm using SciTE4AutoIt3.exe SciTE v1.77.

When I type controlclick in SciTe I receiving the caption which I thought I followed. ControlClick ("title", "text", controlID [, button [, clicks [, x [, y ]]]] )

Any ways I changed it to read as follows -

ControlClick ( "ServiceCenter - Main Menu:", "", "[CLASS:ToolbarWindow32; INSTANCE:13]", "Right", 35, 5) But it's still not refreshing the SC window b/c it's still timing out.

The reason I'm trying to specify the x and y axis is because the Class and Instance values cover two icons; the Collapse and Refresh.

Question: Why did you encapsulate the controlclick inside of $ret? I could not find any documentation on $ret.

Also with the code you supplied I do return a 1 so it does recognize the program but it still times out.

Heres the AU Window Info:

>>>> Window <<<<

Title: ServiceCenter - Main Menu: username@abc.com - Peregrine ServiceCenter Client

Class: SWT_Window0

Position: -4, -4

Size: 1288, 1002

Style: 0x97CF0000

ExStyle: 0x00100100

Handle: 0x002E037E

>>>> Control <<<<

Class: ToolbarWindow32

Instance: 13

ClassnameNN: ToolbarWindow3213

Advanced (Class): [CLASS:ToolbarWindow32; INSTANCE:13]

ID: 4719510

Text:

Position: 254, 25

Size: 46, 22

ControlClick Coords: 35, 5

Style: 0x5601AB45

ExStyle: 0x00100000

Handle: 0x00480396

>>>> Mouse <<<<

Position: 289, 76

Cursor ID: 2

Color: 0xFFFFFF

>>>> StatusBar <<<<

>>>> Visible Text <<<<

VA

Top

Incident Utilities

Maintenance

On Call

Change Utilities

Tools

>>>> Hidden Text <<<<

Releases

Edited by cpezie

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

AutoIt Window Info occasionally can't show or recognize the correct hierarchy of the controls. It'll show you for example that MSPaint's left toolbar ClassnameNN is "AfxControlBar42u3" but if you'll take a look using WinSpy you'll see that it's actually a parent control that must be the first parameter of ControlClick to successfully click it's sub items.

Take a look at this example: (Require WIN XP I believe)

Run('mspaint')
WinWaitActive('untitled')

Dim $hwnd = WinGetHandle('untitled')
Dim $hParent = ControlGetHandle($hwnd, '', 'AfxControlBar42u3')
Dim $hChild = ControlGetHandle($hParent, '', '[CLASS:AfxWnd42u]')
ControlClick('', '', $hChild, 'left', 1, 19, 114)

I'm not saying that AutoIt Window Info is not that great, the opposite is the truth, but that it's hard to retrieve exact information about a stack of controls. In short, try WinSpy for your problem.

Edited by Authenticity

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thanks for the info but this confuses me even more.

I was able to find what I think is the parent and child handles but I can't find any information on the DIM function so I don't know what I'm trying to accomplish by using it. I found some info on the Hwnd in the Help file but I'm still in the fog.

So here's what I'd like for you to answer for me if possible.

Currently when I execute the script Service Center maximizes and become the active window.

I'm not confident that the control click executes but what I do see is that after about 20 sec the .exe closes instead of repeating.

So what command do I use to make the controlclick repeat at a set delay?

here's what I get when i execute from within SciTE:

>"D:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Documents and Settings\username\My Documents\AutoIT\SC_AutoRefresh2.au3" /autoit3dir "D:\Program Files\AutoIt3" /UserParams

+>17:05:14 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 ANSI)

>Running AU3Check (1.54.14.0) from:D:\Program Files\AutoIt3

+>17:05:14 AU3Check ended.rc:0

>Running:(3.3.0.0): D:\Program Files\AutoIt3\autoit3.exe "D:\Documents and Settings\username\My Documents\AutoIT\SC_AutoRefresh2.au3"

+>17:05:21 AutoIT3.exe ended.rc:0

+>17:05:22 AutoIt3Wrapper Finished

>Exit code: 0 Time: 8.597

Edited by cpezie

Share this post


Link to post
Share on other sites

Well I was able to make the MouseClick function work though it's not my idea solution.

Now I just have to figure out how to make it repeat every 10 minutes.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Dim $iMin = @MIN + 10
If $iMin > 59 Then $iMin = Mod($iMin, 10)
Dim $iInterval = 1000*30
_ServerRefresh()

While 1
    Sleep($iInterval)
    _Check()
WEnd


Func _Check()
    If $iMin = @MIN Then
        $iMin += 10
        If $iMin > 59 Then $iMin = Mod($iMin, 10)
        _ServerRefresh()
    EndIf
EndFunc

Func _ServerRefresh()
    ; Refresh the server
EndFunc

Edited by Authenticity

Share this post


Link to post
Share on other sites

... Thanks for the reply and info.

I've worked thru the tutorials but didn't see info on the Control ID specifically the controlclick. ...

You are welcome.

I've been away from the forum and NET for a few days. :-(

Sorry - I've not looked at those tuts in a long time, I was not aware that controlclick was not covered. :-(

... When I type controlclick in SciTe I receiving the caption which I thought I followed. ControlClick ("title", "text", controlID [, button [, clicks [, x [, y ]]]] ) ...

It was the trailing bracket after your y value that I was unsure of... but you fixed that now.

... Question: Why did you encapsulate the controlclick inside of $ret? I could not find any documentation on $ret.

Also with the code you supplied I do return a 1 so it does recognize the program but it still times out. ...

#ret is just the name of my variable. it could hanve been $var or any vaild variable name. It is assigned the return value of the controlclick function. After that controlclick function executes, it passes/assigns the return value of 1 to $ret if the control was located - otherwise, it returns 0.

There are many other ways to use the return value besides having it go to a variable:

msgbox(0,"",controlclick(......)) would also display the return value.

When part of a single line if/then line of code, the return value is evaluated as the expression

if controlclick(......) then msgbox(0,"", "control was found")

that would be the same as:

if 1 then msgbox(0,"", "control was found")

or

if 0 then msgbox(0,"", "control was found")

For the if/then lines above, the msgbox would only appear if the controlclick returned a value of 1.

~hope this helps~


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks for you help (both of you) :D

I finally got it working using the controlclick, yes! LOL. To add insult even though I'm watching the Service Center refresh every ten minutes as it should it still ends up timing out.???? I assumed that activating the refresh button would surely keep the active session alive. WTF. So now I've gotta figure out what triggers an active session in SC.

Well this is the code that I ended up with. Of course it's your code you guy's just made me figure out the little things lol but I'm glad you did. Also after staring at AutoIT Win Info I realized that it was actually telling me the parent/child controls the whole time I just didn't know what I was looking at. :P Now I need to donate some cash cause you didnt have to do anything. :unsure:

----

; Script Function: Every 10 minutes send commands to refresh Service Center.

;Declare Variables

Dim $iMin = @MIN + 10

If $iMin > 59 Then $iMin = Mod($iMin, 10)

Dim $iInterval = 1000*30

_ServerRefresh()

While 1

Sleep($iInterval)

_Check()

WEnd

Func _Check()

If $iMin = @MIN Then

$iMin += 10

If $iMin > 59 Then $iMin = Mod($iMin, 10)

_ServerRefresh()

EndIf

EndFunc

Func _ServerRefresh()

; Refresh the server

WinActivate("ServiceCenter - Main Menu:")

WinWaitActive("ServiceCenter - Main Menu:")

Dim $hwnd = WinGetHandle("ServiceCenter - Main Menu:")

Dim $hParent = ControlGetHandle($hwnd, "", "SWT_Window0")

Dim $hChild = ControlGetHandle($hParent, "", "[CLASS:ToolbarWindow32; INSTANCE:13]")

ControlClick ( "", "", $hChild, "", 1, 34, 11 )

EndFunc

Share this post


Link to post
Share on other sites

... it still ends up timing out.???? ... So now I've gotta figure out what triggers an active session in SC. ...

I'm not sure that the forum at sc-resources.net is discussing the same product that you are working with. A Google of "Service Center 6" "timeout" took me to that forum and these posts:

http://www.sc-resources.net/showthread.php?t=148

http://www.sc-resources.net/showthread.php?t=2542

Sorry if that chases the wrong rabbit.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
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
Sign in to follow this  
Followers 0