Sign in to follow this  
Followers 0
Herb191

Slow button response

8 posts in this topic

This script works but it is vary slow. Three buttons work almost immediately (next, previous and ok) but the other buttons labeled BookSelcitonOption1-4 take forever to work. I’m not sure why. Any suggestions would be appreciated.

Thanks

P.S.

I just coped this script out of my main program and made a few changes so there are some extra variables

that aren’t used in this part of script.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>;
#include <GuiImageList.au3>




_Scanoutgui()

Func _Scanoutgui()
    Global $Record,$BarCodeNumber, $BookEntrySpot, $BookEntrySpot, $BookNumber, $TextToCount, $TextToCount, $TextCharacterCounter
    Global  $ScanningOutOfWAREHOUSE, $ScanningOutOfREPAIR, $ScanningOutOfSTORE, $font, $DisplayEntry, $TEXT, $DisplayTotals
                        

Local $Next, $Previous, $BookToScanOutwin, $a, $Checkoutput, $OutputCounter, $b, $destination
Local $output2, $msg, $results, $Okbutton, $outputTitle1, $OutputT1, $OutputListPrice
Local $OutputListPrice1, $OutputConditionOfBook1, $OutputAssingmentNumber1
Local $OutputListPrice2, $OutputConditionOfBook2, $OutputAssingmentNumber2
Local $OutputListPrice3, $OutputConditionOfBook3, $OutputAssingmentNumber3
Local $OutputListPrice3, $OutputConditionOfBook3, $OutputAssingmentNumber4
Local $BookSelectionOption1,$BookSelectionOption2, $BookSelectionOption3, $BookSelectionOption4 
Local $Message1
Local $hImage, $hDC
                    
                
$Bookinfo = @ScriptDir & "\Bookinfo.ini"
$BookEntrySpot = "40"

$BookToScanOutwin = GUICreate("Book to scan out", 900, 600, -1, -1, -1, $WS_EX_TOPMOST)

                    $BookToScanOutwin_Pos = WinGetPos($BookToScanOutwin, "")
                    GUISetState(@SW_SHOW)
                    
                    $CopesOfBooksInWarehouse = IniRead($Bookinfo, $BookEntrySpot, "CopesOfBooksInWarehouse", "0")
                    
                        $a = 0
                        $b = 0
                        While 1
                            $Checkoutput = IniRead($Bookinfo, $BookEntrySpot, "WarehouseBook " & $a & "Assignment Number", "Error")
                            Select
;Checks to make sure loop has not gone though all off the books in the ini file. If it has it will exit loop.                           
                                Case $Checkoutput = ("Error")
                                    If $CopesOfBooksInWarehouse < $b Then ExitLoop
                                Case Else
                                    $b = $b + 1 ;keeps track of books found
                                    Select
                                        Case $OutputAssingmentNumber1 = ("")
                                            $OutputAssingmentNumber1 = IniRead($Bookinfo, $BookEntrySpot, "WarehouseBook " & $a & "Assignment Number", "Error")
                                            $OutputListPrice1 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "LIST PRICE" & $a, "Error")
                                            $OutputConditionOfBook1 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "ConditionOfBook" & $a, "Error")

;Displays book 1 info on gui                    
                                            GUISetFont(20, 1000, "", $font)
                                            $OutputT1 = IniRead($Bookinfo, $BookEntrySpot, "Title", "Error")
                                            $OutputTitle1 = GUICtrlCreateLabel($OutputT1, 5, 5, 300, 70)    
                                            GUICtrlCreateLabel("Assingment Number", 5, 35, 500, 70)
                                            $OutputAssingmentNumber1 = GUICtrlCreateLabel($outputAssingmentNumber1, 400, 35, 300, 70)
                                            GUICtrlCreateLabel("Condition Of Book", 5, 65, 500, 70)
                                            $OutputConditionOfBook1 = GUICtrlCreateLabel($OutputConditionOfBook1, 400, 65, 300, 70)
                                            GUICtrlCreateLabel("List Price", 5, 95, 500, 70)
                                            $OutputListPrice1 = GUICtrlCreateLabel($OutputListPrice1, 400, 95, 300, 70)
                
                                            GUICtrlSetFont( -1, 20, 800, "", $font)
                                            GUICtrlSetFont($outputTitle1, 20, 800, "", $font)
                                            GUICtrlSetFont($outputAssingmentNumber1, 20, 800, "", $font)
;Load images to put under book 1
                                            $hImage = _GUIImageList_Create(900, 4)
                                            _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($BookToScanOutwin, 000000, 900, 4))

;Draw images to put under book 1
                                            $hDC = _WinAPI_GetDC($BookToScanOutwin)
                                            _GUIImageList_DrawEx($hImage, 0, $hDC, 0, 125)
                                            _WinAPI_ReleaseDC($BookToScanOutwin, $hDC)

;Displays book 2 info                   
                                        Case $OutputAssingmentNumber2 = ("")
                                            $OutputAssingmentNumber2 = IniRead($Bookinfo, $BookEntrySpot, "WarehouseBook " & $a & "Assignment Number", "Error")
                                            $OutputListPrice2 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "LIST PRICE" & $a, "Error")
                                            $OutputConditionOfBook2 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "ConditionOfBook" & $a, "Error")
                                            
;Displays book 2 info on gui                    
                                            GUISetFont(20, 1000, "", $font)
                                            $OutputT1 = IniRead($Bookinfo, $BookEntrySpot, "Title", "Error")
                                            $outputTitle1 = GUICtrlCreateLabel($OutputT1, 5, 140, 300, 70)  
                                            GUICtrlCreateLabel("Assingment Number", 5, 170, 500, 70)
                                            $outputAssingmentNumber2 = GUICtrlCreateLabel($outputAssingmentNumber2, 400, 170, 300, 70)
                                            GUICtrlCreateLabel("Condition Of Book", 5, 200, 500, 70)
                                            $OutputConditionOfBook2 = GUICtrlCreateLabel($OutputConditionOfBook2, 400, 200, 300, 70)
                                            GUICtrlCreateLabel("List Price", 5, 230, 500, 70)
                                            $OutputListPrice2 = GUICtrlCreateLabel($OutputListPrice2, 400, 230, 300, 70)
;Load images to put under book 2
                                            $hImage = _GUIImageList_Create(900, 4)
                                            _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($BookToScanOutwin, 000000, 900, 4))
;Draw images to put under book 2
                                            $hDC = _WinAPI_GetDC($BookToScanOutwin)
                                            _GUIImageList_DrawEx($hImage, 0, $hDC, 0, 260)
                                            _WinAPI_ReleaseDC($BookToScanOutwin, $hDC)
                                            
                                            
;displays book 3 info                   
                                        Case $OutputAssingmentNumber3 = ("")
                                            $OutputAssingmentNumber3 = IniRead($Bookinfo, $BookEntrySpot, "WarehouseBook " & $a & "Assignment Number", "Error")
                                            $OutputListPrice3 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "LIST PRICE" & $a, "Error")
                                            $OutputConditionOfBook3 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "ConditionOfBook" & $a, "Error")
                                            
;Displays book 3 info on gui                    
                                            GUISetFont(20, 1000, "", $font)
                                            $OutputT1 = IniRead($Bookinfo, $BookEntrySpot, "Title", "Error")
                                            $OutputTitle1 = GUICtrlCreateLabel($OutputT1, 5, 275, 300, 70)  
                                            GUICtrlCreateLabel("Assingment Number", 5, 305, 500, 70)
                                            $OutputAssingmentNumber3 = GUICtrlCreateLabel($OutputAssingmentNumber3, 400, 305, 300, 70)
                                            GUICtrlCreateLabel("Condition Of Book", 5, 335, 500, 70)
                                            $OutputConditionOfBook3 = GUICtrlCreateLabel($OutputConditionOfBook3, 400, 335, 300, 70)
                                            GUICtrlCreateLabel("List Price", 5, 365, 500, 70)
                                            $OutputListPrice3 = GUICtrlCreateLabel($OutputListPrice3, 400, 365, 300, 70)
; Load images to put under book 3
                                            $hImage = _GUIImageList_Create(900, 4)
                                            _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($BookToScanOutwin, 000000, 900, 4))
; Draw images to put under book 3
                                            $hDC = _WinAPI_GetDC($BookToScanOutwin)
                                            _GUIImageList_DrawEx($hImage, 0, $hDC, 0, 395)
                                            _WinAPI_ReleaseDC($BookToScanOutwin, $hDC)
                    
;displays book 4 info                   
                                        Case $OutputAssingmentNumber4 = ("")
                                            $OutputAssingmentNumber4 = IniRead($Bookinfo, $BookEntrySpot, "WarehouseBook " & $a & "Assignment Number", "Error")
                                            $OutputListPrice4 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "LIST PRICE" & $a, "Error")
                                            $OutputConditionOfBook4 = IniRead($Bookinfo, $BookEntrySpot, "Warehouse" & "ConditionOfBook" & $a, "Error")
                                            
;Displays book 4 info on gui                    
                                            GUISetFont(20, 1000, "", $font)
                                            $OutputT1 = IniRead($Bookinfo, $BookEntrySpot, "Title", "Error")
                                            $OutputTitle1 = GUICtrlCreateLabel($OutputT1, 5, 410, 300, 70)  
                                            GUICtrlCreateLabel("Assingment Number", 5, 440, 500, 70)
                                            $OutputAssingmentNumber4 = GUICtrlCreateLabel($OutputAssingmentNumber4, 400, 440, 300, 70)
                                            GUICtrlCreateLabel("Condition Of Book", 5, 470, 500, 70)
                                            $OutputConditionOfBook4 = GUICtrlCreateLabel($OutputConditionOfBook4, 400, 470, 300, 70)
                                            GUICtrlCreateLabel("List Price", 5, 500, 500, 70)
                                            $OutputListPrice4 = GUICtrlCreateLabel($OutputListPrice4, 400, 500, 300, 70)
; Load images to put under book 4
                                            $hImage = _GUIImageList_Create(900, 4)
                                            _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($BookToScanOutwin, 000000, 900, 4))
; Draw images to put under book 4
                                            $hDC = _WinAPI_GetDC($BookToScanOutwin)
                                            _GUIImageList_DrawEx($hImage, 0, $hDC, 0, 530)
                                            _WinAPI_ReleaseDC($BookToScanOutwin, $hDC)                  
                                    EndSelect   
                            EndSelect
                                
                            
                            If $OutputCounter = $CopesOfBooksInWarehouse Then ExitLoop
                            $a = ($a + 1)
                        WEnd

;Displays messages on gui 
                    $Message1 = GUICtrlCreateLabel("Please select the book you are scanning out and press ok", 565, 10, 300, 70)
                    GUICtrlSetFont($Message1, 13, 800, "", $font)
                    GUICtrlSetColor(-1, 0xFF0000)

;Displays next pevious and ok button as well as resting the button font
                    
                    GUISetFont(10, 800, "", $font)
                    $Next = GUICtrlCreateButton("Next", 5, 560, 50, 30)
                    $Previous = GUICtrlCreateButton("Previous", 65, 560, 70, 30)
                    $Okbutton = GUICtrlCreateButton("Ok", 800, 560, 70, 30)
    
;Displays "SELECT"  buttons 
                    $BookSelectionOption1 = GUICtrlCreateButton("SELECT", 565, 85, 300, 30)
                    $BookSelectionOption2 = GUICtrlCreateButton("SELECT", 565, 220, 300, 30)
                    $BookSelectionOption3 = GUICtrlCreateButton("SELECT", 565, 355, 300, 30)
                    $BookSelectionOption4 = GUICtrlCreateButton("SELECT", 565, 490, 300, 30)
                    
                    GUISetState()

; Run the GUI until the dialog is closed
                    While 1
                        $msg = GUIGetMsg()
                            Select
                                        
                                Case $msg = $Next
                                    MsgBox(4096, "", "Next")
                                    GUIDelete()
                                    ExitLoop
                                Case $msg = $Previous
                                    MsgBox(4096, "", "Perevious")
                                    GUIDelete()
                                    ExitLoop
                                    
                                Case $msg = $BookSelectionOption1
                                    GUICtrlSetColor ($BookSelectionOption1, 0xFF0000)
                                Case $msg = $BookSelectionOption2
                                    GUICtrlSetColor ($BookSelectionOption2, 0xFF0000)
                                Case $msg = $BookSelectionOption3
                                    GUICtrlSetColor ($BookSelectionOption3, 0xFF0000)
                                Case $msg = $BookSelectionOption4
                                    GUICtrlSetColor ($BookSelectionOption4, 0xFF0000)
                                Case $msg = $GUI_EVENT_CLOSE
                                    GUIDelete()
                                    ExitLoop
                                    Case $msg = $Okbutton
                                    MsgBox(4096, "", "ok")
                                    GUIDelete()
                                    ExitLoop
                            EndSelect   
                            
                    WEnd
            
EndFunc

Here is the ini file used in the script:

[40]
Title=Big Bounce
LIST PRICE=7.50    
Numberofcopies=6
StoreLIST PRICE1=7.50

WarehouseConditionOfBook9=VERYGOOD
WarehouseBook 9Assignment Number=B112
WarehouseBookTrackerNumber131=131
WarehouseLIST PRICE10=7.50

WarehouseConditionOfBook10=VERYGOOD
WarehouseBook 10Assignment Number=B113
WarehouseBookTrackerNumber132=132
WarehouseLIST PRICE11=7.50

WarehouseConditionOfBook11=VERYGOOD
WarehouseBook 11Assignment Number=B114
WarehouseBookTrackerNumber133=133
WarehouseLIST PRICE12=7.50


WarehouseConditionOfBook20=VERYGOOD
WarehouseBook 20Assignment Number=B123
WarehouseBookTrackerNumber142=142
WarehouseLIST PRICE21=7.50

WarehouseConditionOfBook21=VERYGOOD
WarehouseBook 21Assignment Number=B124
WarehouseBookTrackerNumber143=143
WarehouseLIST PRICE22=7.50

WarehouseConditionOfBook22=VERYGOOD
WarehouseBook 22Assignment Number=B125
WarehouseBookTrackerNumber144=144
WarehouseLIST PRICE23=7.50

CopesOfBooksInWarehouse=5

Share this post


Link to post
Share on other sites



I don't really see what you mean here. I ran the script and clicked the select buttons and they worked fine. Immediately the text color went to red. So don't get what you mean by "it takes a lot of time".


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

I don't really see what you mean here. I ran the script and clicked the select buttons and they worked fine. Immediately the text color went to red. So don't get what you mean by "it takes a lot of time".

Yes that’s what is suppose to happen when you click on the select buttons. The problem is when I run it there is about a 10 to 20 second delay before clicking on the select buttons do anything. The weird thing is that the other buttons will work immediately.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I still don't understand what you are driving at. The problem u r facing didn't reproduce at my end and it worked without any delays. I am using WinXP pro as my OS

Edited by Manjish

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

@Herb191,

Your problem appears to be that your labels for $OutputAssingmentNumber, $OutputConditionOfBook, & $OutputListPrice are too big and overlapping the left hand sides of the buttons.

To see this, run the Au3Info tool with "Highlight Controls" turned on and use it to examine your GUI.

As it is right now, if you click on the right hand side of a button you will find that things work OK.

But if you click on the left hand side of a button, you aren't actually clicking the button, but rather one of the labels.

Solution: remove the width & height specification when you create those buttons.

You've already specified the font size, so the labels will autosize when created.

(or change width & height so they don't overlap)

GUISetFont(20, 1000, "", $font)
$OutputT1 = IniRead($Bookinfo, $BookEntrySpot, "Title", "Error")
$OutputTitle1 = GUICtrlCreateLabel($OutputT1, 5, 5, 300, 70)
GUICtrlCreateLabel("Assingment Number", 5, 35, 500, 70)
$OutputAssingmentNumber1 = GUICtrlCreateLabel($OutputAssingmentNumber1, 400, 35);, 300, 70)
GUICtrlCreateLabel("Condition Of Book", 5, 65, 500, 70)
$OutputConditionOfBook1 = GUICtrlCreateLabel($OutputConditionOfBook1, 400, 65);, 300, 70)
GUICtrlCreateLabel("List Price", 5, 95, 500, 70)
$OutputListPrice1 = GUICtrlCreateLabel($OutputListPrice1, 400, 95);, 300, 70)

GUICtrlSetFont(-1, 20, 800, "", $font)
GUICtrlSetFont($OutputTitle1, 20, 800, "", $font)
GUICtrlSetFont($OutputAssingmentNumber1, 20, 800, "", $font)

PS: You don't need a GUISetFont(20, 1000, "", $font) statement every time you create a group of controls either.

GuiSetFont( ) is a global change for the whole GUI

Share this post


Link to post
Share on other sites

@Herb191,

Your problem appears to be that your labels for $OutputAssingmentNumber, $OutputConditionOfBook, & $OutputListPrice are too big and overlapping the left hand sides of the buttons.

To see this, run the Au3Info tool with "Highlight Controls" turned on and use it to examine your GUI.

As it is right now, if you click on the right hand side of a button you will find that things work OK.

But if you click on the left hand side of a button, you aren't actually clicking the button, but rather one of the labels.

Solution: remove the width & height specification when you create those buttons.

You've already specified the font size, so the labels will autosize when created.

(or change width & height so they don't overlap)

GUISetFont(20, 1000, "", $font)
$OutputT1 = IniRead($Bookinfo, $BookEntrySpot, "Title", "Error")
$OutputTitle1 = GUICtrlCreateLabel($OutputT1, 5, 5, 300, 70)
GUICtrlCreateLabel("Assingment Number", 5, 35, 500, 70)
$OutputAssingmentNumber1 = GUICtrlCreateLabel($OutputAssingmentNumber1, 400, 35);, 300, 70)
GUICtrlCreateLabel("Condition Of Book", 5, 65, 500, 70)
$OutputConditionOfBook1 = GUICtrlCreateLabel($OutputConditionOfBook1, 400, 65);, 300, 70)
GUICtrlCreateLabel("List Price", 5, 95, 500, 70)
$OutputListPrice1 = GUICtrlCreateLabel($OutputListPrice1, 400, 95);, 300, 70)

GUICtrlSetFont(-1, 20, 800, "", $font)
GUICtrlSetFont($OutputTitle1, 20, 800, "", $font)
GUICtrlSetFont($OutputAssingmentNumber1, 20, 800, "", $font)

PS: You don't need a GUISetFont(20, 1000, "", $font) statement every time you create a group of controls either.

GuiSetFont( ) is a global change for the whole GUI

Thank you Rullius. That’s what it was. Lol I spent hours looking for something in the way I wrote the code. I thought it would be something much more complicated.

Share this post


Link to post
Share on other sites

I still don't understand what you are driving at. The problem u r facing didn't reproduce at my end and it worked without any delays. I am using WinXP pro as my OS

Thanks for taking the time to look at my script. Rullius suggestions worked. :D

Share this post


Link to post
Share on other sites

Thank you Rullius.

No problem Her1

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