myspacee Posted May 23, 2015 Share Posted May 23, 2015 Hello,try to scroll up & down file list using mouse wheel :expandcollapse popup#include <GuiConstantsEx.au3> #include <File.au3> #include <Array.au3> GUIRegisterMsg(0x020A, "_Mousewheel") $sFolder = @ScriptDir & "\" ;GUI GUICreate("Automation", 300, 500) $refresh_todo = GUICtrlCreateButton("refresh", 10, 35, 75, 20) $mylist = GUICtrlCreateList("", 10, 60, 280, 300) _refresh_todo_list() GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $refresh_todo _refresh_todo_list() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd func _refresh_todo_list() Local $FileList = _FileListToArray($sFolder, "*.*") If @error = 1 Then MsgBox(0, "", "No Folders Found.") Exit EndIf If @error = 4 Then MsgBox(0, "", "No Files Found.") Exit EndIf For $i = 1 To $FileList[0] GUICtrlSetData($mylist, $FileList[$i]) Next EndFunc Func _Mousewheel($hWnd, $msg, $l, $r) If $l = 0xFF880000 Then ; Mouse wheel up tooltip("Mousewheel up") Send("{UP}") Else ; Mouse wheel down tooltip("Mousewheel down") Send("{DOWN}") EndIf sleep (1000) tooltip("") EndFunc ;==>_MousewheelThis code doesn't works, i can't understand why send is lost when focus is on a list element... Everytime I select an element (with mouse or manually) :- i must retrieve selection (namefile)- allow to read file (are all .txt) when press mouse wheel button- copy content to clipboard Maybe, I can't undestand how intercept mouse correctly.Can you help me ? thank you,m. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 24, 2015 Moderators Share Posted May 24, 2015 myspacee,This seems a rather roundabout way of doing it, but it does work unless you rotate the scroll wheel really quickly:expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> ;#include <Array.au3> #include <GuiListBox.au3> $sFolder = @ScriptDir & "\" $iList_Height = 300 ; Create GUI $hGUI = GUICreate("Automation", 300, 500) $refresh_todo = GUICtrlCreateButton("refresh", 10, 35, 75, 20) $mylist = GUICtrlCreateList("", 10, 60, 280, $iList_Height) $hList = GUICtrlGetHandle($mylist) $cDummy = GUICtrlCreateDummy() ; Create dummy control to act when scroll occurs _refresh_todo_list() GUISetState(@SW_SHOW) ; Set focus to button ControlFocus($hGUI, "", $refresh_todo) GUIRegisterMsg($WM_MOUSEWHEEL, "_Mousewheel") ; Determine how many items visible and thus offset of mid point $iItem_Height = _GUICtrlListBox_GetItemHeight($mylist) $iMid_Offset = Int($iList_Height / $iItem_Height / 2) While 1 Switch GUIGetMsg() Case $refresh_todo _refresh_todo_list() Case $GUI_EVENT_CLOSE ExitLoop Case $cDummy ; Dummy fired from within handler $iIndex = GUICtrlRead($cDummy) ; Read index of highlighted item $iTopIndex = $iIndex - $iMid_Offset ; Determine requried top item If $iTopIndex > -1 Then _GUICtrlListBox_SetTopIndex($mylist, $iTopIndex) ; Set if not below 0 EndIf EndSwitch ; Keep focus from listto prevent scrollbar eating the mousewheel message If _WinAPI_GetFocus() = $hList Then ControlFocus($hGUI, "", $refresh_todo) EndIf WEnd Func _refresh_todo_list() Local $FileList = _FileListToArray($sFolder, "*.*") If @error = 1 Then MsgBox(0, "", "No Folders Found.") Exit EndIf If @error = 4 Then MsgBox(0, "", "No Files Found.") Exit EndIf For $i = 1 To $FileList[0] GUICtrlSetData($mylist, $FileList[$i]) Next GUICtrlSetState($refresh_todo, $GUI_FOCUS) EndFunc Func _Mousewheel($hWnd, $iMsg, $wParam, $lParam) ; get index of highlighted item $iIndex = _GUICtrlListBox_GetCaretIndex($mylist) ; If ther is a highlighted item If $iIndex <> - 1 Then If $wParam = 0xFF880000 Then ; Mouse wheel up $iIndex -= 1 If $iIndex = -1 Then $iIndex = 0 Else ; Mouse wheel down $iIndex += 1 If $iIndex = _GUICtrlListBox_GetCount($mylist) Then $iIndex -= 1 EndIf ; Click on required item _GUICtrlListBox_ClickItem($mylist, $iIndex) ; Action dummy so scrolling takes place outside the handler GUICtrlSendToDummy($cDummy, $iIndex) EndIf ; Prevent scrollbar from reacting Return 0 EndFunc ;==>_MousewheelPerhaps someone else can come up with a better way, but ListBoxes are pretty primitive controls and are not easy thing with which to interact.M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
myspacee Posted May 24, 2015 Author Share Posted May 24, 2015 Hello,thank you for reply and code, but hower I can't use to reach my goal.I hope is possible 'reserve' mouse wheel up/down and redirect this user motion to GUICtrlCreateList. Try to explain my needs :- with another script i collect text from web/doc/pdf/etc and apply some 'rules' to text (i obtain a lot of txt files (>400), enriched wiht Adob3 Ind3sign styles)- I want to allow my users to 'navigate' through these files using mouse wheel and follow specific order, without move focus from 'paste' application (files are ordered by first step) At this point, as you suggest, ListBoxes not suite my needs. I think to use a list GUI to allow my users follow job and give them freedom to choose files to paste and go on. Is possible to reserve mouse wheel and redirect this 'motion' to another GUI ?I search an easy way to follow a list without obliging my users to go back and forth. Thank you for your time,m. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now