Jump to content

Prosess Time Problem


Bert
 Share

Recommended Posts

I have a script that will dock a toolbar to a window. It works, but I have a process time problem. I attempted to fix it by adding sleep statements in various places, and it helped, but it doesn't address the root of the problem. I suspect the problem is between lines 211 and 225. Also, sometimes the script will not exit when the window no longer exist. Any help would be welcomed.

CODE
#include <GuiConstants.au3>

;#Include <IE.au3>

Opt("WinTitleMatchMode", 2)

Opt("GUIOnEventMode", 1)

Opt('MustDeclareVars', 1)

;TraySetState(2)

Global $Title

Dim $Btn_1, $Btn_2, $Btn_3, $Btn_4, $Btn_5, $Btn_6, $Btn_7, $Btn_8, $Btn_9, $Btn_10

Dim $GUI1, $GUI2, $qst3, $keySET

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

Dim $xx, $yy, $wgt, $Keep_IVTool, $WinList, $Temp_Title, $TitleChange = True

Dim $s_URL, $o_object

If $CMDLine[0] <> 1 Then Exit

$Title = $CMDLine[1]

$Temp_Title = $Title

WinWait($Title)

$GUI2 = WinGetHandle($Title)

$wgt = WinGetTitle($Title)

;===================================================================================================

$xx = 215

$yy = 55

$GUI1 = GUICreate("Toolbar", $xx, $yy, -1, -1, $WS_CLIPSIBLINGS, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $GUI2)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

;===================================================================================================

GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================

$Keep_IVTool = True

While $Keep_IVTool

sleep(17)

Select

Case $Title <> $Temp_Title

; When title change, save new title and delete all control ID

$Temp_Title = $Title

$TitleChange = True

GUICtrlDelete($Btn_1)

GUICtrlDelete($Btn_2)

GUICtrlDelete($Btn_3)

GUICtrlDelete($Btn_4)

GUICtrlDelete($Btn_5)

GUICtrlDelete($Btn_6)

GUICtrlDelete($Btn_7)

GUICtrlDelete($Btn_8)

GUICtrlDelete($Btn_9)

GUICtrlDelete($Btn_10) ;etc...

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("Printer2.ico", -1, 1, 1, 30, 30) ;print ticket

GUICtrlSetTip(-1, " Print ticket ")

GUICtrlSetOnEvent($Btn_1, "_print_incident")

$Btn_2 = GUICtrlCreateIcon("Recycle.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip(-1, " Refresh ticket ")

GUICtrlSetOnEvent($Btn_2, "_refresh_ticket")

$Btn_3 = GUICtrlCreateIcon("log1.ICO", -1, 70, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_3, "_log_note")

GUICtrlSetTip(-1, " Log comment")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("FedExPak.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_Fedex")

GUICtrlSetTip($Btn_5, " Track Depot Part shipped with Fedex" & @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

$Btn_6 = GUICtrlCreateIcon("Envel.ico", -1, 175, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_6, "_Depot")

GUICtrlSetTip($Btn_6, " Track part ordered in Depot system"& @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Request Detail - Unicenter ServicePlus Service Desk") <> 0

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("Printer2.ico", -1, 1, 1, 30, 30) ;print ticket

GUICtrlSetTip(-1, " Print ticket ")

GUICtrlSetOnEvent($Btn_1, "_print_incident")

$Btn_2 = GUICtrlCreateIcon("Recycle.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip(-1, " Refresh ticket ")

GUICtrlSetOnEvent($Btn_2, "_refresh_ticket")

$Btn_3 = GUICtrlCreateIcon("log1.ICO", -1, 70, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_3, "_log_note")

GUICtrlSetTip(-1, " Log comment")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("FedExPak.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_Fedex")

GUICtrlSetTip($Btn_5, " Track Depot Part shipped with Fedex" & @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

$Btn_6 = GUICtrlCreateIcon("Envel.ico", -1, 175, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_6, "_Depot")

GUICtrlSetTip($Btn_6, " Track part ordered in Depot system"& @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Problem Detail - Unicenter ServicePlus Service Desk") <> 0

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("Printer2.ico", -1, 1, 1, 30, 30) ;print ticket

GUICtrlSetTip(-1, " Print ticket ")

GUICtrlSetOnEvent($Btn_1, "_print_incident")

$Btn_2 = GUICtrlCreateIcon("Recycle.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip(-1, " Refresh ticket ")

GUICtrlSetOnEvent($Btn_2, "_refresh_ticket")

$Btn_3 = GUICtrlCreateIcon("log1.ICO", -1, 70, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_3, "_log_note")

GUICtrlSetTip(-1, " Log comment")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("FedExPak.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_Fedex")

GUICtrlSetTip($Btn_5, " Track Depot Part shipped with Fedex" & @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

$Btn_6 = GUICtrlCreateIcon("Envel.ico", -1, 175, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_6, "_Depot")

GUICtrlSetTip($Btn_6, " Track part ordered in Depot system"& @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Update Incident - Unicenter ServicePlus Service Desk") <> 0

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("log1.ICO", -1, 1, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_1, "_log_note2")

GUICtrlSetTip($Btn_1, " Log comment")

$Btn_2 = GUICtrlCreateIcon("Palmtree.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip($Btn_2, " TreePaste Configuration item lookup tool " & @CRLF _

& "CLICK IN THE CONFIGURATION" & @CRLF _

& "ITEM FIELD BEFORE USING!!")

GUICtrlSetOnEvent($Btn_2, "_F4")

$Btn_3 = GUICtrlCreateIcon("Crayons.ico", -1, 70, 1, 30, 30) ;print ticket

GUICtrlSetTip($Btn_3, " QuickPaste clipboard enhancement tool" & @CRLF _

& "CLICK IN THE FIELD YOU WISH" & @CRLF _

& "TO EDIT BEFORE USING!!")

GUICtrlSetOnEvent($Btn_3, "_F6")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("Alarmclock.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_F9")

GUICtrlSetTip($Btn_5, " Time Stamper" & @CRLF _

& "CLICK IN THE FIELD YOU WANT" & @CRLF _

& "TO TIMESTAMP BEFORE USING!!")

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Update Request - Unicenter ServicePlus Service Desk") <> 0

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("log1.ICO", -1, 1, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_1, "_log_note2")

GUICtrlSetTip($Btn_1, " Log comment")

$Btn_2 = GUICtrlCreateIcon("Palmtree.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip($Btn_2, " TreePaste Configuration item lookup tool " & @CRLF _

& "CLICK IN THE CONFIGURATION" & @CRLF _

& "ITEM FIELD BEFORE USING!!")

GUICtrlSetOnEvent($Btn_2, "_F4")

$Btn_3 = GUICtrlCreateIcon("Crayons.ico", -1, 70, 1, 30, 30) ;print ticket

GUICtrlSetTip($Btn_3, " QuickPaste clipboard enhancement tool" & @CRLF _

& "CLICK IN THE FIELD YOU WISH" & @CRLF _

& "TO EDIT BEFORE USING!!")

GUICtrlSetOnEvent($Btn_3, "_F6")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("Alarmclock.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_F9")

GUICtrlSetTip($Btn_5, " Time Stamper" & @CRLF _

& "CLICK IN THE FIELD YOU WANT" & @CRLF _

& "TO TIMESTAMP BEFORE USING!!")

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Update Problem - Unicenter ServicePlus Service Desk") <> 0

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("log1.ICO", -1, 1, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_1, "_log_note2")

GUICtrlSetTip($Btn_1, " Log comment")

$Btn_2 = GUICtrlCreateIcon("Palmtree.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip($Btn_2, " TreePaste Configuration item lookup tool " & @CRLF _

& "CLICK IN THE CONFIGURATION" & @CRLF _

& "ITEM FIELD BEFORE USING!!")

GUICtrlSetOnEvent($Btn_2, "_F4")

$Btn_3 = GUICtrlCreateIcon("Crayons.ico", -1, 70, 1, 30, 30) ;print ticket

GUICtrlSetTip($Btn_3, " QuickPaste clipboard enhancement tool" & @CRLF _

& "CLICK IN THE FIELD YOU WISH" & @CRLF _

& "TO EDIT BEFORE USING!!")

GUICtrlSetOnEvent($Btn_3, "_F6")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("Alarmclock.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_F9")

GUICtrlSetTip($Btn_5, " Time Stamper" & @CRLF _

& "CLICK IN THE FIELD YOU WANT" & @CRLF _

& "TO TIMESTAMP BEFORE USING!!")

EndSelect

sleep(4)

_ToolbarDocked()

$Keep_IVTool = False

$WinList = WinList()

For $x = 1 To $WinList[0][0]

ConsoleWrite('Title: ' & $WinList[$x][0] & @LF & 'WinHandle: ' & $WinList[$x][1] & @CRLF)

If $GUI2 == $WinList[$x][1] Then

$Keep_IVTool = True

$Title = $WinList[$x][0]

ExitLoop

EndIf

Next

WEnd

_Exit()

Func _ToolbarDocked()

$p_win1 = WinGetPos($GUI1);parent

$p_win2 = WinGetPos($GUI2);toolbar

If Not IsArray($p_win1) Or Not IsArray($p_win2) Then Return

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - ($xx + 3)

$y2 = $y1 - ($yy - 31)

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + ($xx + 3)

$y1 = $y2 + ($yy - 31)

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1 - ($xx + 5) ;

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2 - ($xx + 5) ;

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

EndFunc ;==>_ToolbarDocked

Func _Exit()

IniWrite(@TempDir & '\' & $GUI2 & '.ini', 'Main', 'WinHandle', $GUI2)

GUIDelete($GUI1)

While FileExists(@TempDir & '\' & $GUI2 & '.ini')

Sleep(10)

WEnd

Exit

EndFunc ;==>_Exit

;Func _Exit()

;IniWrite(@TempDir & '\' & $GUI2 & '.ini', 'Main', 'WinHandle', $GUI2)

;

;While FileExists(@TempDir & '\' & $GUI2 & '.ini')

;Sleep(5)

;WEnd

;Exit

;EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _print_incident()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{PRINTSCREEN}")

EndFunc ;==>_print_incident

Func _refresh_ticket()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F5}")

EndFunc ;==>_refresh_ticket

Func _F5()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F5}")

EndFunc ;==>_refresh_ticket

Func _F4()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F4}")

EndFunc ;==>_refresh_ticket

Func _F9()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F9}")

EndFunc

Func _log_note()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then

WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")

Else

sleep(20)

BlockInput(1)

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

sleep(20)

Send("!t")

Sleep(500)

Send("l")

BlockInput(0)

EndIf

EndFunc ;==>_log_note

Func _log_note2()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then

WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")

Else

sleep(20)

BlockInput(1)

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

sleep(20)

Send("!t")

Sleep(500)

Send("l")

BlockInput(0)

EndIf

EndFunc ;==>_log_note

Func _depotmain()

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://atlnotes1.stsc.suntrust.com/SunTrac...?OpenForm", "")

EndFunc

Func _fedex()

while 2

$qst3 = MsgBox(4, "Track in FedEx", "Did you highlight the depot tracking number?")

If $qst3 = 6 Then

_next()

ExitLoop

ElseIf $qst3 = 7 Then

ExitLoop

EndIf

WEnd

EndFunc

Func _depot()

while 3

$qst3 = MsgBox(4, "Track in Depot", "Did you highlight the depot tracking number?")

If $qst3 = 6 Then

_next2()

exitloop

ElseIf $qst3 = 7 Then

ExitLoop

EndIf

WEnd

EndFunc

Func _next()

BlockInput(1)

WinActivate("Detail - Unicenter ServicePlus Service Desk")

Send("^c")

sleep(10)

Send("^c")

sleep(10)

Send("^c")

sleep(30)

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new https://www.fedex.com/AltRefTracking?ascend...&altref=y", "")

WinWaitActive("FedEx | Track", "Done", 10)

sleep(1500)

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;5

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;10

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;15

sleep(20)

Send("{TAB}")

sleep(20)

sleep(20)

Send("^v")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

Sleep(20)

Send("{DOWN}")

sleep(20)

Send("{TAB}")

sleep(50)

Send("{TAB}")

BlockInput(0)

EndFunc

Func _next2()

BlockInput(1)

WinActivate("Detail - Unicenter ServicePlus Service Desk")

Send("^c")

sleep(10)

Send("^c")

sleep(10)

Send("^c")

sleep(30)

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://atlnotes1.stsc.suntrust.com/SunTrac...?OpenForm", "")

WinWaitActive("Depot Ordering System - Search Orders", "http://atlnotes1.stsc.suntrust.com/SunTrack/DepotNew.nsf/SearchOrders?OpenForm", 5)

WinWaitActive("Depot Ordering System - Search Orders", "Done", 5)

_depotc()

if WinExists("http://atlnotes1.stsc.suntrust.com/SunTrack/DepotNew.nsf/SearchOrders?OpenForm&Seq=1") then

sleep(100)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{ENTER}")

_depotc()

endif

WinWaitActive("Matching Orders for your Search", "", 5)

sleep(200)

Send("{TAB 2}")

sleep(20)

Send("{ENTER}")

WinWaitActive("Depot Ordering System - Order #", "Done", 5)

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{ENTER}")

BlockInput(0)

EndFunc

func _depotc()

sleep(400)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("^v")

sleep(20)

Send("{ENTER}")

EndFunc

func _F6()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

$keySET = IniRead("unplus.ini", "qkeys", "key", "{" & "F6" & "}")

Sleep(20)

send($keySET)

EndFunc

#endregion

Link to comment
Share on other sites

anyone at all? :)

I looked at your code twice today.

There are several things that I would do differently, but none that relate to the issue that you mentioned.

Are you sure that you could not cut the code down to something a bit smaller and still have it show your problem? You might get more help with a bit less code... or maybe not.

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

Link to comment
Share on other sites

I have no problem in reworking it so it is smaller. If you see a better way to code it, by all means please do. I'm no expert at this, and I love to learn anything new. I reworked the code to this script, but my problem still exist. I did manage to fix the problem of the program not exiting. it was caused by the func _exit() having a loop. I took out the loop, and it closes fine. I still need to fix the processor time problem. Thoughts?

CODE
;ivtool version 1.2

#include <GuiConstants.au3>

Opt("WinTitleMatchMode", 2)

Opt("GUIOnEventMode", 1)

Opt('MustDeclareVars', 1)

;TraySetState(2)

Global $Title

Dim $Btn_1, $Btn_2, $Btn_3, $Btn_4, $Btn_5, $Btn_6, $Btn_7, $Btn_8, $Btn_9, $Btn_10

Dim $GUI1, $GUI2, $qst3, $keySET

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

Dim $xx, $yy, $wgt, $Keep_IVTool, $WinList, $Temp_Title, $TitleChange = True

Dim $s_URL, $o_object

If $CMDLine[0] <> 1 Then Exit

$Title = $CMDLine[1]

$Temp_Title = $Title

WinWait($Title)

$GUI2 = WinGetHandle($Title)

$wgt = WinGetTitle($Title)

;===================================================================================================

$xx = 215

$yy = 55

$GUI1 = GUICreate("Toolbar", $xx, $yy, -1, -1, $WS_CLIPSIBLINGS, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $GUI2)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

;===================================================================================================

GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================

$Keep_IVTool = True

While $Keep_IVTool

sleep(17)

Select

Case $Title <> $Temp_Title

; When title change, save new title and delete all control ID

$Temp_Title = $Title

$TitleChange = True

GUICtrlDelete($Btn_1)

GUICtrlDelete($Btn_2)

GUICtrlDelete($Btn_3)

GUICtrlDelete($Btn_4)

GUICtrlDelete($Btn_5)

GUICtrlDelete($Btn_6)

GUICtrlDelete($Btn_7)

GUICtrlDelete($Btn_8)

GUICtrlDelete($Btn_9)

GUICtrlDelete($Btn_10) ;etc...

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0

_detail()

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Request Detail - Unicenter ServicePlus Service Desk") <> 0

_detail()

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Problem Detail - Unicenter ServicePlus Service Desk") <> 0

_detail()

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Update Incident - Unicenter ServicePlus Service Desk") <> 0

_updateT()

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Update Request - Unicenter ServicePlus Service Desk") <> 0

_updateT()

EndSelect

sleep(5)

Select

Case $TitleChange And StringInStr($Title, "Update Problem - Unicenter ServicePlus Service Desk") <> 0

_updateT()

EndSelect

sleep(4)

_ToolbarDocked()

$Keep_IVTool = False

$WinList = WinList()

For $x = 1 To $WinList[0][0]

ConsoleWrite('Title: ' & $WinList[$x][0] & @LF & 'WinHandle: ' & $WinList[$x][1] & @CRLF)

If $GUI2 == $WinList[$x][1] Then

$Keep_IVTool = True

$Title = $WinList[$x][0]

ExitLoop

EndIf

Next

WEnd

_Exit()

Func _detail()

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("Printer2.ico", -1, 1, 1, 30, 30) ;print ticket

GUICtrlSetTip(-1, " Print ticket ")

GUICtrlSetOnEvent($Btn_1, "_print_incident")

$Btn_2 = GUICtrlCreateIcon("Recycle.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip(-1, " Refresh ticket ")

GUICtrlSetOnEvent($Btn_2, "_refresh_ticket")

$Btn_3 = GUICtrlCreateIcon("log1.ICO", -1, 70, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_3, "_log_note")

GUICtrlSetTip(-1, " Log comment")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("FedExPak.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_Fedex")

GUICtrlSetTip($Btn_5, " Track Depot Part shipped with Fedex" & @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

$Btn_6 = GUICtrlCreateIcon("Envel.ico", -1, 175, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_6, "_Depot")

GUICtrlSetTip($Btn_6, " Track part ordered in Depot system"& @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

EndFunc

Func _updateT()

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("log1.ICO", -1, 1, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_1, "_log_note2")

GUICtrlSetTip($Btn_1, " Log comment")

$Btn_2 = GUICtrlCreateIcon("Palmtree.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip($Btn_2, " TreePaste Configuration item lookup tool " & @CRLF _

& "CLICK IN THE CONFIGURATION" & @CRLF _

& "ITEM FIELD BEFORE USING!!")

GUICtrlSetOnEvent($Btn_2, "_F4")

$Btn_3 = GUICtrlCreateIcon("Crayons.ico", -1, 70, 1, 30, 30) ;print ticket

GUICtrlSetTip($Btn_3, " QuickPaste clipboard enhancement tool" & @CRLF _

& "CLICK IN THE FIELD YOU WISH" & @CRLF _

& "TO EDIT BEFORE USING!!")

GUICtrlSetOnEvent($Btn_3, "_F6")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("Alarmclock.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_F9")

GUICtrlSetTip($Btn_5, " Time Stamper" & @CRLF _

& "CLICK IN THE FIELD YOU WANT" & @CRLF _

& "TO TIMESTAMP BEFORE USING!!")

EndFunc

Func _ToolbarDocked()

$p_win1 = WinGetPos($GUI1);parent

$p_win2 = WinGetPos($GUI2);toolbar

If Not IsArray($p_win1) Or Not IsArray($p_win2) Then Return

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - ($xx + 3)

$y2 = $y1 - ($yy - 31)

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + ($xx + 3)

$y1 = $y2 + ($yy - 31)

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1 - ($xx + 5) ;

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2 - ($xx + 5) ;

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

EndFunc ;==>_ToolbarDocked

Func _Exit()

IniWrite(@TempDir & '\' & $GUI2 & '.ini', 'Main', 'WinHandle', $GUI2)

GUIDelete($GUI1)

Exit

EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _print_incident()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{PRINTSCREEN}")

EndFunc ;==>_print_incident

Func _refresh_ticket()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F5}")

EndFunc ;==>_refresh_ticket

Func _F5()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F5}")

EndFunc ;==>_refresh_ticket

Func _F4()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F4}")

EndFunc ;==>_refresh_ticket

Func _F9()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F9}")

EndFunc

Func _log_note()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then

WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")

Else

sleep(20)

BlockInput(1)

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

sleep(20)

Send("!t")

Sleep(500)

Send("l")

BlockInput(0)

EndIf

EndFunc ;==>_log_note

Func _log_note2()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then

WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")

Else

sleep(20)

BlockInput(1)

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

sleep(20)

Send("!t")

Sleep(500)

Send("l")

BlockInput(0)

EndIf

EndFunc ;==>_log_note

Func _depotmain()

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://atlnotes1.stsc.suntrust.com/SunTrac...?OpenForm", "")

EndFunc

Func _fedex()

while 2

$qst3 = MsgBox(4, "Track in FedEx", "Did you highlight the depot tracking number?")

If $qst3 = 6 Then

_next()

ExitLoop

ElseIf $qst3 = 7 Then

ExitLoop

EndIf

WEnd

EndFunc

Func _depot()

while 3

$qst3 = MsgBox(4, "Track in Depot", "Did you highlight the depot tracking number?")

If $qst3 = 6 Then

_next2()

exitloop

ElseIf $qst3 = 7 Then

ExitLoop

EndIf

WEnd

EndFunc

Func _next()

BlockInput(1)

WinActivate("Detail - Unicenter ServicePlus Service Desk")

Send("^c")

sleep(10)

Send("^c")

sleep(10)

Send("^c")

sleep(30)

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new https://www.fedex.com/AltRefTracking?ascend...&altref=y", "")

WinWaitActive("FedEx | Track", "Done", 10)

sleep(1500)

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;5

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;10

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;15

sleep(20)

Send("{TAB}")

sleep(20)

sleep(20)

Send("^v")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

Sleep(20)

Send("{DOWN}")

sleep(20)

Send("{TAB}")

sleep(50)

Send("{TAB}")

BlockInput(0)

EndFunc

Func _next2()

BlockInput(1)

WinActivate("Detail - Unicenter ServicePlus Service Desk")

Send("^c")

sleep(10)

Send("^c")

sleep(10)

Send("^c")

sleep(30)

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://atlnotes1.stsc.suntrust.com/SunTrac...?OpenForm", "")

WinWaitActive("Depot Ordering System - Search Orders", "http://atlnotes1.stsc.suntrust.com/SunTrack/DepotNew.nsf/SearchOrders?OpenForm", 5)

WinWaitActive("Depot Ordering System - Search Orders", "Done", 5)

_depotc()

if WinExists("http://atlnotes1.stsc.suntrust.com/SunTrack/DepotNew.nsf/SearchOrders?OpenForm&Seq=1") then

sleep(100)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{ENTER}")

_depotc()

endif

WinWaitActive("Matching Orders for your Search", "", 5)

sleep(200)

Send("{TAB 2}")

sleep(20)

Send("{ENTER}")

WinWaitActive("Depot Ordering System - Order #", "Done", 5)

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{ENTER}")

BlockInput(0)

EndFunc

func _depotc()

sleep(400)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("^v")

sleep(20)

Send("{ENTER}")

EndFunc

func _F6()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

$keySET = IniRead("unplus.ini", "qkeys", "key", "{" & "F6" & "}")

Sleep(20)

send($keySET)

EndFunc

#endregion

Link to comment
Share on other sites

Edit: Replaced all of these comments with a reworked version of the function named "_next" in a later post.

...but I still wonder about this:

I'm not sure that I understand you are repeating Select/Case/EndSelect with only one Case? It seems like one If line (with no EndIf) would have less CPU load.

If $TitleChange And StringInStr($Title, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0 Then _detail ()
That one line would replace one set of your Select/Case/EndSelect........or........use more than one case statement between your Select and EndSelect lines - see the sample in the help file. [Caveat - I've seen others repeat Select/Case/EndSelect lines with only one Case line - so there might be something to it that I just don't get.]

...hope this helps...

Edited by herewasplato

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

Link to comment
Share on other sites

@herewasplato: The application I'm dealing with doesn't have any controls I can grab ahold of. I've tried working with IE.au3 on them, and it wouldn't work. This aplication is a exe that runs inside of IE, so my options of controling the window is limited. (Thus the tabs) . I can't use clipput, for AutoIT can't see the text. My only option was ^C, and I ended up using the repeat for I have to deal with when the window shows up in full, then when it is available. It has a mind of its own, so I'm left with timing to get it to work. That part does seem however to be stable.

I'm not sure that I understand you are repeating Select/Case/EndSelect with only one Case? It seems like one If line (with no EndIf) would have less CPU load.CODEIf $TitleChange And StringInStr($Title, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0 Then _detail ()That one line would replace one set of your Select/Case/EndSelect........or........use more than one case statement between your Select and EndSelect lines - see the sample in the help file. [Caveat - I've seen others repeat Select/Case/EndSelect lines with only one Case line - so there might be something to it that I just don't get.]...hope this helps...

I was trying to spread around the sleep statements to lessen the CPU load. I didn't like doing this, but otherwise I was running around 50% load. I rather find a better way to fix it.

I reworked it some more, and did some testing, and I think in the following code the problem is in the area of line 77 to 87.

In it's current form, I'v got a CPU load around 17. You will notice the sleep statements between some of the case statements. I had this problem in another script, and I was advised this might fix my issue. By adding a sleep(1) between the 3 different types of case statements, I get the CPU time down from 50 to 17. If I change it to 10, it won't improve it much, and I start to suffer from responce time issues.

CODE
#include <GuiConstants.au3>

;#Include <IE.au3>

Opt("WinTitleMatchMode", 2)

Opt("GUIOnEventMode", 1)

Opt('MustDeclareVars', 1)

TraySetState(2)

Global $Title ;= "Incident Detail - Unicenter ServicePlus Service Desk"

Dim $Btn_1, $Btn_2, $Btn_3, $Btn_4, $Btn_5, $Btn_6, $Btn_7, $Btn_8, $Btn_9, $Btn_10

Dim $GUI1, $GUI2, $qst3, $keySET

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

Dim $xx, $yy, $wgt, $Keep_IVTool, $WinList, $Temp_Title, $TitleChange = True

Dim $s_URL, $o_object

If $CMDLine[0] <> 1 Then Exit

$Title = $CMDLine[1]

$Temp_Title = $Title

WinWait($Title)

$GUI2 = WinGetHandle($Title)

$wgt = WinGetTitle($Title)

;===================================================================================================

$xx = 215

$yy = 55

$GUI1 = GUICreate("Ticket Toolbar", $xx, $yy, -1, -1, $WS_CLIPSIBLINGS, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $GUI2)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

;===================================================================================================

GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================

$Keep_IVTool = True

While $Keep_IVTool

if WinActive("Ticket Toolbar") then WinActivate($Title)

;sleep(15)

Select

case $wgt == 0

exit

EndSelect

sleep(1)

select

Case $Title <> $Temp_Title

; When title change, save new title and delete all control ID

$Temp_Title = $Title

$TitleChange = True

GUICtrlDelete($Btn_1)

GUICtrlDelete($Btn_2)

GUICtrlDelete($Btn_3)

GUICtrlDelete($Btn_4)

GUICtrlDelete($Btn_5)

GUICtrlDelete($Btn_6)

EndSelect

sleep(1)

Select

Case $TitleChange And StringInStr($Title, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0

_detail()

Case $TitleChange And StringInStr($Title, "Request Detail - Unicenter ServicePlus Service Desk") <> 0

_detail()

Case $TitleChange And StringInStr($Title, "Problem Detail - Unicenter ServicePlus Service Desk") <> 0

_detail()

Case $TitleChange And StringInStr($Title, "Update Incident - Unicenter ServicePlus Service Desk") <> 0

_update()

Case $TitleChange And StringInStr($Title, "Update Request - Unicenter ServicePlus Service Desk") <> 0

_update()

Case $TitleChange And StringInStr($Title, "Update Problem - Unicenter ServicePlus Service Desk") <> 0

_update()

EndSelect

;sleep(15)

_ToolbarDocked()

$Keep_IVTool = False

$WinList = WinList()

For $x = 1 To $WinList[0][0]

ConsoleWrite('Title: ' & $WinList[$x][0] & @LF & 'WinHandle: ' & $WinList[$x][1] & @CRLF)

If $GUI2 == $WinList[$x][1] Then

$Keep_IVTool = True

$Title = $WinList[$x][0]

ExitLoop

EndIf

Next

WEnd

_Exit()

Func _detail()

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("Printer2.ico", -1, 1, 1, 30, 30) ;print ticket

GUICtrlSetTip(-1, " Print ticket ")

GUICtrlSetOnEvent($Btn_1, "_print_incident")

$Btn_2 = GUICtrlCreateIcon("Recycle.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip(-1, " Refresh ticket ")

GUICtrlSetOnEvent($Btn_2, "_refresh_ticket")

$Btn_3 = GUICtrlCreateIcon("log1.ICO", -1, 70, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_3, "_log_note")

GUICtrlSetTip(-1, " Log comment")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("FedExPak.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_Fedex")

GUICtrlSetTip($Btn_5, " Track Depot Part shipped with Fedex" & @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

$Btn_6 = GUICtrlCreateIcon("Envel.ico", -1, 175, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_6, "_Depot")

GUICtrlSetTip($Btn_6, " Track part ordered in Depot system"& @CRLF _

& "HIGHLIGHT DEPOT ORDER NUMBER BEFORE USING!!")

EndFunc

Func _update()

$TitleChange = False

$Btn_1 = GUICtrlCreateIcon("log1.ICO", -1, 1, 1, 30,30) ;log comment

GUICtrlSetOnEvent($Btn_1, "_log_note2")

GUICtrlSetTip($Btn_1, " Log comment")

$Btn_2 = GUICtrlCreateIcon("Palmtree.ico", -1, 35, 1, 30, 30) ;refresh ticket

GUICtrlSetTip($Btn_2, " TreePaste Configuration item lookup tool " & @CRLF _

& "CLICK IN THE CONFIGURATION" & @CRLF _

& "ITEM FIELD BEFORE USING!!")

GUICtrlSetOnEvent($Btn_2, "_F4")

$Btn_3 = GUICtrlCreateIcon("Crayons.ico", -1, 70, 1, 30, 30) ;print ticket

GUICtrlSetTip($Btn_3, " QuickPaste clipboard enhancement tool" & @CRLF _

& "CLICK IN THE FIELD YOU WISH" & @CRLF _

& "TO EDIT BEFORE USING!!")

GUICtrlSetOnEvent($Btn_3, "_F6")

$Btn_4 = GUICtrlCreateIcon("Crate.ICO", -1, 105, 1, 30, 30) ;depot main

GUICtrlSetOnEvent($Btn_4, "_depotmain")

GUICtrlSetTip(-1, " Open a Depot Ticket")

$Btn_5 = GUICtrlCreateIcon("Alarmclock.ico", -1, 140, 1, 30, 30) ;Track part shipped With FedEx

GUICtrlSetOnEvent($Btn_5, "_F9")

GUICtrlSetTip($Btn_5, " Time Stamper" & @CRLF _

& "CLICK IN THE FIELD YOU WANT" & @CRLF _

& "TO TIMESTAMP BEFORE USING!!")

EndFunc

Func _ToolbarDocked()

$p_win1 = WinGetPos($GUI1);parent

$p_win2 = WinGetPos($GUI2);toolbar

If Not IsArray($p_win1) Or Not IsArray($p_win2) Then Return

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - ($xx + 3)

$y2 = $y1 - ($yy - 31)

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + ($xx + 3)

$y1 = $y2 + ($yy - 31)

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1 - ($xx + 5) ;

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2 - ($xx + 5) ;

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

EndFunc ;==>_ToolbarDocked

Func _Exit()

IniWrite(@TempDir & '\' & $GUI2 & '.ini', 'Main', 'WinHandle', $GUI2)

GUIDelete($GUI1)

;While FileExists(@TempDir & '\' & $GUI2 & '.ini')

;Sleep(1)

;WEnd

Exit

EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _print_incident()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{PRINTSCREEN}")

EndFunc ;==>_print_incident

Func _refresh_ticket()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F5}")

EndFunc ;==>_refresh_ticket

Func _F5()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F5}")

EndFunc ;==>_refresh_ticket

Func _F4()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F4}")

EndFunc ;==>_refresh_ticket

Func _F9()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

Sleep(10)

Send("{F9}")

EndFunc

Func _log_note()

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then

WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")

Else

sleep(20)

BlockInput(1)

WinActivate("Incident Detail - Unicenter ServicePlus Service Desk")

sleep(20)

Send("!t")

Sleep(500)

Send("l")

BlockInput(0)

EndIf

EndFunc ;==>_log_note

Func _log_note2()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then

WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")

Else

sleep(20)

BlockInput(1)

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

sleep(20)

Send("!t")

Sleep(500)

Send("l")

BlockInput(0)

EndIf

EndFunc ;==>_log_note

Func _depotmain()

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://atlnotes1.stsc.suntrust.com/SunTrac...?OpenForm", "")

EndFunc

Func _fedex()

while 2

$qst3 = MsgBox(4, "Track in FedEx", "Did you highlight the depot tracking number?")

If $qst3 = 6 Then

_next()

ExitLoop

ElseIf $qst3 = 7 Then

ExitLoop

EndIf

WEnd

EndFunc

Func _depot()

while 3

$qst3 = MsgBox(4, "Track in Depot", "Did you highlight the depot tracking number?")

If $qst3 = 6 Then

_next2()

exitloop

ElseIf $qst3 = 7 Then

ExitLoop

EndIf

WEnd

EndFunc

Func _next()

BlockInput(1)

WinActivate("Detail - Unicenter ServicePlus Service Desk")

Send("^c")

sleep(10)

Send("^c")

sleep(10)

Send("^c")

sleep(30)

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new https://www.fedex.com/AltRefTracking?ascend...&altref=y", "")

WinWaitActive("FedEx | Track", "Done", 10)

sleep(1500)

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;5

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;10

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}") ;15

sleep(20)

Send("{TAB}")

sleep(20)

sleep(20)

Send("^v")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

Sleep(20)

Send("{DOWN}")

sleep(20)

Send("{TAB}")

sleep(50)

Send("{TAB}")

BlockInput(0)

EndFunc

Func _next2()

BlockInput(1)

WinActivate("Detail - Unicenter ServicePlus Service Desk")

Send("^c")

sleep(10)

Send("^c")

sleep(10)

Send("^c")

sleep(30)

Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://atlnotes1.stsc.suntrust.com/SunTrac...?OpenForm", "")

WinWaitActive("Depot Ordering System - Search Orders", "http://atlnotes1.stsc.suntrust.com/SunTrack/DepotNew.nsf/SearchOrders?OpenForm", 5)

WinWaitActive("Depot Ordering System - Search Orders", "Done", 5)

_depotc()

if WinExists("http://atlnotes1.stsc.suntrust.com/SunTrack/DepotNew.nsf/SearchOrders?OpenForm&Seq=1") then

sleep(100)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{ENTER}")

_depotc()

endif

WinWaitActive("Matching Orders for your Search", "", 5)

sleep(200)

Send("{TAB 2}")

sleep(20)

Send("{ENTER}")

WinWaitActive("Depot Ordering System - Order #", "Done", 5)

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("{ENTER}")

BlockInput(0)

EndFunc

func _depotc()

sleep(400)

Send("{TAB}")

sleep(20)

Send("{TAB}")

sleep(20)

Send("^v")

sleep(20)

Send("{ENTER}")

EndFunc

func _F6()

WinActivate("Update Incident - Unicenter ServicePlus Service Desk")

$keySET = IniRead("unplus.ini", "qkeys", "key", "{" & "F6" & "}")

Sleep(20)

send($keySET)

EndFunc

#endregion

edit: I added this, and I got the processor time to "0", However, my responce time got very sluggish. It is in the area of line 77 to 87. I suspect the problem is with line 81. I don't know how to solve it though.

_ToolbarDocked()
    $Keep_IVTool = False
    $WinList = WinList()
    For $x = 1 To $WinList[0][0]
        sleep(1)
        ConsoleWrite('Title: ' & $WinList[$x][0] & @LF & 'WinHandle: ' & $WinList[$x][1] & @CRLF)
        If $GUI2 == $WinList[$x][1] Then 
            $Keep_IVTool = True
            $Title = $WinList[$x][0]
            ExitLoop
        EndIf       
    Next    
WEnd

Thoughts?

Edited by vollyman
Link to comment
Share on other sites

  • Developers

ConsoleWrite('Title: ' & $WinList[$x][0] & @LF & 'WinHandle: ' & $WinList[$x][1] & @CRLF)

If I add a sleep(1) either just before or after, the responce time is real bad, like 4 or 5 seconds.

Why do you need the consolewrite() on that line? It will slow the script down a lot ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@vollyman,

See how it performs with that ConsoleWrite line remarked out and then reconsider the small changes that I mentioned. You can use ClipPut ("") - it just clears the clipboard to get it ready for your ctrl-c. The two loops that I posted should work for you - but I understand the need to fix the big things first.

As for tabbing around within IE - that was the point of that rather long post that I directed you to. It mentions a way to do it (without IE.au3) that may require less maintenance of your code. A simple do/tab/sleep/until loop instead of a dozen tab/sleep lines. At the very least, replace them with a for/tab/sleep/next loop.

got to run

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

Link to comment
Share on other sites

@JdeB: I had a friend of mine design this piece, and I havent tested it without it. If it bombs, is it possible to have it write to a text file instead to speed it up? On the same subject, is using consolewrite always going to cause a CPU load?

@herewasplato: I will give it a try. The windows that have the many tabs,(the Fedex site), was designed to see if it was possible. It does work ok, (not 100% though) but you are right in that there is a better way to do it. I will work on recoding it tomorrow.

Edited by vollyman
Link to comment
Share on other sites

@JdeB: I had a friend of mine design this piece, and I havent tested it without it. If it bombs, is it possible to have it write to a text file instead to speed it up? On the same subject, is using consolewrite always going to cause a CPU load?

It worked fine. THANK YOU!

@herewasplato: Had to take the mrs to the hopsital today, so I haven't had a chance to recode the script yet. She is fine, but currently sleeping with prince Valium. (Messed her back up)

Link to comment
Share on other sites

Hope she gets better...

I also noticed that you used a line of code like this:

WinWaitActive("FedEx | Track", "Done", 10)

...as long as that works for you, then that is fine...

If you give your code to a coworker, they might not have the IE status bar turned on. That would make the word "Done" hidden text. You might want to include AutoItSetOption("WinDetectHiddenText", 1) near the top of your script. I discuss this point in greater detail here:

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

(same link as in my other post above)

Edited by herewasplato

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

Link to comment
Share on other sites

Here is one function reworked for you:

Func _next()
 ;BlockInput(1)
 ;try for 100 times to clear the clipboard
 ;exit early if you succeed
    For $i = 1 To 100
        ClipPut("")
        Sleep(50)
        $junk = ClipGet()
        Sleep(50)
        If $junk = "" Then ExitLoop
        Sleep(50)
    Next
    If $junk <> "" Then MsgBox(0, "Error", "Possible Clipboard Error")
 ;try for 100 times to copy from the app
 ;exit early if you succeed
    For $i = 1 To 100
        WinActivate("Detail - Unicenter ServicePlus Service Desk")
        Send("^c")
        Sleep(50)
        $junk = ClipGet()
        Sleep(50)
        WinActivate("Detail - Unicenter ServicePlus Service Desk")
        Send("^c")
        Sleep(50)
        $junk2 = ClipGet()
        If $junk = $junk2 Then ExitLoop
        Sleep(50)
    Next
    If $junk <> $junk2 Then MsgBox(0, "Error", "Possible Clipboard Error")
    
    Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new https://www.fedex.com/AltRefTracking?ascend...&altref=y", "")
    WinWaitActive("FedEx | Track", "Done", 10)
 ;find the calendar as a reference
    Do
        Send("{TAB}")
        Sleep(20)
    Until WinExists("FedEx | Track", "java script:show_calendar")
 ;go back four tabs to the tracking number field
    Send("+{TAB 4}")
    Sleep(20)
    Send("^v");paste in info
    Sleep(20)
    Send("{TAB 5}");country
    Send("{DOWN}")
    Send("{TAB 2}");leaves focus on the "track" button
    BlockInput(0)
EndFunc;==>_next
Edit: I tested it with notepad instead of WinActivate("Detail - Unicenter ServicePlus Service Desk") and it seemed to work like your function did.

Edit2: ran the code thru Tidy...

Edit3: Comments on the clipboard loops:

http://www.autoitscript.com/forum/index.ph...ndpost&p=152678

Edited by herewasplato

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

Link to comment
Share on other sites

This looks real good. Your point on hidden text is very well taken. I have a script that this script needs to work with, and this point of yours makes enlighten me of a bug in it I will need to fix. I will plug in your code tomorrow and give it a try. Thanks!

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...