Jump to content

List View Gridlines bug?


 Share

Recommended Posts

I thought my script was 100% ready to go, until I noticed something. If you launch the script, the GUI comes up and shows everything w/ grid lines like it is supposed to. If you grab the scroll slider, and drag, everything is fine. however, if you use the scrollbar arrows, the gridlines get all wacky....ideas?

; #INDEX# =======================================================================================================================
; Title .........: Portal Procedure Batch Printer for CGS
; AutoIt Version : 3.3.6.1
; Language ......: English
; Description ...: Batch Printer for Portal program at CGS. Only contains procedures managed at satellite location.
; Author(s) .....: yours truly
; ===============================================================================================================================

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <ButtonConstants.au3>

Opt('MouseCoordMode',0)
Opt('PixelCoordMode',0)
Opt('GUIOnEventMode',1)

HotKeySet('{ESC}','_OnExit')
TraySetIcon('PortalJ_Print.ico')

;Create Array
#region
Dim $aProcedure [112][3] = [ _
        ['1.3.9','PPM','PPI'], _
        ['1.3.10A','PPM','PPI'], _
        ['1.3.10B','PPM','PPI'], _
        ['1.3.10C','PPM','PPI'], _
        ['1.3.27','PPM','PPI'], _
        ['1.3.30','PPM','PPI'], _
        ['1.3.51','PPM','PPI'], _
        ['1.3.56','PPM','PPI'], _
        ['1.3.57','PPM','PPI'], _
        ['1.3.62','PPM','PPI'], _
        ['1.3.64','PPM','PPI'], _
        ['1.3.68','PPM','PPI'], _
        ['1.3.69','PPM','PPI'], _
        ['1.3.76','PPM','PPI'], _
        ['1.4.7','PPM','PPI'], _
        ['1.20.1','PPM','PPI'], _
        ['10.1.13','PPM','PPI'], _
        ['10.1.21','PPM','PPI'], _
        ['10.1.22','PPM','PPI'], _
        ['10.2.7','PPM','PPI'], _
        ['10.2.10','PPM','PPI'], _
        ['10.2.13','PPM','PPI'], _
        ['10.2.14','PPM','PPI'], _
        ['10.2.17','PPM','PPI'], _
        ['10.2.18','PPM','PPI'], _
        ['10.2.23','PPM','PPI'], _
        ['10.2.27','PPM','PPI'], _
        ['10.2.28','PPM','PPI'], _
        ['10.2.29','PPM','PPI'], _
        ['10.2.31','PPM','PPI'], _
        ['10.2.33','PPM','PPI'], _
        ['10.2.34','PPM','PPI'], _
        ['10.2.37','PPM','PPI'], _
        ['10.2.41','PPM','PPI'], _
        ['10.2.47','PPM','PPI'], _
        ['10.2.51','PPM','PPI'], _
        ['10.2.53','PPM','PPI'], _
        ['10.2.79','PPM','PPI'], _
        ['10.2.101','PPM','PPI'], _
        ['10.4.1','PPM','PPI'], _
        ['10.4.2','PPM','PPI'], _
        ['10.4.3','PPM','PPI'], _
        ['10.4.4','PPM','PPI'], _
        ['10.4.10','PPM','PPI'], _
        ['10.4.11','PPM','PPI'], _
        ['10.4.12','PPM','PPI'], _
        ['10.4.14','PPM','PPI'], _
        ['10.23.1','PPM','PPI'], _
        ['10.23.2','PPM','PPI'], _
        ['10.23.4','PPM','PPI'], _
        ['10.24.12','PPM','PPI'], _
        ['10.24.135','PPM','PPI'], _
        ['10.25.19','PPM','PPI'], _
        ['10.25.46','PPM','PPI'], _
        ['10.25.54','PPM','PPI'], _
        ['10.25.55','PPM','PPI'], _
        ['10.25.57','PPM','PPI'], _
        ['10.25.61','PPM','PPI'], _
        ['10.25.78','PPM','PPI'], _
        ['11.2.11.3','PPM','PPI'], _
        ['11.2.15.7','PPM','PPI'], _
        ['11.2.23.4','PPM','PPI'], _
        ['CIVES-5','ENG','PPI'], _
        ['CIVES-6','ENG','PPI'], _
        ['DES-2-1','ENG','PPI'], _
        ['DES-2-2','ENG','PPI'], _
        ['DES-2-7','ENG','PPI'], _
        ['DES-3-1','ENG','PPI'], _
        ['DES-3-2','ENG','PPI'], _
        ['DES-3-3','ENG','PPI'], _
        ['DES-4-1','ENG','PPI'], _
        ['DES-4-2','ENG','PPI'], _
        ['DES-4-12','ENG','PPI'], _
        ['DES-5-2','ENG','PPI'], _
        ['EMS-01','EMS','MAN'], _
        ['ENG-DES-02','ENG','PPI'], _
        ['GEN-RPP-04','PPM','PPI'], _
        ['GEN-RPP-10','PPM','PPI'], _
        ['HPI-0.19','HPI','PPI'], _
        ['ISPM-1','ISPM','PPI'], _
        ['ISPM-2','ISPM','PPI'], _
        ['ISPM-3','ISPM','PPI'], _
        ['ISPM-4','ISPM','PPI'], _
        ['ISPM-5','ISPM','PPI'], _
        ['ISPM-6','ISPM','PPI'], _
        ['ISPM-7','ISPM','PPI'], _
        ['ISPM-8','ISPM','PPI'], _
        ['ISPM-9','ISPM','PPI'], _
        ['ISPM-10','ISPM','PPI'], _
        ['ISPM-11','ISPM','PPI'], _
        ['ISPM-12','ISPM','PPI'], _
        ['ISPM-13','ISPM','PPI'], _
        ['ISPM-14','ISPM','PPI'], _
        ['ISPM-15','ISPM','PPI'], _
        ['ISPM-16','ISPM','PPI'], _
        ['ISPM-17','ISPM','PPI'], _
        ['ISPM-18','ISPM','PPI'], _
        ['ISPM-19','ISPM','PPI'], _
        ['ISPM-20','ISPM','PPI'], _
        ['MI-2.6.1','MAI','PPI'], _
        ['MWP-1','MWP','MAN'], _
        ['MWP-5','MWP','MAN'], _
        ['MWP-7','MWP','MAN'], _
        ['MWP-10','MWP','MAN'], _
        ['MWP-13','MWP','MAN'], _
        ['QCI-2','QCI','PPI'], _
        ['SWP-CHE-05','SWP','PPI'], _
        ['SWP-CM-01','SWP','PPI'], _
        ['SWP-DES-01','SWP','PPI'], _
        ['SWP-OSH-06','SWP','PPI'], _
        ['SWP-OSH-08','SWP','PPI'], _
        ['SWP-TST-01','SWP','PPI'] _
        ]
#endregion

Dim $aProcedureSize = UBound($aProcedure)
;Set Extended Styles
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES,$LVS_EX_GRIDLINES)
;Create GUI
$hWnd = GUICreate('Portal Procedure Printer',400,500)
;Create Buttons
$bPrint = GUICtrlCreateButton('',308,50,80,40,$BS_ICON)
GUICtrlSetImage($bPrint,'shell32.dll',17)
GUICtrlCreateLabel('PRINT',334,90)
$bExit = GUICtrlCreateButton('',308,120,80,40,$BS_ICON)
GUICtrlSetImage($bExit,'shell32.dll',240)
GUICtrlCreateLabel('EXIT',338,160)
;Create Button Events
GUICtrlSetonEvent($bExit,'_OnExit')
GUICtrlSetOnEvent($bPrint,'_Print')
;Create List View and Apply Styles
$hListView = GUICtrlCreateListView('',2,2,294,468)
_GUICtrlListView_SetExtendedListViewStyle($hListView,$exStyles)
;Add columns
_GUICtrlListView_AddColumn($hListView,'Doc Type',70)
_GUICtrlListView_AddColumn($hListView,'Sub Type',70)
_GUICtrlListView_AddColumn($hListView,'Doc No.',134)
;Set colors
_GUICtrlListView_SetBkColor($hListView,$CLR_SKYBLUE)
_GUICtrlListView_SetTextColor($hListView,$CLR_BLACK)
_GUICtrlListView_SetTextBkColor($hListView,$CLR_SKYBLUE)
;Add items and subitems to list view
For $i = 0 to $aProcedureSize -1
    _GUICtrlListView_AddItem($hListView,$aProcedure[$i][2],0)
    _GUICtrlListView_AddSubItem($hListView,$i,$aProcedure[$i][1],1)
    _GUICtrlListView_AddSubItem($hListView,$i,$aProcedure[$i][0],2)
    _GUICtrlListView_AddSubItem($hListView,$i,'TEMPORARY MODIFICATION',3)
Next
;Set GUI Close Event
GUISetOnEvent($GUI_EVENT_CLOSE,'_OnExit')
;Display GUI
GUISetState()

While 1
    Sleep(1000)
WEnd

Func _Print()
GUISetState(@SW_HIDE)
    For $i = 0 to $aProcedureSize -1
        If _GUICtrlListView_GetItemChecked($hListView,$i) Then
            WinActivate('TIM')
            $PortalWait = WinWaitActive('TIM','',5)
                If $PortalWait == 0 Then
                    MsgBox(0,'Error','Portal window not found')
                    GuiSetState(@SW_SHOW)
                    Return
                EndIf
            MouseClick('Left',378,75)
            WinWait('TIMX000 - VENTYX INCORPORATED - [ PAS6 ]')
            MouseClick('Left',421,381)
            WinWait ('TIMMENU - [ PAS6 ]')
            MouseClick('Left',211,110)
            WinWait('TIMC010 - CONT DOC - INFORMATION - [ PAS6 ]')
            MouseClick('Left',119,151)
            Send($aProcedure[$i][2])
            MouseClick('Left',440,151)
            Send($aProcedure[$i][1])
            MouseClick('Left',200,174)
            Send($aProcedure[$i][0])
            Send('{ENTER}')
            ;Check to see if image has loaded
            $ImageColorHex = Hex(PixelGetColor(376,533))
                Do
                    $ImageColorHex = Hex(PixelGetColor(376,533))
                Until $ImageColorHex == '0000FFFF'
            MouseClick('Left',376,533)
            ;IE Download Window
            WinWait('File Download')
            WinActivate('File Download')
            Sleep(500)
            ControlClick('File Download','','[ID:4423]')
            ;Adobe Reader Window
            WinWaitActive('00')
            Sleep(500)
            Send('!{F4}') ;<-- Don't forget to remove after done testing
            #cs
            WinActivate('00')
            $AdobeWait = WinWaitActive('00','',5)
            If $AdobeWait == 0 Then
                    MsgBox(0,'Error','Adobe window not found')
                    GUISetState(@SW_SHOW)
                    Return
                EndIf
            Send('^p')
            ;Printing
            WinWaitActive('Print')
            ControlClick('Print','','Button27')
            WinWait('Progress')
            WinWaitClose('Progress')
            WinActivate('00')
            Sleep(1000)
            Send('!{F4}')
            #CE
        EndIf
    Next
    MsgBox(0,'','Script is finished')
    Exit
EndFunc

Func _OnExit()
    Exit
EndFunc
Link to comment
Share on other sites

  • Moderators

dufran3,

Sorry, it all works fine for me - with slider and arrows. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Dragging the scrollbar is Ok, but when I click on scollbar one window down the lines becomes too small.

I'm afraid you have to thing about a workaround - or swap your PC with Melbas one.

Tested on: WinXP (all updates). New standard business Notebookt.

HTH, Reinhard

Link to comment
Share on other sites

You can use WM_Notify_Events to repaint after a scroll is finished.

HTH, Reinhard

Edit: _WinAPI_RedrawWindow statement not needed after hide/show

Code Snippet:

GUISetState()
...
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
..
While 1
..

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $hListView
            Select
                Case $event = $NM_CLICK
                    Consolewrite(@lf&"LV-Item clicked"&@lf)
                Case $event = $NM_DBLCLK
                    consolewrite(@lf&"LV-Item Doubleclick"&@lf)
                Case $event = $LVN_ENDSCROLL
                    consolewrite(@lf&"Endscroll"&@lf)
                    GUICtrlSetState ( $hlistview,$GUI_Hide)
                    GUICtrlSetState ( $hlistview,$GUI_Show)
                    ;_WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_UPDATENOW)
                    ;_WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_VALIDATE)
                    ;Return $GUI_RUNDEFMSG
            EndSelect

    EndSelect
EndFunc

Updated total code:

; #INDEX# =======================================================================================================================
; Title .........: Portal Procedure Batch Printer for CGS
; AutoIt Version : 3.3.6.1
; Language ......: English
; Description ...: Batch Printer for Portal program at CGS. Only contains procedures managed at satellite location.
; Author(s) .....: yours truly
; ===============================================================================================================================

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>


Opt('MouseCoordMode',0)
Opt('PixelCoordMode',0)
Opt('GUIOnEventMode',1)

HotKeySet('{ESC}','_OnExit')
TraySetIcon('PortalJ_Print.ico')

;Create Array
#region
Dim $aProcedure [112][3] = [ _
        ['1.3.9','PPM','PPI'], _
        ['1.3.10A','PPM','PPI'], _
        ['1.3.10B','PPM','PPI'], _
        ['1.3.10C','PPM','PPI'], _
        ['1.3.27','PPM','PPI'], _
        ['1.3.30','PPM','PPI'], _
        ['1.3.51','PPM','PPI'], _
        ['1.3.56','PPM','PPI'], _
        ['1.3.57','PPM','PPI'], _
        ['1.3.62','PPM','PPI'], _
        ['1.3.64','PPM','PPI'], _
        ['1.3.68','PPM','PPI'], _
        ['1.3.69','PPM','PPI'], _
        ['1.3.76','PPM','PPI'], _
        ['1.4.7','PPM','PPI'], _
        ['1.20.1','PPM','PPI'], _
        ['10.1.13','PPM','PPI'], _
        ['10.1.21','PPM','PPI'], _
        ['10.1.22','PPM','PPI'], _
        ['10.2.7','PPM','PPI'], _
        ['10.2.10','PPM','PPI'], _
        ['10.2.13','PPM','PPI'], _
        ['10.2.14','PPM','PPI'], _
        ['10.2.17','PPM','PPI'], _
        ['10.2.18','PPM','PPI'], _
        ['10.2.23','PPM','PPI'], _
        ['10.2.27','PPM','PPI'], _
        ['10.2.28','PPM','PPI'], _
        ['10.2.29','PPM','PPI'], _
        ['10.2.31','PPM','PPI'], _
        ['10.2.33','PPM','PPI'], _
        ['10.2.34','PPM','PPI'], _
        ['10.2.37','PPM','PPI'], _
        ['10.2.41','PPM','PPI'], _
        ['10.2.47','PPM','PPI'], _
        ['10.2.51','PPM','PPI'], _
        ['10.2.53','PPM','PPI'], _
        ['10.2.79','PPM','PPI'], _
        ['10.2.101','PPM','PPI'], _
        ['10.4.1','PPM','PPI'], _
        ['10.4.2','PPM','PPI'], _
        ['10.4.3','PPM','PPI'], _
        ['10.4.4','PPM','PPI'], _
        ['10.4.10','PPM','PPI'], _
        ['10.4.11','PPM','PPI'], _
        ['10.4.12','PPM','PPI'], _
        ['10.4.14','PPM','PPI'], _
        ['10.23.1','PPM','PPI'], _
        ['10.23.2','PPM','PPI'], _
        ['10.23.4','PPM','PPI'], _
        ['10.24.12','PPM','PPI'], _
        ['10.24.135','PPM','PPI'], _
        ['10.25.19','PPM','PPI'], _
        ['10.25.46','PPM','PPI'], _
        ['10.25.54','PPM','PPI'], _
        ['10.25.55','PPM','PPI'], _
        ['10.25.57','PPM','PPI'], _
        ['10.25.61','PPM','PPI'], _
        ['10.25.78','PPM','PPI'], _
        ['11.2.11.3','PPM','PPI'], _
        ['11.2.15.7','PPM','PPI'], _
        ['11.2.23.4','PPM','PPI'], _
        ['CIVES-5','ENG','PPI'], _
        ['CIVES-6','ENG','PPI'], _
        ['DES-2-1','ENG','PPI'], _
        ['DES-2-2','ENG','PPI'], _
        ['DES-2-7','ENG','PPI'], _
        ['DES-3-1','ENG','PPI'], _
        ['DES-3-2','ENG','PPI'], _
        ['DES-3-3','ENG','PPI'], _
        ['DES-4-1','ENG','PPI'], _
        ['DES-4-2','ENG','PPI'], _
        ['DES-4-12','ENG','PPI'], _
        ['DES-5-2','ENG','PPI'], _
        ['EMS-01','EMS','MAN'], _
        ['ENG-DES-02','ENG','PPI'], _
        ['GEN-RPP-04','PPM','PPI'], _
        ['GEN-RPP-10','PPM','PPI'], _
        ['HPI-0.19','HPI','PPI'], _
        ['ISPM-1','ISPM','PPI'], _
        ['ISPM-2','ISPM','PPI'], _
        ['ISPM-3','ISPM','PPI'], _
        ['ISPM-4','ISPM','PPI'], _
        ['ISPM-5','ISPM','PPI'], _
        ['ISPM-6','ISPM','PPI'], _
        ['ISPM-7','ISPM','PPI'], _
        ['ISPM-8','ISPM','PPI'], _
        ['ISPM-9','ISPM','PPI'], _
        ['ISPM-10','ISPM','PPI'], _
        ['ISPM-11','ISPM','PPI'], _
        ['ISPM-12','ISPM','PPI'], _
        ['ISPM-13','ISPM','PPI'], _
        ['ISPM-14','ISPM','PPI'], _
        ['ISPM-15','ISPM','PPI'], _
        ['ISPM-16','ISPM','PPI'], _
        ['ISPM-17','ISPM','PPI'], _
        ['ISPM-18','ISPM','PPI'], _
        ['ISPM-19','ISPM','PPI'], _
        ['ISPM-20','ISPM','PPI'], _
        ['MI-2.6.1','MAI','PPI'], _
        ['MWP-1','MWP','MAN'], _
        ['MWP-5','MWP','MAN'], _
        ['MWP-7','MWP','MAN'], _
        ['MWP-10','MWP','MAN'], _
        ['MWP-13','MWP','MAN'], _
        ['QCI-2','QCI','PPI'], _
        ['SWP-CHE-05','SWP','PPI'], _
        ['SWP-CM-01','SWP','PPI'], _
        ['SWP-DES-01','SWP','PPI'], _
        ['SWP-OSH-06','SWP','PPI'], _
        ['SWP-OSH-08','SWP','PPI'], _
        ['SWP-TST-01','SWP','PPI'] _
        ]
#endregion

Dim $aProcedureSize = UBound($aProcedure)
;Set Extended Styles
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES,$LVS_EX_GRIDLINES)
;Create GUI
$hWnd = GUICreate('Portal Procedure Printer',400,500)
;Create Buttons
$bPrint = GUICtrlCreateButton('',308,50,80,40,$BS_ICON)
GUICtrlSetImage($bPrint,'shell32.dll',17)
GUICtrlCreateLabel('PRINT',334,90)
$bExit = GUICtrlCreateButton('',308,120,80,40,$BS_ICON)
GUICtrlSetImage($bExit,'shell32.dll',240)
GUICtrlCreateLabel('EXIT',338,160)
;Create Button Events
GUICtrlSetonEvent($bExit,'_OnExit')
GUICtrlSetOnEvent($bPrint,'_Print')
;Create List View and Apply Styles
$hListView = GUICtrlCreateListView('',2,2,294,468)

_GUICtrlListView_SetExtendedListViewStyle($hListView,$exStyles)
;Add columns
_GUICtrlListView_AddColumn($hListView,'Doc Type',70)
_GUICtrlListView_AddColumn($hListView,'Sub Type',70)
_GUICtrlListView_AddColumn($hListView,'Doc No.',134)
;Set colors
_GUICtrlListView_SetBkColor($hListView,$CLR_SKYBLUE)
_GUICtrlListView_SetTextColor($hListView,$CLR_BLACK)
_GUICtrlListView_SetTextBkColor($hListView,$CLR_SKYBLUE)
;Add items and subitems to list view
For $i = 0 to $aProcedureSize -1
    _GUICtrlListView_AddItem($hListView,$aProcedure[$i][2],0)
    _GUICtrlListView_AddSubItem($hListView,$i,$aProcedure[$i][1],1)
    _GUICtrlListView_AddSubItem($hListView,$i,$aProcedure[$i][0],2)
    _GUICtrlListView_AddSubItem($hListView,$i,'TEMPORARY MODIFICATION',3)
Next
;Set GUI Close Event
GUISetOnEvent($GUI_EVENT_CLOSE,'_OnExit')
;Display GUI
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
    Sleep(1000)
WEnd

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $hListView
            Select
                Case $event = $NM_CLICK
                    Consolewrite(@lf&"LV-Item clicked"&@lf)
                Case $event = $NM_DBLCLK
                    consolewrite(@lf&"LV-Item Doubleclick"&@lf)
                Case $event = $LVN_ENDSCROLL
                    consolewrite(@lf&"Endscroll"&@lf)
                    GUICtrlSetState ( $hlistview,$GUI_Hide)
                    GUICtrlSetState ( $hlistview,$GUI_Show)
                    ;_WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_UPDATENOW)
                    ;_WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_VALIDATE)
                    ;Return $GUI_RUNDEFMSG
            EndSelect

    EndSelect
EndFunc

Func _Print()
GUISetState(@SW_HIDE)
    For $i = 0 to $aProcedureSize -1
        If _GUICtrlListView_GetItemChecked($hListView,$i) Then
            WinActivate('TIM')
            $PortalWait = WinWaitActive('TIM','',5)
                If $PortalWait == 0 Then
                    MsgBox(0,'Error','Portal window not found')
                    GuiSetState(@SW_SHOW)
                    Return
                EndIf
            MouseClick('Left',378,75)
            WinWait('TIMX000 - VENTYX INCORPORATED - [ PAS6 ]')
            MouseClick('Left',421,381)
            WinWait ('TIMMENU - [ PAS6 ]')
            MouseClick('Left',211,110)
            WinWait('TIMC010 - CONT DOC - INFORMATION - [ PAS6 ]')
            MouseClick('Left',119,151)
            Send($aProcedure[$i][2])
            MouseClick('Left',440,151)
            Send($aProcedure[$i][1])
            MouseClick('Left',200,174)
            Send($aProcedure[$i][0])
            Send('{ENTER}')
            ;Check to see if image has loaded
            $ImageColorHex = Hex(PixelGetColor(376,533))
                Do
                    $ImageColorHex = Hex(PixelGetColor(376,533))
                Until $ImageColorHex == '0000FFFF'
            MouseClick('Left',376,533)
            ;IE Download Window
            WinWait('File Download')
            WinActivate('File Download')
            Sleep(500)
            ControlClick('File Download','','[ID:4423]')
            ;Adobe Reader Window
            WinWaitActive('00')
            Sleep(500)
            Send('!{F4}') ;<-- Don't forget to remove after done testing
            #cs
            WinActivate('00')
            $AdobeWait = WinWaitActive('00','',5)
            If $AdobeWait == 0 Then
                    MsgBox(0,'Error','Adobe window not found')
                    GUISetState(@SW_SHOW)
                    Return
                EndIf
            Send('^p')
            ;Printing
            WinWaitActive('Print')
            ControlClick('Print','','Button27')
            WinWait('Progress')
            WinWaitClose('Progress')
            WinActivate('00')
            Sleep(1000)
            Send('!{F4}')
            #CE
        EndIf
    Next
    MsgBox(0,'','Script is finished')
    Exit
EndFunc


Func _OnExit()
    Exit
EndFunc
Edited by ReFran
Link to comment
Share on other sites

Hi,

for me it works fine.

Next thing which could be done would be only to redraw if scoll down is for one page and not to redraw if scoll down only some rows.

But that about my level and therewith also about the time I can spend on that. So I've to go out.

Good luck, Reinhard

Link to comment
Share on other sites

Give _WinAPI_InvalidateRect($hListView) a try like suggested by Siao here to solve a scrolling glitch.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #INDEX# =======================================================================================================================
; Title .........: Portal Procedure Batch Printer for CGS
; AutoIt Version : 3.3.6.1
; Language ......: English
; Description ...: Batch Printer for Portal program at CGS. Only contains procedures managed at satellite location.
; Author(s) .....: yours truly
; ===============================================================================================================================

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <ButtonConstants.au3>

Opt('MouseCoordMode', 0)
Opt('PixelCoordMode', 0)
Opt('GUIOnEventMode', 1)

HotKeySet('{ESC}', '_OnExit')
TraySetIcon('PortalJ_Print.ico')

;Create Array
#region
Dim $aProcedure[112][3] = [ _
        ['1.3.9', 'PPM', 'PPI'], _
        ['1.3.10A', 'PPM', 'PPI'], _
        ['1.3.10B', 'PPM', 'PPI'], _
        ['1.3.10C', 'PPM', 'PPI'], _
        ['1.3.27', 'PPM', 'PPI'], _
        ['1.3.30', 'PPM', 'PPI'], _
        ['1.3.51', 'PPM', 'PPI'], _
        ['1.3.56', 'PPM', 'PPI'], _
        ['1.3.57', 'PPM', 'PPI'], _
        ['1.3.62', 'PPM', 'PPI'], _
        ['1.3.64', 'PPM', 'PPI'], _
        ['1.3.68', 'PPM', 'PPI'], _
        ['1.3.69', 'PPM', 'PPI'], _
        ['1.3.76', 'PPM', 'PPI'], _
        ['1.4.7', 'PPM', 'PPI'], _
        ['1.20.1', 'PPM', 'PPI'], _
        ['10.1.13', 'PPM', 'PPI'], _
        ['10.1.21', 'PPM', 'PPI'], _
        ['10.1.22', 'PPM', 'PPI'], _
        ['10.2.7', 'PPM', 'PPI'], _
        ['10.2.10', 'PPM', 'PPI'], _
        ['10.2.13', 'PPM', 'PPI'], _
        ['10.2.14', 'PPM', 'PPI'], _
        ['10.2.17', 'PPM', 'PPI'], _
        ['10.2.18', 'PPM', 'PPI'], _
        ['10.2.23', 'PPM', 'PPI'], _
        ['10.2.27', 'PPM', 'PPI'], _
        ['10.2.28', 'PPM', 'PPI'], _
        ['10.2.29', 'PPM', 'PPI'], _
        ['10.2.31', 'PPM', 'PPI'], _
        ['10.2.33', 'PPM', 'PPI'], _
        ['10.2.34', 'PPM', 'PPI'], _
        ['10.2.37', 'PPM', 'PPI'], _
        ['10.2.41', 'PPM', 'PPI'], _
        ['10.2.47', 'PPM', 'PPI'], _
        ['10.2.51', 'PPM', 'PPI'], _
        ['10.2.53', 'PPM', 'PPI'], _
        ['10.2.79', 'PPM', 'PPI'], _
        ['10.2.101', 'PPM', 'PPI'], _
        ['10.4.1', 'PPM', 'PPI'], _
        ['10.4.2', 'PPM', 'PPI'], _
        ['10.4.3', 'PPM', 'PPI'], _
        ['10.4.4', 'PPM', 'PPI'], _
        ['10.4.10', 'PPM', 'PPI'], _
        ['10.4.11', 'PPM', 'PPI'], _
        ['10.4.12', 'PPM', 'PPI'], _
        ['10.4.14', 'PPM', 'PPI'], _
        ['10.23.1', 'PPM', 'PPI'], _
        ['10.23.2', 'PPM', 'PPI'], _
        ['10.23.4', 'PPM', 'PPI'], _
        ['10.24.12', 'PPM', 'PPI'], _
        ['10.24.135', 'PPM', 'PPI'], _
        ['10.25.19', 'PPM', 'PPI'], _
        ['10.25.46', 'PPM', 'PPI'], _
        ['10.25.54', 'PPM', 'PPI'], _
        ['10.25.55', 'PPM', 'PPI'], _
        ['10.25.57', 'PPM', 'PPI'], _
        ['10.25.61', 'PPM', 'PPI'], _
        ['10.25.78', 'PPM', 'PPI'], _
        ['11.2.11.3', 'PPM', 'PPI'], _
        ['11.2.15.7', 'PPM', 'PPI'], _
        ['11.2.23.4', 'PPM', 'PPI'], _
        ['CIVES-5', 'ENG', 'PPI'], _
        ['CIVES-6', 'ENG', 'PPI'], _
        ['DES-2-1', 'ENG', 'PPI'], _
        ['DES-2-2', 'ENG', 'PPI'], _
        ['DES-2-7', 'ENG', 'PPI'], _
        ['DES-3-1', 'ENG', 'PPI'], _
        ['DES-3-2', 'ENG', 'PPI'], _
        ['DES-3-3', 'ENG', 'PPI'], _
        ['DES-4-1', 'ENG', 'PPI'], _
        ['DES-4-2', 'ENG', 'PPI'], _
        ['DES-4-12', 'ENG', 'PPI'], _
        ['DES-5-2', 'ENG', 'PPI'], _
        ['EMS-01', 'EMS', 'MAN'], _
        ['ENG-DES-02', 'ENG', 'PPI'], _
        ['GEN-RPP-04', 'PPM', 'PPI'], _
        ['GEN-RPP-10', 'PPM', 'PPI'], _
        ['HPI-0.19', 'HPI', 'PPI'], _
        ['ISPM-1', 'ISPM', 'PPI'], _
        ['ISPM-2', 'ISPM', 'PPI'], _
        ['ISPM-3', 'ISPM', 'PPI'], _
        ['ISPM-4', 'ISPM', 'PPI'], _
        ['ISPM-5', 'ISPM', 'PPI'], _
        ['ISPM-6', 'ISPM', 'PPI'], _
        ['ISPM-7', 'ISPM', 'PPI'], _
        ['ISPM-8', 'ISPM', 'PPI'], _
        ['ISPM-9', 'ISPM', 'PPI'], _
        ['ISPM-10', 'ISPM', 'PPI'], _
        ['ISPM-11', 'ISPM', 'PPI'], _
        ['ISPM-12', 'ISPM', 'PPI'], _
        ['ISPM-13', 'ISPM', 'PPI'], _
        ['ISPM-14', 'ISPM', 'PPI'], _
        ['ISPM-15', 'ISPM', 'PPI'], _
        ['ISPM-16', 'ISPM', 'PPI'], _
        ['ISPM-17', 'ISPM', 'PPI'], _
        ['ISPM-18', 'ISPM', 'PPI'], _
        ['ISPM-19', 'ISPM', 'PPI'], _
        ['ISPM-20', 'ISPM', 'PPI'], _
        ['MI-2.6.1', 'MAI', 'PPI'], _
        ['MWP-1', 'MWP', 'MAN'], _
        ['MWP-5', 'MWP', 'MAN'], _
        ['MWP-7', 'MWP', 'MAN'], _
        ['MWP-10', 'MWP', 'MAN'], _
        ['MWP-13', 'MWP', 'MAN'], _
        ['QCI-2', 'QCI', 'PPI'], _
        ['SWP-CHE-05', 'SWP', 'PPI'], _
        ['SWP-CM-01', 'SWP', 'PPI'], _
        ['SWP-DES-01', 'SWP', 'PPI'], _
        ['SWP-OSH-06', 'SWP', 'PPI'], _
        ['SWP-OSH-08', 'SWP', 'PPI'], _
        ['SWP-TST-01', 'SWP', 'PPI'] _
        ]
#endregion

Dim $aProcedureSize = UBound($aProcedure)
;Set Extended Styles
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)
;Create GUI
$hWnd = GUICreate('Portal Procedure Printer', 400, 500)
;Create Buttons
$bPrint = GUICtrlCreateButton('', 308, 50, 80, 40, $BS_ICON)
GUICtrlSetImage($bPrint, 'shell32.dll', 17)
GUICtrlCreateLabel('PRINT', 334, 90)
$bExit = GUICtrlCreateButton('', 308, 120, 80, 40, $BS_ICON)
GUICtrlSetImage($bExit, 'shell32.dll', 240)
GUICtrlCreateLabel('EXIT', 338, 160)
;Create Button Events
GUICtrlSetOnEvent($bExit, '_OnExit')
GUICtrlSetOnEvent($bPrint, '_Print')
;Create List View and Apply Styles
$cListView = GUICtrlCreateListView('', 2, 2, 294, 468)
Global $hListView = GUICtrlGetHandle($cListView)
_GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
;Add columns
_GUICtrlListView_AddColumn($hListView, 'Doc Type', 70)
_GUICtrlListView_AddColumn($hListView, 'Sub Type', 70)
_GUICtrlListView_AddColumn($hListView, 'Doc No.', 134)
;Set colors
_GUICtrlListView_SetBkColor($hListView, $CLR_SKYBLUE)
_GUICtrlListView_SetTextColor($hListView, $CLR_BLACK)
_GUICtrlListView_SetTextBkColor($hListView, $CLR_SKYBLUE)
;Add items and subitems to list view
For $i = 0 To $aProcedureSize - 1
    _GUICtrlListView_AddItem($hListView, $aProcedure[$i][2], 0)
    _GUICtrlListView_AddSubItem($hListView, $i, $aProcedure[$i][1], 1)
    _GUICtrlListView_AddSubItem($hListView, $i, $aProcedure[$i][0], 2)
    _GUICtrlListView_AddSubItem($hListView, $i, 'TEMPORARY MODIFICATION', 3)
Next
;Set GUI Close Event
GUISetOnEvent($GUI_EVENT_CLOSE, '_OnExit')
;Display GUI
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

GUISetState()

While 1
    Sleep(1000)
WEnd

Func _Print()
    GUISetState(@SW_HIDE)
    For $i = 0 To $aProcedureSize - 1
        If _GUICtrlListView_GetItemChecked($hListView, $i) Then
            WinActivate('TIM')
            $PortalWait = WinWaitActive('TIM', '', 5)
            If $PortalWait == 0 Then
                MsgBox(0, 'Error', 'Portal window not found')
                GUISetState(@SW_SHOW)
                Return
            EndIf
            MouseClick('Left', 378, 75)
            WinWait('TIMX000 - VENTYX INCORPORATED - [ PAS6 ]')
            MouseClick('Left', 421, 381)
            WinWait('TIMMENU - [ PAS6 ]')
            MouseClick('Left', 211, 110)
            WinWait('TIMC010 - CONT DOC - INFORMATION - [ PAS6 ]')
            MouseClick('Left', 119, 151)
            Send($aProcedure[$i][2])
            MouseClick('Left', 440, 151)
            Send($aProcedure[$i][1])
            MouseClick('Left', 200, 174)
            Send($aProcedure[$i][0])
            Send('{ENTER}')
            ;Check to see if image has loaded
            $ImageColorHex = Hex(PixelGetColor(376, 533))
            Do
                $ImageColorHex = Hex(PixelGetColor(376, 533))
            Until $ImageColorHex == '0000FFFF'
            MouseClick('Left', 376, 533)
            ;IE Download Window
            WinWait('File Download')
            WinActivate('File Download')
            Sleep(500)
            ControlClick('File Download', '', '[ID:4423]')
            ;Adobe Reader Window
            WinWaitActive('00')
            Sleep(500)
            Send('!{F4}') ;<-- Don't forget to remove after done testing
            #cs
                WinActivate('00')
                $AdobeWait = WinWaitActive('00','',5)
                If $AdobeWait == 0 Then
                MsgBox(0,'Error','Adobe window not found')
                GUISetState(@SW_SHOW)
                Return
                EndIf
                Send('^p')
                ;Printing
                WinWaitActive('Print')
                ControlClick('Print','','Button27')
                WinWait('Progress')
                WinWaitClose('Progress')
                WinActivate('00')
                Sleep(1000)
                Send('!{F4}')
            #ce
        EndIf
    Next
    MsgBox(0, '', 'Script is finished')
    Exit
EndFunc   ;==>_Print

Func _OnExit()
    Exit
EndFunc   ;==>_OnExit

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)

    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    Local $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Local $nNotifyCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hListView
            Switch $nNotifyCode
                Case $LVN_ENDSCROLL ; solve AutoResize_ScrollGlitch by Siao - http://www.autoitscript.com/forum/index.php?showtopic=55811&view=findpost&p=429058
                    _WinAPI_InvalidateRect($hListView)
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_Notify_Events
Edited by KaFu
Link to comment
Share on other sites

Hi Kafu,

works well for me. Will have to look deeper into that.

Maybe useful for autoscroll if you load much items in a loop.

However, I coudn't resist to start another test.

If scroll starts, it counts the customdraw until scroll ends.

If customdraw > 20 it redraw at the end of scroll and reset counter.

Not real professional, but works also.

br, Reinhard

; #INDEX# =======================================================================================================================
; Title .........: Portal Procedure Batch Printer for CGS
; AutoIt Version : 3.3.6.1
; Language ......: English
; Description ...: Batch Printer for Portal program at CGS. Only contains procedures managed at satellite location.
; Author(s) .....: yours truly
; ===============================================================================================================================

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>

DIM $lrd = 0 ; for redraw listview

Opt('MouseCoordMode',0)
Opt('PixelCoordMode',0)
Opt('GUIOnEventMode',1)

HotKeySet('{ESC}','_OnExit')
TraySetIcon('PortalJ_Print.ico')

;Create Array
#region
Dim $aProcedure [112][3] = [ _
        ['1.3.9','PPM','PPI'], _
        ['1.3.10A','PPM','PPI'], _
        ['1.3.10B','PPM','PPI'], _
        ['1.3.10C','PPM','PPI'], _
        ['1.3.27','PPM','PPI'], _
        ['1.3.30','PPM','PPI'], _
        ['1.3.51','PPM','PPI'], _
        ['1.3.56','PPM','PPI'], _
        ['1.3.57','PPM','PPI'], _
        ['1.3.62','PPM','PPI'], _
        ['1.3.64','PPM','PPI'], _
        ['1.3.68','PPM','PPI'], _
        ['1.3.69','PPM','PPI'], _
        ['1.3.76','PPM','PPI'], _
        ['1.4.7','PPM','PPI'], _
        ['1.20.1','PPM','PPI'], _
        ['10.1.13','PPM','PPI'], _
        ['10.1.21','PPM','PPI'], _
        ['10.1.22','PPM','PPI'], _
        ['10.2.7','PPM','PPI'], _
        ['10.2.10','PPM','PPI'], _
        ['10.2.13','PPM','PPI'], _
        ['10.2.14','PPM','PPI'], _
        ['10.2.17','PPM','PPI'], _
        ['10.2.18','PPM','PPI'], _
        ['10.2.23','PPM','PPI'], _
        ['10.2.27','PPM','PPI'], _
        ['10.2.28','PPM','PPI'], _
        ['10.2.29','PPM','PPI'], _
        ['10.2.31','PPM','PPI'], _
        ['10.2.33','PPM','PPI'], _
        ['10.2.34','PPM','PPI'], _
        ['10.2.37','PPM','PPI'], _
        ['10.2.41','PPM','PPI'], _
        ['10.2.47','PPM','PPI'], _
        ['10.2.51','PPM','PPI'], _
        ['10.2.53','PPM','PPI'], _
        ['10.2.79','PPM','PPI'], _
        ['10.2.101','PPM','PPI'], _
        ['10.4.1','PPM','PPI'], _
        ['10.4.2','PPM','PPI'], _
        ['10.4.3','PPM','PPI'], _
        ['10.4.4','PPM','PPI'], _
        ['10.4.10','PPM','PPI'], _
        ['10.4.11','PPM','PPI'], _
        ['10.4.12','PPM','PPI'], _
        ['10.4.14','PPM','PPI'], _
        ['10.23.1','PPM','PPI'], _
        ['10.23.2','PPM','PPI'], _
        ['10.23.4','PPM','PPI'], _
        ['10.24.12','PPM','PPI'], _
        ['10.24.135','PPM','PPI'], _
        ['10.25.19','PPM','PPI'], _
        ['10.25.46','PPM','PPI'], _
        ['10.25.54','PPM','PPI'], _
        ['10.25.55','PPM','PPI'], _
        ['10.25.57','PPM','PPI'], _
        ['10.25.61','PPM','PPI'], _
        ['10.25.78','PPM','PPI'], _
        ['11.2.11.3','PPM','PPI'], _
        ['11.2.15.7','PPM','PPI'], _
        ['11.2.23.4','PPM','PPI'], _
        ['CIVES-5','ENG','PPI'], _
        ['CIVES-6','ENG','PPI'], _
        ['DES-2-1','ENG','PPI'], _
        ['DES-2-2','ENG','PPI'], _
        ['DES-2-7','ENG','PPI'], _
        ['DES-3-1','ENG','PPI'], _
        ['DES-3-2','ENG','PPI'], _
        ['DES-3-3','ENG','PPI'], _
        ['DES-4-1','ENG','PPI'], _
        ['DES-4-2','ENG','PPI'], _
        ['DES-4-12','ENG','PPI'], _
        ['DES-5-2','ENG','PPI'], _
        ['EMS-01','EMS','MAN'], _
        ['ENG-DES-02','ENG','PPI'], _
        ['GEN-RPP-04','PPM','PPI'], _
        ['GEN-RPP-10','PPM','PPI'], _
        ['HPI-0.19','HPI','PPI'], _
        ['ISPM-1','ISPM','PPI'], _
        ['ISPM-2','ISPM','PPI'], _
        ['ISPM-3','ISPM','PPI'], _
        ['ISPM-4','ISPM','PPI'], _
        ['ISPM-5','ISPM','PPI'], _
        ['ISPM-6','ISPM','PPI'], _
        ['ISPM-7','ISPM','PPI'], _
        ['ISPM-8','ISPM','PPI'], _
        ['ISPM-9','ISPM','PPI'], _
        ['ISPM-10','ISPM','PPI'], _
        ['ISPM-11','ISPM','PPI'], _
        ['ISPM-12','ISPM','PPI'], _
        ['ISPM-13','ISPM','PPI'], _
        ['ISPM-14','ISPM','PPI'], _
        ['ISPM-15','ISPM','PPI'], _
        ['ISPM-16','ISPM','PPI'], _
        ['ISPM-17','ISPM','PPI'], _
        ['ISPM-18','ISPM','PPI'], _
        ['ISPM-19','ISPM','PPI'], _
        ['ISPM-20','ISPM','PPI'], _
        ['MI-2.6.1','MAI','PPI'], _
        ['MWP-1','MWP','MAN'], _
        ['MWP-5','MWP','MAN'], _
        ['MWP-7','MWP','MAN'], _
        ['MWP-10','MWP','MAN'], _
        ['MWP-13','MWP','MAN'], _
        ['QCI-2','QCI','PPI'], _
        ['SWP-CHE-05','SWP','PPI'], _
        ['SWP-CM-01','SWP','PPI'], _
        ['SWP-DES-01','SWP','PPI'], _
        ['SWP-OSH-06','SWP','PPI'], _
        ['SWP-OSH-08','SWP','PPI'], _
        ['SWP-TST-01','SWP','PPI'] _
        ]
#endregion

Dim $aProcedureSize = UBound($aProcedure)
;Set Extended Styles
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES,$LVS_EX_GRIDLINES)
;Create GUI
$hWnd = GUICreate('Portal Procedure Printer',400,500)
;Create Buttons
$bPrint = GUICtrlCreateButton('',308,50,80,40,$BS_ICON)
GUICtrlSetImage($bPrint,'shell32.dll',17)
GUICtrlCreateLabel('PRINT',334,90)
$bExit = GUICtrlCreateButton('',308,120,80,40,$BS_ICON)
GUICtrlSetImage($bExit,'shell32.dll',240)
GUICtrlCreateLabel('EXIT',338,160)
;Create Button Events
GUICtrlSetonEvent($bExit,'_OnExit')
GUICtrlSetOnEvent($bPrint,'_Print')
;Create List View and Apply Styles
$hListView = GUICtrlCreateListView('',2,2,294,468)

_GUICtrlListView_SetExtendedListViewStyle($hListView,$exStyles)
;Add columns
_GUICtrlListView_AddColumn($hListView,'Doc Type',70)
_GUICtrlListView_AddColumn($hListView,'Sub Type',70)
_GUICtrlListView_AddColumn($hListView,'Doc No.',134)
;Set colors
_GUICtrlListView_SetBkColor($hListView,$CLR_SKYBLUE)
_GUICtrlListView_SetTextColor($hListView,$CLR_BLACK)
_GUICtrlListView_SetTextBkColor($hListView,$CLR_SKYBLUE)
;Add items and subitems to list view
For $i = 0 to $aProcedureSize -1
    _GUICtrlListView_AddItem($hListView,$aProcedure[$i][2],0)
    _GUICtrlListView_AddSubItem($hListView,$i,$aProcedure[$i][1],1)
    _GUICtrlListView_AddSubItem($hListView,$i,$aProcedure[$i][0],2)
    _GUICtrlListView_AddSubItem($hListView,$i,'TEMPORARY MODIFICATION',3)
Next
;Set GUI Close Event
GUISetOnEvent($GUI_EVENT_CLOSE,'_OnExit')
;Display GUI
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
    Sleep(1000)
WEnd

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $hListView
            Select
                Case $event = $NM_CLICK
                    Consolewrite("LV-Item clicked"&@lf)
                Case $event = $NM_DBLCLK
                    consolewrite("LV-Item Doubleclick"&@lf)
                Case $event = $LVN_BEGINSCROLL
                    consolewrite("LV-Beginscroll"&@lf)
                    $lrd = 1
                Case $event = $NM_CUSTOMDRAW
                    if $lrd > 0 then $lrd += 1
                    consolewrite("LV-Custumdraw = "&$lrd &@lf)
                Case $event = $LVN_ENDSCROLL
                    consolewrite(@lf&"LV-Endscroll"&@lf)
                    if $lrd > 20 then
                        GUICtrlSetState ( $hlistview,$GUI_Hide)
                        GUICtrlSetState ( $hlistview,$GUI_Show)
                    EndIf
                    $lrd = 0
            EndSelect

    EndSelect
EndFunc

Func _Print()
GUISetState(@SW_HIDE)
    For $i = 0 to $aProcedureSize -1
        If _GUICtrlListView_GetItemChecked($hListView,$i) Then
            WinActivate('TIM')
            $PortalWait = WinWaitActive('TIM','',5)
                If $PortalWait == 0 Then
                    MsgBox(0,'Error','Portal window not found')
                    GuiSetState(@SW_SHOW)
                    Return
                EndIf
            MouseClick('Left',378,75)
            WinWait('TIMX000 - VENTYX INCORPORATED - [ PAS6 ]')
            MouseClick('Left',421,381)
            WinWait ('TIMMENU - [ PAS6 ]')
            MouseClick('Left',211,110)
            WinWait('TIMC010 - CONT DOC - INFORMATION - [ PAS6 ]')
            MouseClick('Left',119,151)
            Send($aProcedure[$i][2])
            MouseClick('Left',440,151)
            Send($aProcedure[$i][1])
            MouseClick('Left',200,174)
            Send($aProcedure[$i][0])
            Send('{ENTER}')
            ;Check to see if image has loaded
            $ImageColorHex = Hex(PixelGetColor(376,533))
                Do
                    $ImageColorHex = Hex(PixelGetColor(376,533))
                Until $ImageColorHex == '0000FFFF'
            MouseClick('Left',376,533)
            ;IE Download Window
            WinWait('File Download')
            WinActivate('File Download')
            Sleep(500)
            ControlClick('File Download','','[ID:4423]')
            ;Adobe Reader Window
            WinWaitActive('00')
            Sleep(500)
            Send('!{F4}') ;<-- Don't forget to remove after done testing
            #cs
            WinActivate('00')
            $AdobeWait = WinWaitActive('00','',5)
            If $AdobeWait == 0 Then
                    MsgBox(0,'Error','Adobe window not found')
                    GUISetState(@SW_SHOW)
                    Return
                EndIf
            Send('^p')
            ;Printing
            WinWaitActive('Print')
            ControlClick('Print','','Button27')
            WinWait('Progress')
            WinWaitClose('Progress')
            WinActivate('00')
            Sleep(1000)
            Send('!{F4}')
            #CE
        EndIf
    Next
    MsgBox(0,'','Script is finished')
    Exit
EndFunc


Func _OnExit()
    Exit
EndFunc
Edited by ReFran
Link to comment
Share on other sites

This is a known bug in the listview control, but ONLY for Windows XP - apparently, MS fixed this in Vista and higher. I ran into the same thing in an application I am working on. Here is my fix.

I registered a handler for the WM_NOTIFY message, which looks for a LVN_ENDSCROLL notification (end of scrolling operation). The handler then passes off to "refreshgrid()", which is shown below. In the code, refreshing is done after every LVN_ENDSCROLL notification, but only on the visible portion of the control. Flickering, etc. seems fine on my machine - relatively smooth operation. The code comments make reference to "registered.au3" - this is just the handler which looks for the notification. I have eliminated some useless portions of the code (particular to my app).

The code posted here is just the "good bits" and comes from a few different includes.

; registers handler in main app, before message loop
GUIRegisterMsg ($WM_NOTIFY, "WinMsgNotify" ) ; see _registered.au3

; --------------------------------------------------------

; structure, for handler
; NMITEMACTIVATE structure - passed by WM_NOTIFY instead of NMHDR for some listview actions
Const $tag_NMITEMACTIVATE = _
"hwnd hWndFrom;" & _        ; Window handle to the control sending a message
"int IDFrom;" & _           ; Identifier of the control sending a message - guaranteed unique
"int Code;" & _             ; Notification code (from the control)
"int Index;" & _            ; Index of the list-view item, or -1 if not applicable
"int SubItem;" & _          ; "One"-based (PROBABLY zero based) index of the subitem, or 0 if for whole item.
"int NewState;" & _         ; New item state or 0 if state not used
"int OldState;" & _         ; Old item state or 0 if state not used
"int Changed;" & _          ; Set of flags to indicate attributes that have changed, same as LVITEM.Mask
"int X;" & _                ; X co-ord of activation point
"int Y;" & _                ; Y co-ord of activation point
"int lParam;" & _           ; Application-defined value of the item or undefined if not used.
"int KeyFlags"              ; Modifier keys that were pressed at the time of the activation.
                            ; Combination of LVKF_ALT, LVKF_CONTROL and LVKF_SHIFT

; --------------------------------------------------------

; handler (abbreviated)
; Trap left mouse button double clicks, could be from any control, but designed for ListView
; Also trapping scroll notifications from $LV_files (listview control) - see LV_io.au3/refreshgrid()
Func WinMsgNotify($hWndGUI, $MsgID, $WParam, $LParam) ; handle WM_NOTIFY
    Local $NMHDR = DllStructCreate($tag_NMHDR,$LParam) ; passed by WM_NOTIFY
    Local $NMITEMACTIVATE = DllStructCreate($tag_NMITEMACTIVATE,$LParam) ; full (alternate) structure
; Note first 3 fields of $NMITEMACTIVATE (LV specific) are identical to $NMHDR (generic)
    Local $ctrl_msg = DllStructGetData ($NMHDR,"Code") ; notification from control
    Local $idx,$control ; assign later
; test from $NMHDR - not every WM_NOTIFY will use an alternate structure instead of NMHDR
    Switch $ctrl_msg ; what is the secondary message?

        Case $NM_DBLCLK ; mouse was left double-clicked
            ; code not shown - application specific

        Case $LVN_ENDSCROLL ; scrolling operation just ended
            If $b_LVgrid Then refreshgrid() ; if listview grid enabled then repaint

    EndSwitch
    $NMHDR = 0 ; release memory
    $NMITEMACTIVATE = 0
EndFunc ; WinMsgNotify($hWndGUI, $MsgID, $WParam, $LParam)

; --------------------------------------------------------

; actual refresh function
#cs
Listview controls in Windows - at least up to XP SP3 - have a nasty bug: when the control is set for
gridline display ($LVS_EX_GRIDLINES extended style), scrolling the control is problematic.  Sliding
the "slider" is fine, but clicking above or below it, or using the up/down buttons, causes the grid
lines to be drawn incorrectly.  Lines are either missing or are drawn through the text.  A refresh
of the control, such as occurs by the WM_PAINT message (when the window loses focus, then returns
to focus) corrects the issue, but without a repaint or "refresh",  IT LOOKS LIKE CRAP!  Apparently,
if the Internet is to believed, a fix (at least for XP) is NOT forthcoming.  The next versions of
Windows (Vista, Windows 7) 'may' not have this problem, or at least it might have been corrected by
service packs or upgrades.  The refreshgrid() function following does a "repaint" of the visible
portion of the control, hopefully rectifying the problem.  Refreshgrid() is triggered by a
$LVN_ENDSCROLL notification sent by the control and intercepted by WinMsgNotify - see registered.au3.
#ce
Func refreshgrid() ; repaint visible portion of listview
    Local $topline,$pagecount,$btmline
    $topline = GUICtrlSendMsg ($LV_files,$LVM_GETTOPINDEX,0,0 ) ; fetch first visible line
; just in case partial line is showing, use previous line
    $topline -=  1
    If $topline < 0 Then $topline = 0
    $pagecount = GUICtrlSendMsg ($LV_files,$LVM_GETCOUNTPERPAGE,0,0 ) ; fetch fully visible count
    $btmline = $topline+$pagecount+2 ; extra line at top and bottom
    If $btmline > (rowcount()-1) Then $btmline = rowcount()-1 ; last line in listview (0 based)
    GUICtrlSendMsg ($LV_files,$LVM_REDRAWITEMS,$topline,$btmline) ; DO IT!
EndFunc ; refreshgrid()

Hope this helps. I think the problem with this bug has been that Vista (and 7) users don't see it! But Wikipedia says that XP still has the highest user base (more than Vista and 7).

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