Jump to content

Strange thing with processor hunger


Bert
 Share

Recommended Posts

Here is my while loop:

While 1
    $GUIMsg = GUIGetMsg()
    $Title_test = WinGetTitle("")
    $Text_test = WinGetText($Title_test)    
        Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
                ExitLoop
    EndSwitch
    _ToolbarDocked()
        Select              
            Case _NowTime() = $current
                Exit
            Case StringInStr($Title_test, "Unicenter ServicePlus Service Desk") <> 0
                Select
                    Case StringInStr($Title_test, "Request Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Request Detail - Unicenter ServicePlus Service Desk")
                        _win1_func()
                    Case StringInStr($Title_test, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Incident Detail - Unicenter ServicePlus Service Desk")
                        _win1_func()
                    Case StringInStr($Title_test, "Problem Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Problem Detail - Unicenter ServicePlus Service Desk")
                        _win3_func()
    
                EndSelect   
                ContinueLoop
            Case Else
            ;;;;
        EndSelect   
    
WEnd

I noticed if I didn't add the Case Else, My processor usuage would be around 15. With it added, I'm at 0. Logic says the script is idling on the Case Else statement. I noticed however, if I move the Case Else to a different location in the case list, I get a error. I do notice in the helpfile it shows in the example script the Case Else is last, but the documentation makes no mention. If you only have a few case statements, it will work fine, but when you start adding them, the processor time goes up. I wonder if that needs to be noted in the help file. This has been a issue in my script for a long while now, I just noticed what was causing it. I'm not sure I need to post this in the bug section, for it isn't a bug, but something that isn't documented in the helpfile. Thoughts?

edit: Wouldn't the Au3Check see this as a error and not run the script if you leave out the Case Else?

Link to comment
Share on other sites

  • Moderators

Well, there is a problem is you leave the Case Else out if you have a large amount of case statements. Your processor time goes up.

Shouldn't be the case, since the Case Else doesn't do anything. I could understand if there was a Sleep(10) in there, or something, but just a blank comment is kind of weird.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Looking at your code and the way your doing the case statements, yes your cpu usage is going to go up.

All your case statements are calling functions

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

This must be my PC acting wierd. Now the processor time is hanging around 15 again, and I didn't change anything. :lmao:

Did you check the other processes running? I don't use Task Manager, I use Process Explorer, and I notice sometimes Firefox goes haywire or Explorer or even Process Explorer itself. Like all 3 of them are fighting over the same Priority settings. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Looking at your code and the way your doing the case statements, yes your cpu usage is going to go up.

All your case statements are calling functions

How would control the processing usage when you need to call those functions? What would need to be changed in order to still make the script do what he wants but limit the cpu usage. I'm kind of running into the same scenario. CPU hits as much as 30. Putting in a sleep drops it down to baout 4-6 but its still there.

Link to comment
Share on other sites

How would control the processing usage when you need to call those functions? What would need to be changed in order to still make the script do what he wants but limit the cpu usage. I'm kind of running into the same scenario. CPU hits as much as 30. Putting in a sleep drops it down to baout 4-6 but its still there.

More than 1 possibility. For example on event or register messages depending on what needs to be done.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I've been trying to isolate what is causing it, and I haven't been able to nail it down yet. I chopped everything out but the WinGetTitle, and I still have CPU hunger. I tried to add a msgbox right before the loop to see if something else was causing it, but it isn't it. This one has me puzzled.

Link to comment
Share on other sites

  • Moderators

I've been trying to isolate what is causing it, and I haven't been able to nail it down yet. I chopped everything out but the WinGetTitle, and I still have CPU hunger. I tried to add a msgbox right before the loop to see if something else was causing it, but it isn't it. This one has me puzzled.

Well since you're obviously not showing the entire script that replicates the issue (because the above doesn't on my machine), all we can do is speculate along with you :lmao:.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Here is the code as I've been trying to see what is causing the problem. I know, I'm not using arrays, so please, no kicking me to the curb on that account. I've chopped out everything I could to isolate what is the cause. Not sure what is causing the hunger problem. Knowing me it is something stupid I'm not seeing.

#include <GuiConstants.au3>
#include <Date.au3>
#include <GuiButton.au3>
#include<misc.au3>
;#include<escreen.au3>   ;remarked out for debugging
;#include<helpscreen.au3>  ;remarked out for debugging
;#include<printing.au3>  ;remarked out for debugging
Opt("WinTitleMatchMode", 2)
;Opt("GUIOnEventMode", 1) ;remarked out for testing
Opt('MustDeclareVars', 1)
Opt("WinDetectHiddenText", 1)
Opt("TrayIconDebug", 1) ;debug is on

Dim $ClientPos, $xx, $yy, $xa, $ya
Dim $Btn_1, $Btn_2, $Btn_3, $Btn_4, $Btn_5, $Btn_6, $Btn_7, $Btn_8, $Btn_9, $Btn_10
Dim $Btn_11, $Btn_12, $Btn_13, $Btn_14, $Btn_15, $Btn_16, $Btn_17, $Btn_18, $Btn_19, $Btn_20
Dim $GUI1, $GUI2, $current
Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1
Dim $g_szVersion, $font, $HotkeyA, $HotkeyB, $GUIMsg, $Title_test, $Text_test, $Title
DIM $web_1, $web_2,$web_3,$web_4,$web_5,$web_6,$web_7,$web_8
DIM $web_9, $web_10,$web_11,$web_12,$web_13
;---------------------------------------------------------------------------
;dim section that controls button position
dim $iniread_0, $iniread_1, $iniread_2, $iniread_3, $iniread_4, $iniread_5 
dim $iniread_6, $iniread_7, $iniread_8, $iniread_9, $iniread_10, $iniread_11
dim $stringLen_1, $stringLen_2, $stringLen_3, $stringLen_4, $stringLen_5
dim $stringLen_1L, $stringLen_2L, $stringLen_3L, $stringLen_4L, $stringLen_5L
dim $btn_pos1, $btn_pos2, $btn_pos3, $btn_pos4, $btn_pos5
dim $btn_pos1a, $btn_pos2a, $btn_pos3a, $btn_pos4a, $btn_pos5a
dim $lenth_GUI, $handle
;----------------------------------------------------------------------------
; websites and other text data
$web_1 = "Microsoft Internet Explorer"
$web_2 = "http://atlnotes3.suntrust.com"
$web_3 = "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://atlnotes3.suntrust.com/suntrack/servicerequest.nsf/WebWelcome?OpenPage&Login"
$web_4 = "http://atlnotes3.suntrust.com/suntrack/servicerequest.nsf/WebWelcome?OpenPage&Login"
$web_5 = "Unicenter ServicePlus Service Desk"
$web_6 = "http://usdp/CAisd/pdmweb.exe"
$web_7 = "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe"
$web_8 = "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://etiportal.suntrust.com/sites/CTS/CTS%20Document%20Repository%20%20Under%20Construction/Forms/AllItems.aspx?RootFolder=%2fsites%2fCTS%2fCTS%20Document%20Repository%20%20Under%20Construction%2fU%20%2d%20V%2fUnicenter%20Service%20Desk&View=%7b55E1874A%2dF8A6%2d4BF0%2dBE11%2dD391D52F8E2A%7d"
$web_9 = "Internet Explorer_Server1"
$web_10 = "Request Detail - Unicenter ServicePlus Service Desk"
$web_11 = "Unicenter ServicePlus Service Desk - Request Search"
$web_12 = "Unicenter ServicePlus Service Desk - Incident Search"
$web_13 = "Unicenter ServicePlus Service Desk - Change Order Search"
;----------------------------------------------------------------------------
$current = "12:00:00 AM"
$font="Arial"
;----------------------------------------------------------------------------
If WinExists("Unicenter Toolbar") Then Exit; UNPlus already running
;----------------------------------------------------------------------------
_buttonposition() ;to calculate the toolbar button positions before the GUI is drawn.
_iniread1() ;To declair all variables set by INI file
;----------------------------------------------------------------------------
;Checks to see if SR system is running
If WinExists($web_1, $web_2) == 0 Then 
    Run($web_3, "")     
    WinWaitActive($web_4, "")
    sleep(300)
endif
;----------------------------------------------------------------------------
;Checks to see if Unicenter system is running
If WinExists($web_5, $web_6) == 0 Then
    Run( $web_7, "")
    WinWaitActive($web_5, $web_6, 20)
    sleep(3000)
EndIf
If WinExists($web_5, $web_6) == 1 Then
    WinActivate($web_5, $web_6)
EndIf
;---------------------------------------------------------------------------------- 
;These hotsetkeys will always be active. This is due to the nature of the function.
;$HotkeyA = HotKeySet($iniread_0, "_quickpaste");QuickPaste ;remarked out for debugging
$HotkeyB = HotKeySet("^!x", "_exit");exit this script only - clrl + alt + x
;----------------------------------------------------------------------------------
$ClientPos = ControlGetPos($web_5, $web_6, $web_9)
$xa = $ClientPos[0]
$ya = $ClientPos[1]
;WinWait("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") ;Remarked out for testing
$GUI2 = WinGetHandle($web_5, $web_6)
;===================================================================================================
$xx = $lenth_GUI ;350  ;width
$yy = 54
$GUI1 = GUICreate("Unicenter Toolbar", $xx, $yy, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW, $GUI2)
GUISetFont(8.5, 900, "", $font, $GUI1)
$Btn_1 = _GuiCtrlCreateButton (1, "Exit", 0, 0, 60, 18, 0x000000, 0xFF0000)
$Btn_2 = _GuiCtrlCreateButton (1, "Options", 0, 19, 60, 18, 0x800080, 0xFFF000)
$Btn_3 = _GuiCtrlCreateButton (1, "Help", 0, 38, 60, 17, 0x800080, 0xFFF000)
$Btn_4 = _GuiCtrlCreateButton (1, "Problem board", 61, 0, 109, 18, 0x800080, 0x00ffff)
$Btn_5 = _GuiCtrlCreateButton (1, "SS Web", 61, 19, 50, 18, 0x800080, 0x00ffff)
$Btn_6 = _GuiCtrlCreateButton (1, "CTS Web", 112, 19, 58, 18, 0x800080, 0x00ffff)
$Btn_7 = _GuiCtrlCreateButton (1, "Refresh", 61, 38, 50, 17, 0x800080, 0x00ffff)
GUICtrlSetFont($Btn_7, 8.4, 900, "", $font)
$Btn_8 = _GuiCtrlCreateButton (1, "Contacts", 112, 38, 58, 17, 0x800080, 0x00ffff)
if $iniread_6 = "yes" then 
    $Btn_9 = _GuiCtrlCreateButton (2, "Request"&@CRLF& $iniread_1, $btn_pos1a, 0,$stringLen_1L, 27, 0x00ffff, 0x800000, False)
    $Btn_10 = _GuiCtrlCreateButton (2, "Incident"&@CRLF& $iniread_1, $btn_pos1a, 27,$stringLen_1L, 27, 0x00ffff, 0x800000, False)
    GUICtrlSetFont($Btn_9, 8, 900, "", $font)
    GUICtrlSetFont($Btn_10, 8, 900, "", $font)
endif   
if $iniread_7 = "yes" then 
    $Btn_11 = _GuiCtrlCreateButton (2, "Request"&@CRLF& $iniread_2, $btn_pos2a, 0,$stringLen_2L, 27, 0x00ffff, 0x800000, False)
    $Btn_12 = _GuiCtrlCreateButton (2, "Incident"&@CRLF& $iniread_2, $btn_pos2a, 27,$stringLen_2L, 27, 0x00ffff, 0x800000, False)
    GUICtrlSetFont($Btn_11, 8, 900, "", $font)
    GUICtrlSetFont($Btn_12, 8, 900, "", $font)
endif   
if $iniread_8 = "yes" then 
    $Btn_13 = _GuiCtrlCreateButton (2, "Request"&@CRLF& $iniread_3, $btn_pos3a, 0,$stringLen_3L, 27, 0x00ffff, 0x800000, False)
    $Btn_14 = _GuiCtrlCreateButton (2, "Incident"&@CRLF& $iniread_3, $btn_pos3a, 27,$stringLen_3L, 27, 0x00ffff, 0x800000, False)
    GUICtrlSetFont($Btn_13, 8, 900, "", $font)
    GUICtrlSetFont($Btn_14, 8, 900, "", $font)
endif
if $iniread_9 = "yes" then 
    $Btn_15 = _GuiCtrlCreateButton (2, "Request"&@CRLF& $iniread_4, $btn_pos4a, 0,$stringLen_4L, 27, 0x00ffff, 0x800000, False)
    $Btn_16 = _GuiCtrlCreateButton (2, "Incident"&@CRLF& $iniread_4, $btn_pos4a, 27,$stringLen_4L, 27, 0x00ffff, 0x800000, False)
    GUICtrlSetFont($Btn_15, 8, 900, "", $font)
    GUICtrlSetFont($Btn_16, 8, 900, "", $font)
endif
if $iniread_10 = "yes" then 
    $Btn_17 = _GuiCtrlCreateButton (2, ""&@CRLF& "Change Order"&@CRLF& $iniread_5, $btn_pos5a, 0,$stringLen_5L, 54, 0x000000, 0x00ff00, False)
    GUICtrlSetFont($Btn_17, 8.5, 900, "", $font)
endif

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUIRegisterMsg($WM_DRAWITEM, "MY_WM_DRAWITEM")
;GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") 
GUISetState(@SW_SHOW, $GUI1)
WinActivate($web_5, $web_6)
While 1
;~  sleep(1)
;~     $GUIMsg = GUIGetMsg()
    $Title_test = WinGetTitle("")
    $Text_test = WinGetText($Title_test)    
;~  Switch $GUIMsg
;~         Case $GUI_EVENT_CLOSE
;~                 ExitLoop
;~  EndSwitch
;if $GUIMsg = $GUI_EVENT_CLOSE then Exitloop
    _ToolbarDocked()
;~         Select        
;~             Case _NowTime() = $current
;~                 Exit
;~             Case StringInStr($Title_test, $web_5) <> 0
;~                 Select
;~                     Case StringInStr($Title_test, $web_10) <> 0  ;request detail
;~                         $Title = _CheckProcess($web_10)
;~                         _USD_detail()
;~                     Case StringInStr($Title_test, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0
;~                         $Title = _CheckProcess("Incident Detail - Unicenter ServicePlus Service Desk")
;~                         _USD_detail()
;~                     Case StringInStr($Title_test, "Problem Detail - Unicenter ServicePlus Service Desk") <> 0
;~                         $Title = _CheckProcess("Problem Detail - Unicenter ServicePlus Service Desk")
;~                         _USD_detail()
;~                 EndSelect   
;~                 ContinueLoop
;~                  Case Else
;~                  ;;;;
;~         EndSelect   
    
WEnd
#cs - this section remarked out to save original settings.
While 1
    $GUIMsg = GUIGetMsg()
    $Title_test = WinGetTitle("")
    $Text_test = WinGetText($Title_test)    
        Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
                ExitLoop
    EndSwitch
    _ToolbarDocked()
        Select              
            Case _NowTime() = $current
                Exit
            Case StringInStr($Title_test, "Unicenter ServicePlus Service Desk") <> 0
                Select
                    Case StringInStr($Title_test, "Request Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Request Detail - Unicenter ServicePlus Service Desk")
                        _USD_detail()
                    Case StringInStr($Title_test, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Incident Detail - Unicenter ServicePlus Service Desk")
                        _USD_detail()
                    Case StringInStr($Title_test, "Problem Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Problem Detail - Unicenter ServicePlus Service Desk")
                        _USD_detail()   
                    Case StringInStr($Title_test, "Update Incident - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Update Incident - Unicenter ServicePlus Service Desk")
                        _win4_func()
                EndSelect
                ContinueLoop
            Case Else
                ;;;;
        EndSelect   
    
WEnd
#ce
Func _ToolbarDocked()
    $p_win1 = WinGetPos($GUI1);parent
    $p_win2 = WinGetPos($GUI2);toolbar
    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 + 4)
            $y2 = $y1 - ($ya + 25)
            WinMove($GUI2, "", $x2+1, $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 + 4)
            $y1 = $y2 + ($ya + 25)
            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
            $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
            $y1 = $p_win2[1] - $p_win1[3]
            WinMove($GUI1, "", $x1, $y1)
        EndIf
    EndIf

EndFunc   ;==>_ToolbarDocked

Func _Exit()
;~  Sleep(10)
;~  WinActivate("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe")
;~  Sleep(10)
;~  Send("{F10}")
;~  Sleep(1000)
;sleep(1)
    Exit
EndFunc   ;==>_Exit
Func _option()
    MsgBox(0, "", "option button pushed") ; currently set for devolopment work
    ;Run("UNOption.exe")
EndFunc   ;==>_option
Func _msg1()
    MsgBox(0, "", "help button pushed") ; currently set for devolopment work
EndFunc   ;==>_option
Func _USD() 
    Run($web_8, "")
EndFunc   ;==>_USD

Func Button_Click(ByRef $ctrl_id)
    Switch $ctrl_id
    Case $Btn_1  ;exit
         WinActivate($web_5, $web_6)
        _exit()
#cs     
    Case $Btn_2  ;option
         WinActivate($web_5, $web_6)
        _option()   
    Case $Btn_3  ;help
        WinActivate($web_5, $web_6)
        _msg1()
    Case $Btn_4
        sleep(1)
        Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://solutioncenter-app.suntrust.com/internal/WebBoards/problemboard.asp", "") 
    Case $Btn_5
        Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://solutioncenter.suntrust.com/internal/", "")   
    Case $Btn_6
        Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://etiportal.suntrust.com/sites/CTS/default.aspx", "")   
    Case $Btn_7
        WinActivate($web_5, $web_6)
        _F5B_Func()
    Case $Btn_8
        Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://solutioncenter.suntrust.com/Internal/Documents/SC_Info/Key_Contacts/SolutionCenterContactPhoneList.pdf", "")      
    Case $Btn_9
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 1", "not found")
        _F2_Func()  
    Case $Btn_10
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 1", "not found")       
        _F3_Func()  
    Case $Btn_11
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 2", "not found")
        _F2_Func()  
    Case $Btn_12
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 2", "not found")       
        _F3_Func()  
    Case $Btn_13
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 3", "not found")
        _F2_Func()  
    Case $Btn_14
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 3", "not found")       
        _F3_Func()  
    Case $Btn_15
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 4", "not found")
        _F2_Func()  
    Case $Btn_16
        WinActivate($web_5, $web_6)
        $handle = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 4", "not found")       
        _F3_Func()      
    Case $Btn_17
        WinActivate($web_5, $web_6)
        _F3b_Func()     
#ce         
EndSwitch
EndFunc 

Func _buttonposition()
    _iniread1()
    ; checks string lenth from inireads 1 thru 5
$stringLen_1 = StringLen ($iniread_1)
$stringLen_2 = StringLen ($iniread_2)
$stringLen_3 = StringLen ($iniread_3)
$stringLen_4 = StringLen ($iniread_4)
$stringLen_5 = StringLen ($iniread_5)

; calculates width of button needed to accomidate text in button
if $stringLen_1 <= 10 then $stringLen_1L = 30+($stringLen_1 * 5.8)
if $stringLen_1 > 10 then 
    if $stringLen_1 <= 15 then $stringLen_1L = 20+($stringLen_1 * 5.8)  
endif       
if $stringLen_1 > 15 then 
    if $stringLen_1 <= 30 then $stringLen_1L = 15+($stringLen_1 * 5.8)  
    if $stringLen_1 > 30 then $stringLen_1L = 15+($stringLen_1 * 5.8)
    endif
    
if $stringLen_2 <= 10 then $stringLen_2L = 30+($stringLen_2 * 5.8)
if $stringLen_2 > 10 then 
    if $stringLen_2 <= 15 then $stringLen_2L = 20+($stringLen_2 * 5.8)  
endif       
if $stringLen_2 > 15 then 
    if $stringLen_2 <= 30 then $stringLen_2L = 15+($stringLen_2 * 5.8)
    if $stringLen_2 > 30 then $stringLen_2L = 15+($stringLen_2 * 5.8)
    endif   

if $stringLen_3 <= 10 then $stringLen_3L = 30+($stringLen_3 * 5.8)
if $stringLen_3 > 10 then 
    if $stringLen_3 <= 15 then $stringLen_3L = 20+($stringLen_3 * 5.8)  
endif       
if $stringLen_3 > 15 then 
    if $stringLen_3 <= 30 then $stringLen_3L = 15+($stringLen_3 * 5.8)
    if $stringLen_3 > 30 then $stringLen_3L = 15+($stringLen_3 * 5.8)       
    endif
    
if $stringLen_4 <= 10 then $stringLen_4L = 30+($stringLen_4 * 5.8)
if $stringLen_4 > 10 then 
    if $stringLen_4 <= 15 then $stringLen_4L = 20+($stringLen_4 * 5.8)  
endif       
if $stringLen_4 > 15 then 
    if $stringLen_4 <= 30 then $stringLen_4L = 15+($stringLen_4 * 5.8)  
    if $stringLen_4 > 30 then $stringLen_4L = 10+($stringLen_4 * 5.8)
    endif   
    
if $stringLen_5 <= 10 then $stringLen_5L = 50+($stringLen_5 * 5.8)
if $stringLen_5 > 10 then 
    if $stringLen_5 <= 15 then $stringLen_5L = 40+($stringLen_5 * 5.8)  
endif       
if $stringLen_5 > 15 then 
    if $stringLen_5 <= 30 then $stringLen_5L = 15+($stringLen_5 * 5.8)
    if $stringLen_5 > 30 then $stringLen_5L = 10+($stringLen_5 * 5.8)   
    endif
; Checks to see if button is enabled. If not enabled, width of button is 0
if $iniread_6 = "yes" then 
    $btn_pos1 = $stringLen_1L
else    
    $btn_pos1 = "0"
EndIf

if $iniread_7 = "yes" then 
    $btn_pos2 = $stringLen_2L
else    
    $btn_pos2 = "0"
EndIf

if $iniread_8 = "yes" then 
    $btn_pos3 = $stringLen_3L
else    
    $btn_pos3 = "0"
EndIf

if $iniread_9 = "yes" then 
    $btn_pos4 = $stringLen_4L
else    
    $btn_pos4 = "0"
EndIf

if $iniread_10 = "yes" then 
    $btn_pos5 = $stringLen_5L
else    
    $btn_pos5 = "0"
EndIf

$lenth_GUI = 170 + $btn_pos1 + $btn_pos2 + $btn_pos3 + $btn_pos4 + $btn_pos5
$btn_pos1a = 171
$btn_pos2a = 171 + $btn_pos1 
$btn_pos3a = 171 + $btn_pos1 + $btn_pos2 
$btn_pos4a = 171 + $btn_pos1 + $btn_pos2 + $btn_pos3 
$btn_pos5a = 171 + $btn_pos1 + $btn_pos2 + $btn_pos3 + $btn_pos4 
EndFunc

func _iniread1()
    $iniread_0 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "key", "{" & "F6" & "}")
    $iniread_1 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 1", "not found")
    $iniread_2 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 2", "not found")
    $iniread_3 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 3", "not found")
    $iniread_4 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 4", "not found")
    $iniread_5 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 5", "not found")
    $iniread_6 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "enable 1", "not found")
    $iniread_7 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "enable 2", "not found")
    $iniread_8 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "enable 3", "not found")
    $iniread_9 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "enable 4", "not found")
    $iniread_10 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "enable 5", "not found")
    $iniread_11 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "enable 6", "not found")
EndFunc 

Func _F2_Func(); Search Request
    local $g, $aa, $clip, $info, $bb
    If WinExists($web_1, "[239] Sorry, your session has timed out.") Then
        WinActivate($web_1, "[239] Sorry, your session has timed out.")
    EndIf
    
    ControlSend($web_5, "", $web_9, "!e", 0)
    Sleep(5)
    ControlSend($web_5, "", $web_9, "r", 0)
    WinWaitActive( $web_6, "Opening", 1)
    Sleep(200)
    WinWaitActive($web_11, "Done", 1)
    WinWaitActive($web_11, "j", 1)
    WinWaitActive($web_11, "Done", 1)   
    Sleep(1000)
    ;BlockInput(1) ;remarked out for testing
    ControlSend($web_11, "", $web_9, "{TAB}", 0)
    Sleep(35)
    ControlSend($web_11, "", $web_9, "{RIGHT}", 0)
    Sleep(35)
    ControlSend($web_11, "", $web_9, "{RIGHT}", 0)
    _F2_chk1()
    $g = 1
    While 2
        $g = $g + 1
        if $handle = $iniread_1 then $aa = StringLen($iniread_1)
        if $handle = $iniread_2 then $aa = StringLen($iniread_2)
        if $handle = $iniread_3 then $aa = StringLen($iniread_3)
        if $handle = $iniread_4 then $aa = StringLen($iniread_4)    
        $clip = ClipGet()
        $info = String($clip)
        $bb = StringLen($info)
        Select
            Case $aa = $bb
                ExitLoop
            Case $g = 10
                ExitLoop
            Case Else
                Send("{BACKSPACE}")
                _F2_chk1()
                ContinueLoop
        EndSelect
    WEnd
    Sleep(5)
    ControlSend($web_11, "", $web_9, "!s", 0)
    ;BlockInput(0) ;remarked out for testing
    
EndFunc   ;==>_F2_Func

Func _F2_chk1()

    if $handle = $iniread_1 then 
        Send($iniread_1)
        sleep(1)
    endif   
    if $handle = $iniread_2 then 
        Send($iniread_2)
        sleep(1)
    endif   
    if $handle = $iniread_3 then 
        Send($iniread_3)
        sleep(1)
    endif   
    if $handle = $iniread_4 then 
        Send($iniread_4)
        sleep(1)
    endif   
    ClipPut("")
    Send("^a")
    Sleep(10)
    Send("^c")
    Sleep(10)
    Send("^c")
EndFunc   ;==>_F2_chk1 

Func _F3_Func(); Search Incident
    local $g, $aa, $clip, $info, $bb
    If WinExists($web_1, "[239] Sorry, your session has timed out.") Then
        WinActivate($web_1, "[239] Sorry, your session has timed out.")
    EndIf   
    
    ControlSend($web_5, "", $web_9, "!e", 0)
    Sleep(5)
    ControlSend($web_5, "", $web_9, "i", 0)
    WinWait( $web_5, "Opening", 1)
    Sleep(200)
    WinWait( $web_12, "Done", 3)
    Sleep(500)
    BlockInput(1)
    ControlSend( $web_12, "", $web_9, "{RIGHT}", 0)
    Sleep(35)
    ControlSend( $web_12, "", $web_9, "{RIGHT}", 0)
    _F2_chk1()
    $g = 1
    While 2
        $g = $g + 1
        if $handle = $iniread_1 then $aa = StringLen($iniread_1)
        if $handle = $iniread_2 then $aa = StringLen($iniread_2)
        if $handle = $iniread_3 then $aa = StringLen($iniread_3)
        if $handle = $iniread_4 then $aa = StringLen($iniread_4)
        Sleep(5)
        Send("^c")
        Sleep(5)
        Send("^c") ;this allows for error. Sometimes this fails, so it is done twice for safety.
        $clip = ClipGet()
        $bb = StringLen(String($clip))  
        Select
            Case $aa = $bb
                ExitLoop
            Case $g = 10
                ExitLoop
            Case Else
                _F2_chk1()
                ContinueLoop
        EndSelect
    WEnd
    Sleep(5)
    ControlSend( $web_12, "", $web_9, "!s", 0)
    BlockInput(0)
EndFunc   ;==>_F3_Func

Func _F3b_Func(); Search Change Order
    local $g, $aa, $clip, $info, $bb
    If WinExists($web_5, "[239] Sorry, your session has timed out.") Then
        WinActivate($web_5, "[239] Sorry, your session has timed out.")
    EndIf
    ControlSend($web_5, "", $web_9, "!e", 0)
    Sleep(5)
    ControlSend($web_5, "", $web_9, "c", 0)
    WinWait($web_5, "Opening", 1)
    Sleep(200)
    WinWait( $web_13, "Done", 1)
    WinWait( $web_13, "j", 1)
    WinWait( $web_13, "Done", 1)
    Sleep(400)
    ControlSend($web_13, "", $web_9, "{RIGHT}", 0)
    Sleep(35)
    ControlSend($web_13, "", $web_9, "{RIGHT}", 0)
    _F3b_chk1()
    $g = 1
    While 2
        $g = $g + 1
        $aa = StringLen($iniread_5)
        Sleep(5)
        Send("^c")
        Sleep(5)
        Send("^c") ;this allows for error. Sometimes this fails, so it is done twice for safety.
        $bb = StringLen(String(ClipGet()))
        Select
            Case $aa = $bb
                ExitLoop
            Case $g = 10
                ExitLoop
            Case Else
                _F3b_chk1()
                ContinueLoop
        EndSelect
    WEnd
    Sleep(5)
    ControlSend($web_13, "",$web_9, "!s", 0)
    Sleep(1000)
    IniWrite("bin\unplus.ini", @UserName, "action", "0")
EndFunc   ;==>_F3b_Func

Func _F3b_chk1()
    local $iniread_5
    $iniread_5 = IniRead(@ScriptDir & "\bin\unplus.ini", @UserName, "search 5", "not found")
    Send($iniread_5)
    ClipPut("")
    Send("^a")
    Sleep(10)
    Send("^c")
    Sleep(5)
    Send("^c") ;this allows for error. Sometimes this fails, so it is done twice for safety.
EndFunc   ;==>_F3b_chk1
;--------------------------

Func _F5B_Func(); Refresh Querry
    If WinExists($web_5, "[239] Sorry, your session has timed out.") Then
        WinActivate($web_5, "[239] Sorry, your session has timed out.")
    Else        
        BlockInput(1)
        Send("!v")
        Sleep(5)
        Send("!e")
        BlockInput(0)
    EndIf
EndFunc   ;==>_F5B_Func

Func _USD_detail() ;Ticket Detail - Unicenter ServicePlus Service Desk)
;~  HotKeySet("{F1}", "HelpView");turns key on for help  ;remarked out for testing
;~  HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket
;~  HotKeySet("{PRINTSCREEN}", "print_ticket"); Print ticket
    Do
        Sleep(10)
    Until Not WinActive("Detail - Unicenter ServicePlus Service Desk") ;$sTitle) ;)
    _key_clean_1()
EndFunc   ;==>_win1_func

Func _win4_func() ;Update Incident - Unicenter ServicePlus Service Desk)
;~  HotKeySet("{F1}", "HelpView");turns key on for help
;~  HotKeySet("{F4}", "_TreePaste");turns key on for TreePaste
;~  HotKeySet("{F9}", "_TimeStamp");Turns on key for TimeStamp
    Do
        Sleep(10)
    Until Not WinActive("Update Incident - Unicenter ServicePlus Service Desk") ;$sTitle)  ;
    _key_clean_1()
EndFunc   ;==>_win4_func

Func _key_clean_1() ;Releases hotsetkeys
    HotKeySet("{F1}"); turns help off
    HotKeySet("{F2}"); turns Request off
    HotKeySet("{F3}"); turns Incident off
    HotKeySet("{F4}"); turns TreePaste off
    HotKeySet("{F5}"); turns refresh off
    HotKeySet("{F8}"); turns Resolution off
    HotKeySet("{F9}"); turns TimeStamp off
    HotKeySet("{PRINTSCREEN}"); Turns Print ticket off
EndFunc   ;==>_key_clean_1
Link to comment
Share on other sites

Well since you're obviously not showing the entire script that replicates the issue (because the above doesn't on my machine), all we can do is speculate along with you :lmao:.

I was in the process of chopping everything out to make it more manageable before I posted it. Sorry for the delay.

Edit: The program is working fine, except for the hunger issue. One will need the guibutton.au3 from GaFrost. I use a slight varient of his that allows for multiline on the buttons. I think for testing it shouldn't make a difference.

Edited by vollyman
Link to comment
Share on other sites

  • Moderators

Well the easiest way I can see to debug it since you have so many functions doing so much within themselves, is to comment out line by line.

First I would start with commenting out ;_ToolBarDocked() and monitor the process usage... Then I'd uncomment that if not satisfied, and take out this entire section :

Case StringInStr($Title_test, "Unicenter ServicePlus Service Desk") <> 0
                Select
                    Case StringInStr($Title_test, "Request Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Request Detail - Unicenter ServicePlus Service Desk")
                        _USD_detail()
                    Case StringInStr($Title_test, "Incident Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Incident Detail - Unicenter ServicePlus Service Desk")
                        _USD_detail()
                    Case StringInStr($Title_test, "Problem Detail - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Problem Detail - Unicenter ServicePlus Service Desk")
                        _USD_detail()   
                    Case StringInStr($Title_test, "Update Incident - Unicenter ServicePlus Service Desk") <> 0
                        $Title = _CheckProcess("Update Incident - Unicenter ServicePlus Service Desk")
                        _win4_func()
                EndSelect
                ContinueLoop
And see how my cpu usage is from there (which is probably where it lies), then line by line from there (each function call) to see if I can narrow down the specific function that I'd need to work on. This shouldn't take more than 15 minutes I'd think.

Edit:

BTW, except for startup, with how you have it setup with all the comments, I had 0 cpu usage.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I did a simple loop with the following code and ran it by itself. THe CPU time was 25

while 1
    $Title_test = WinGetTitle("")
WEnd

I think I know the problem, but the solution is another matter. I need a way to detect about 30 different windows without pegging the processor to its knees. I know I've discussed this before, but I still don't have a stable solution.

Edited by vollyman
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...