Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/24/2023 in all areas

  1. mutleey

    Infinite scroll

    I thank colleagues @argumentum @pixelsearch @Nine and @Andreik for their help, I already have a base to work with, thank you very much; @pixelsearch At first I won't use GDI+, but as the script evolves I can implement it.
    2 points
  2. Nine

    Infinite scroll

    Something along this : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <Misc.au3> #include <GUIScrollBars_Ex.au3> Global $aButton[51] Global $bButton[51] Global $cButton[51] ; Create GUI $hGUI_Main = GUICreate("", 792, 1080, -1, 0, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0xFFAAAA) For $i = 0 To 50 $aButton[$i] = GUICtrlCreatePic("mp3.jpg", 6, 10 + (262 * $i), 250, 250) $bButton[$i] = GUICtrlCreatePic("mp3.jpg", 262, 10 + (262 * $i), 250, 250) $cButton[$i] = GUICtrlCreatePic("mp3.jpg", 518, 10 + (262 * $i), 250, 250) Next _GUIScrollBars_Generate($hGUI_Main, 0, 10 + (262 * $i)) GUISetState(@SW_SHOW, $hGUI_Main) Local $iPos, $iY While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN $iPos = MouseGetPos(1) $iY = $iPos While _IsPressed("01") If $iPos = MouseGetPos(1) Then ContinueLoop $iPos = MouseGetPos(1) If $iPos < $iY Then For $i = 1 To Int(($iY - $iPos) / 15) _SendMessage($hGUI_Main, $WM_VSCROLL, $SB_LINEDOWN) Next Else For $i = 1 To Int(($iPos - $iY) / 15) _SendMessage($hGUI_Main, $WM_VSCROLL, $SB_LINEUP) Next EndIf If $i > 1 Then $iY = $iPos WEnd EndSwitch WEnd
    2 points
  3. try the new and improved _RunWaitEx() now with "real code" PS: ..my head is full of jokes. I hope that the RunWait above get's it done.
    2 points
  4. Hello Again! I previously stumbled upon a topic asking for maps datatype's instructions... I too wasn't sure what a map is until I tried it... So I am making this topic to help other newbies (and some oldbies) better understand the Maps datatype of AutoIt! Lets start! A Note for Readers The maps datatype is still in development and is currently in Alpha Stage (More Risky than Beta) and its unstable, so AutoIt can crash indefinably while using Maps! I can't guarantee if this will be implemented in stable versions, this is a fairly new thing to AutoIt coders & in my honest opinion I don't see any use for it Maps are the best datatype in AutoIt, Very Useful ... Not hurting anyone though . Also the maps datatype is DISABLED IN STABLE VERSIONS, So you need to install the latest beta version of AutoIt to make maps work . If you find any bugs while using a map, please report it in the Official Bug Tracker Introduction To Maps Maps are just like arrays, instead they use "keys" to access elements inside them... A key can be either a string or an integer (Other datatypes work too but they are converted to a integer [Equivalent to Int($vKey)] before assignment [Source]). Although Integers don't represent the order of elements in a map unlike in an array... Declaring Maps Its similar to declaring an Array: ; This is the only way to declare a map ; You must have a declarative keyword like Dim/Global/Local before the declaration unless the map is assigned a value from a functions return Local $mMap[] ; Don't insert any numbers or strings it! Simple, Isn't it? Using Maps Using maps is similar to arrays (again!): Local $mMap[] ; Lets declare our map first! ; Adding data to maps is easy... ; This is our key ; | ; v $mMap["Key"] = "Value" ; <--- And our value! ; A key is Case-Sensitive meaning "Key" is not same as "key"! $mMap["key"] = "value" ; Not the same as $mMap["Key"]! ; There are 2 different ways to access an element in a map $mMap["Key"] ; 1st Method $mMap.Key ; 2nd Method Enumerating Maps Its quite easy to enumerate through arrays but what about maps? how can I enumerate through them!? #include <MsgBoxConstants.au3> ; Lets create our map first Local $mMap[] ; Lets add some information to the map, feel free to modify & add new elements $mMap["Name"] = "Damon Harris" $mMap["Alias"] = "TheDcoder" $mMap["Gender"] = "Male" $mMap["Age"] = 14 $mMap["Location"] = "India" $aMapKeys = MapKeys($mMap) ; MapKeys function returns all the keys in the format of an array Local $sProfile = "Profile of " & $mMap["Name"] & ':' & @CRLF ; We will use this string later For $vKey In $aMapKeys ; We use this to get the keys in a map :) $sProfile &= @CRLF & $vKey & ': ' & $mMap[$vKey] ; Add some details to the profile string using our map! Next MsgBox($MB_ICONINFORMATION + $MB_OK, "Profile", $sProfile) ; Finally display the profile :) It is easy as always Multi-Dimensional Maps Now now... I know that you are a little confused that how can an multi-dimensional maps exist... Although I am not 100% sure if its called that but lets continue: #include <MsgBoxConstants.au3> ; Multi-Dimensional maps are just maps in a map Local $mMapOfMapsvilla[] ; This map will store an other map Local $mParkMap[] ; This Park map will be inserted in the Mapsvilla's map :P $mMapOfMapsvilla["Map Item 1"] = "Town Hall" $mMapOfMapsvilla["Map Item 2"] = "Police Station" $mMapOfMapsvilla["Map Item 3"] = "Shopping Mall" $mMapOfMapsvilla["Map Item 4"] = "Residential Area" $mMapOfMapsvilla["Map Item 5"] = "Park" $mParkMap["Map Item 1"] = "Cottan Candy Stand" $mParkMap["Map Item 2"] = "Public Toilet" $mParkMap["Map Item 3"] = "Woods" $mMapOfMapsvilla.Park = $mParkMap MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla["Map Item 1"]) ; Will display Town Hall MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla.Park["Map Item 1"]) ; Will display Cottan Candy Stand I am sure its easy for you to understand now Frequently Asked Questions (FAQs) & Their answers Q #1. Help! My code does not respond to anything (or) I get an "Variable subscript badly formatted" error on the line of declaration... A. DONT USE F5 or Go, Instead use Alt + F5 or Tools -> Beta Run in SciTE (Make sure that you have Beta installed) Q #2. Why are you using "m" in-front of every map variable? A. Best coding Practices: Names of Variables Q #3. What are "Elements" which you mention frequently??? A. This is a newbie question (I have no intention of insulting you ), so I guess you are new to programming. "Elements" are data slots inside a Map (or an Array), you can imagine elements as individual variable which are stored in a Map. You can access them using "keys", Please refer to "Introduction to Maps" section at the starting of this post Q #4. Are Maps faster than Arrays? A. You need to understand that Maps have different purpose than Arrays. Maps are designed to store data dynamically (like storing information for certain controlIDs of GUI) and Arrays are designed to store data in a order (for instance, Storing every character of a string in an element for easy access). If you still want to know then if Maps are faster, then the answer is maybe... Maps are *supposed* (I am not sure ) to be faster in addition of elements (while Arrays are painfully slow while adding or removing elements). Here (Post #24) is a benchmark (Thanks kealper! ) More FAQs coming soon! Feel free to ask a question in the mean while
    1 point
  5. Yes, it is continuation. You asked me to be more specific in my question. So here we are with this new topic, as for now only related to JS, but ultimately it will be used with au3WebDriver UDF.
    1 point
  6. First install the separate scite4autoit3 installer which comes with these extra utilities.
    1 point
  7. pixelsearch

    Infinite scroll

    @mutleey got it now I inserted in my reworked script Nine's way to scroll, with minor changes (scrolling messages sent to listview and not to GUI). I also added a dummy listview Col 0 (width 0) to never see any item selected while clicking and dragging the mouse etc... It's great to have different ways to do this, using GUICtrlCreatePic or _GUIImageList_Create Here is version 2 : #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <Misc.au3> #include <ScrollBarsConstants.au3> #include <WindowsConstants.au3> GUICreate("ImageList Create v2", 840, 600) $idListview = GUICtrlCreateListView("", 0, 0, 840, 600, BitOr($LVS_SINGLESEL, $LVS_NOCOLUMNHEADER), $LVS_EX_SUBITEMIMAGES) $hListview = GUICtrlGetHandle($idListview) _GUICtrlListView_AddColumn($idListview, "", 0) ; dummy Col 0 (item column) : purpose is to never show any LV item selected. For $i = 1 To 4 ; 4 subitems columns _GUICtrlListView_AddColumn($idListview, "", 205) Next $hImageList = _GUIImageList_Create(200, 200) ; all images are 200 x 200 _GDIPlus_Startup() For $i = 0 To 299 ; 300 images $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\image " & Mod($i, 12) & ".jpg") $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GUIImageList_Add($hImageList, $hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap) _GDIPlus_BitmapDispose($hBitmap) Next _GDIPlus_Shutdown() _GUICtrlListView_SetImageList($idListview, $hImageList, 1) ; 1 = Image list with small icons (0 or 2 won't display anything) For $i = 0 To 74 ; 75 rows (4 images per row => 300 images) _GUICtrlListView_AddItem($idListview, "") ; dummy Col 0 (item column) For $j = 1 To 4 ; 4 subitems columns _GUICtrlListView_AddSubItem($idListview, $i, "", $j, $i*4 + ($j-1)) Next Next GUISetState(@SW_SHOW) Local $iPos, $iY While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN $iPos = MouseGetPos(1) $iY = $iPos While _IsPressed("01") If $iPos = MouseGetPos(1) Then ContinueLoop $iPos = MouseGetPos(1) If $iPos < $iY Then For $i = 1 To Int(($iY - $iPos) / 15) _SendMessage($hListview, $WM_VSCROLL, $SB_LINEDOWN) Next Else For $i = 1 To Int(($iPos - $iY) / 15) _SendMessage($hListview, $WM_VSCROLL, $SB_LINEUP) Next EndIf If $i > 1 Then $iY = $iPos WEnd EndSwitch WEnd _GUIImageList_Destroy($hImageList) GUIDelete() I wonder if you guys have an answer to this : do we always need GDI+ to load jpg images from disk and get their $hBitmap ? Can't it be done with a GDI function instead ?
    1 point
  8. Andreik

    Infinite scroll

    This is more a proof of concept and probably can be done more nicely but it gives you the infinite scrolling effect. Global $aCtrl[30], $hMain, $nMax Global $hMain = GUICreate('Sample', 380, 600) $nMax = CreateUI($aCtrl) GUISetState() While True Switch GUIGetMsg() Case -3 ; GUI_EVENT_CLOSE Exit Case -7 ; GUI_PRIMARY_DOWN ScrollControls($aCtrl) EndSwitch WEnd Func CreateUI(ByRef $aCtrl) Local $nIndex = 0, $nMaxH = 0 For $j = 0 To 9 For $i = 0 To 2 $aCtrl[$nIndex] = GUICtrlCreateLabel('Picture' & $nIndex + 1, $i * 120 + 20, $j * 120 + 20, 100, 100, 0x1201) If $j * 120 + 20 + 100 + 20 > $nMaxH Then $nMaxH = $j * 120 + 20 + 100 + 20 $nIndex += 1 Next Next Return $nMaxH - 600 EndFunc Func ScrollControls($aCtrl) Local $iMouseDelta, $iDeltaY, $nIndex Local Static $WinDelta = 0 Local $yPos = MouseGetPos(1) Do $iMouseDelta = MouseGetPos(1) - $yPos $iDeltaY = $iMouseDelta - $WinDelta $nIndex = 0 For $j = 0 To 9 For $i = 0 To 2 ; Remove or comment next two lines if you want infinite scrolling If $iDeltaY < 0 Then $iDeltaY = 0 If $iDeltaY > $nMax Then $iDeltaY = $nMax GUICtrlSetPos($aCtrl[$nIndex], $i * 120 + 20, $j * 120 + 20 - $iDeltaY, 100, 100) $nIndex += 1 Next Next Sleep(10) Until GUIGetMsg() = -8 ; GUI_PRIMARY_UP $WinDelta = -$iDeltaY EndFunc
    1 point
  9. Probably it would be even better if you place the line after Run() and before StringRegExp().
    1 point
  10. pixelsearch

    Infinite scroll

    @mutleey I just scripted what follows to use an imagelist control and it worked. I placed 6 images (jpg) in the script directory, resized them 100x100 (didn't care about the ratio because I just wanted to get a quick result, would it work or not ?) #include <GDIPlus.au3> #include <GuiImageList.au3> #include <GuiListView.au3> GUICreate("ImageList Create", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 296, -1, $LVS_EX_SUBITEMIMAGES) For $i = 0 To 1 ; 2 columns _GUICtrlListView_AddColumn($idListview, "Col " & $i, 105) Next $hImageList = _GUIImageList_Create(100, 100) ; all images are 100x100 _GDIPlus_Startup() For $i = 0 To 5 ; 6 images $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\image " & $i & ".jpg") $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GUIImageList_Add($hImageList, $hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap) _GDIPlus_BitmapDispose($hBitmap) Next _GDIPlus_Shutdown() _GUICtrlListView_SetImageList($idListview, $hImageList, 1) ; 1 = Image list with small icons (0 or 2 won't display anything) For $i = 0 To 2 ; 3 rows (2 images per row) _GUICtrlListView_AddItem($idListview, "", $i*2) ; 0/2/4 = image 0/2/4 in Col 0 _GUICtrlListView_AddSubItem($idListview, $i, "", 1, $i*2 +1) ; $i = row, 1 = Col 1 (1st subitem), $i*2 +1 = image 1/3/5 Next GUISetState(@SW_SHOW) Do Until GUIGetMsg() = -3 ; $GUI_EVENT_CLOSE = -3 _GUIImageList_Destroy($hImageList) GUIDelete() The list is naturally scrollable, maybe it could be a good start for what you want to achieve. Good luck and a great day to all of you
    1 point
  11. Ask user once for their credential, store them, use them. Why you need to capture instead asking user ?
    1 point
  12. argumentum

    Infinite scroll

    I would use HTML. There are a bunch of HTTP daemons here to choose from. In a browser, press F11 to go full screen, and again to go back to window mode. ( you can try it right now on this browser ) The code to do that via browser, is all over the net. The AutoIt way.., you'll have to pre-load 3 full screen pages to fake an eternal scroll, loading the next canvas/ChildGui, to fake it ?. Too much. I'd truly look at JS/CSS in HTML. If a user clicks, you can have your own protocol ( search here in the forums on how to register a protocol ), say "mutleey://" and it'll do whatever you code it to do.
    1 point
  13. pixelsearch

    Infinite scroll

    _GUIImageList_Create could be a possibility.
    1 point
×
×
  • Create New...