Jump to content

Search the Community

Showing results for tags 'Dynamic'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 4 results

  1. Hello, I have used this forum to get help many times. I thought it was time to (hopefully) help others. I created a script that reads a text file with a list of videos, displays the videos in a GUI with checkboxes next to the names, and displays the selected videos. This will become a part of a larger script I am creating to test a video player. The tough part for me was creating the GUI and Dynamic list of videos. I had a lot of trouble finding samples to help me, but finally found one written by Melba23. The link is in the code, so he gets credit for helping! I also have not used arrays much and they are very picky about looping through the arrays without getting the dreaded error " Array variable has incorrect number of subscripts or subscript dimension range exceeded." However diligence paid off! To run this code, take the video names commented below and create a videos.txt file in your script execution directory. You can put however many video names in this list. Thus the dynamic features of the code. Cheers! Jibberish #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <array.au3> #include <File.au3> #include <GUIConstantsEx.au3> Local $sMediaFile = @ScriptDir & "\videos.txt" ;~ Videos in videos.txt are: ;~ bbb_1080_60s.mp4 ;~ bbb_1080_60s_1.mp4 ;~ bbb_1080_60s_2.mp4 ;~ tos_4K_60s_HEVC.mp4 ;~ tos_4K_60s_HEVC_1.mp4 ;~ tos_4K_60s_HEVC_2.mp4 ;~ ;~ Additional videos can be added to this list. The functions are Dynamic. Dim $aMediaManifest Local $aArrayFile Local $aVideos Local $sVideoName Local $i ; MAIN ; Put the Video File Names into an Array _FileReadToArray($sMediaFile, $aArrayFile) Local $iVideoCount = UBound($aArrayFile) -1 ; Get the number of videos - 1 to prevent errors _ArrayDelete($aArrayFile, 0) ;Counter just gets in the way ; Move backwards through the array deleting the blank lines For $i = $iVideoCount - 1 To 0 Step -1 If $aArrayFile[$i] = "" Then _ArrayDelete($aArrayFile, $i) EndIf Next $aVideos = DisplayVideos($aArrayFile) $iVideoCount = UBound($aArrayFile) -1 _ArrayDisplay($aVideos) ; Display the checked videos ;~ End of MAIN ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; GUI to display Videos in checkboxes ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayVideos($aArrayFile) Local $iTop = -1 Local $iLeft = -1 Local $iWidth Local $iHeight = $iVideoCount * 30 Local $iL = 10 Local $iT = 10 Local $iRow = 0 Local $aVideo Local $iA = 0, $iB = 0 Local $sFill = "" $iMMCount = UBound($aArrayFile) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedVideos[$iMMCount] ; Put the Video File Names into an Array $hGUI = GUICreate("Video Checkbox", $iLeft, $iTop, $iWidth, $iHeight) GUICtrlCreateLabel("Videos", 180, $iT) $iT = $iT + 30 ; This is a great example of using arrays to create GUI check boxes or radio buttons For $i = 0 To $iMMNewCount Step 1 $sMP4Text = $aArrayFile[$i] $aGUICheckbox[$i] = GUICtrlCreateCheckbox($sMP4Text, 30, $iT) $iT += 30 Next $idClose1 = GUICtrlCreateButton("Start", $iL, $iT) GUISetState(@SW_SHOW) ; This section reads the checkboxes and puts the video names in an array in their original position ; in case this is important (as it is to me) ; This was the toughest part to code, and I found no samples online until I saw Melba23's sample here: ; https://www.autoitscript.com/forum/topic/119843-dynamic-gui-problem/#comment-832672 ; I got this working with only a little modification. THANK YOU MELBA23 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idClose1 For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aGUICheckbox[$i]) Case $GUI_CHECKED $aCheckedVideos[$i] = $aArrayFile[$i] Case $GUI_UNCHECKED EndSwitch Next ExitLoop EndSwitch WEnd GUIDelete($hGUI) Return $aCheckedVideos EndFunc ;==>DisplayVideos
  2. Hello ya'll! My problem is split in two, so I'll start with the first one: What I'm having is my script with dynamically created GUIs with similar / identical names. I would like to have that undepending on how many windows I have open to only have one "window" down at the taskbar. I guess all I need is the correct GUI style, but I can't find which one I need. Which brings me to problem part 2 (which I also find to be the easy part): Windows will open and close on random, so there's no set order in which they'll get closed. But I still need one "window" at the taskbar to work with as long as there's at least one window open. In the action of one of these windows getting minimized/restored all of the windows will act simultaneously. This will be solved with something similar: case $GUI_EVENT_MINIMIZE for $1 = 1 to Ubound($ActiveWindows) step +1 WinSetState($ActiveWindows[$1], @SW_MINIMIZE) Next And vice versa for restore. So .. Mainly prob #1 that I need some help with, and a thought about the "always one window at taskbar"-issue. Just point me in the right direction and I'll hopefully solve it myself ^__^' Thanks, and have a great weekend! zvvyt
  3. Hi guys, I'm try to create a gui can be create element by itself. This is what i have done: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIResizeMode", BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE)) Global Const $Element_For_Column = 5 ; Max number of element for column Global Const $Max_Element = 15 ; Number of total element Global $iCount = 1 ; Number 1 is used for basic element Global $Move_Top, $Move_Left, $Temp_iCount Global $Input_[1][1], $Label_[1][1], $Button_[1][2] $hGUI = GUICreate("Dynamic GUI", 233, 107, -1, -1) $Label_A1 = GUICtrlCreateLabel("This is a label n°1", 8, 26, 90, 17) $Input_A1 = GUICtrlCreateInput("", 8, 43, 161, 21) $Button_A1 = GUICtrlCreateButton("1", 176, 41, 51, 25) $Button_A2 = GUICtrlCreateButton("Check Input", 8, 72, 75, 25) $Button_Minus = GUICtrlCreateButton("-", 176, 2, 19, 25) $Button_Plus = GUICtrlCreateButton("+", 210, 2, 19, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button_A1 GUICtrlSetData($Input_A1, "You have clicked button 1") Case $Button_A2 _Test_Func($Input_A1) Case $Button_Plus _Add_Element() Case $Button_Minus Delete_Element() Case Else For $i = 0 To UBound($Button_, 1) - 1 Switch $msg Case $Button_[$i][0] GUICtrlSetData($Input_[$i][0], "You have clicked button " & $i + 1) Case $Button_[$i][1] _Test_Func($Input_[$i][0]) EndSwitch Next EndSwitch WEnd Func _Test_Func($Value) MsgBox(0, 0, "This is the value of Input: " & GUICtrlRead($Value) & @CRLF) EndFunc ;==>_Test_Func Func _Add_Element() Global $hGUISize_Height = 89, $hGUISize_Width = 250 Local Const $Size = WinGetPos($hGUI) $Temp_iCount += 1 $iCount += 1 $Move_Top += 90 If $Temp_iCount = $Element_For_Column Then If $iCount <= $Max_Element Then WinMove($hGUI, "", Default, Default, $Size[2] + $hGUISize_Width, Default) _Middle($hGUI, "") $Move_Top = 0 ; reset top $Move_Left += 250 ; create left vaule $Temp_iCount = 0 ; reset temp_element EndIf EndIf If $iCount <= $Max_Element Then ReDim $Label_[$iCount][$iCount] ReDim $Input_[$iCount][$iCount] ReDim $Button_[$iCount][$iCount * 2] If $iCount <= $Element_For_Column Then $Label_[$iCount - 1][0] = GUICtrlCreateLabel("This is a label n°" & $iCount, 8, 26 + $Move_Top, 90, 17) $Input_[$iCount - 1][0] = GUICtrlCreateInput("", 8, 43 + $Move_Top, 161, 21) $Button_[$iCount - 1][0] = GUICtrlCreateButton($iCount, 176, 41 + $Move_Top, 51, 25) $Button_[$iCount - 1][1] = GUICtrlCreateButton("Check Input", 8, 72 + $Move_Top, 75, 25) WinMove($hGUI, "", Default, Default, Default, $Size[3] + $hGUISize_Height) _Middle($hGUI, "") Else $Label_[$iCount - 1][0] = GUICtrlCreateLabel("This is a label n°" & $iCount, 8 + $Move_Left, 26 + $Move_Top, 90, 17) $Input_[$iCount - 1][0] = GUICtrlCreateInput("", 8 + $Move_Left, 43 + $Move_Top, 161, 21) $Button_[$iCount - 1][0] = GUICtrlCreateButton($iCount, 176 + $Move_Left, 41 + $Move_Top, 51, 25) $Button_[$iCount - 1][1] = GUICtrlCreateButton("Check Input", 8 + $Move_Left, 72 + $Move_Top, 75, 25) EndIf EndIf If $iCount > $Max_Element Then $iCount = $Max_Element $Temp_iCount = $Element_For_Column - 1 EndIf EndFunc ;==>_Add_Element Func Delete_Element() Local Const $Size = WinGetPos($hGUI) Local $Temp_Move_Top = 90 ; Equal to $Move_Top If $iCount = 1 Then ; No element $iCount = 1 Return Else GUICtrlDelete($Label_[$iCount - 1][0]) ; delete element GUICtrlDelete($Input_[$iCount - 1][0]) ; delete element GUICtrlDelete($Button_[$iCount - 1][0]) ; delete element GUICtrlDelete($Button_[$iCount - 1][1]) ; delete element EndIf If $iCount <> 0 Then If $iCount <= $Element_For_Column Then WinMove($hGUI, "", Default, Default, Default, $Size[3] - $hGUISize_Height) ; resize gui _Middle($hGUI, "") EndIf EndIf If $Temp_iCount = 0 Then ; New Column WinMove($hGUI, "", Default, Default, $Size[2] - $hGUISize_Width, Default) ; resize gui _Middle($hGUI, "") $Move_Left -= 250 ; Remove left value $Temp_iCount += $Element_For_Column ; Remove new colum EndIf $iCount -= 1 ; Delete one count $Temp_iCount -= 1; Delete one temp count If $Move_Top = 0 Then ; Equal to start posizion $Move_Top = $Temp_Move_Top * ($Element_For_Column - 1) Else $Move_Top -= 90 ; Delete one position EndIf EndFunc ;==>Delete_Element Func _Middle(Const $win, Const $txt) ; Snippet Valuater - cdkid Local Const $Size = WinGetClientSize($win, $txt) Local Const $y = (@DesktopHeight / 2) - ($Size[1] / 2) Local Const $x = (@DesktopWidth / 2) - ($Size[0] / 2) Return WinMove($win, $txt, $x, $y) EndFunc ;==>_Middle 1) The gui can create element but the size of the width is good only for the second element, then increase every 3°, 4° etc. 2) Buttons don't work because i don't know how to set in the While...WEnd and the realtive function 3) I don't know how to make the creation of 3 element for column until the $Max_Element is reached 4) I don't know how to delete group element ( except the first ) Thanks EDIT: No more to go, if someone has suggestion/improvement just ask
  4. #include <Array.au3> ;;automation to run functions from files $maxFun = 35 Global $v[1] For $l = 1 To $maxFun Step 1 _ArrayAdd ($v[$maxFun] = FileReadLine("C:\IanLogTest\functionLog.log", $l)) Next MsgBox("", "count", $v[$maxFun]) so that is my whole script... what i want it to do is have $maxFun be a text document and the maximum number of lines in the text doc is 35 at any given time.. and then add each line as an element to my array ($v[]). i just dont know how to create a blank array without using 35 ["",""...] as "blank" elements... is there an easy way to do this with a FOR loop? i feel that there is.. or should i just write out 35 variables and then $var1 = fileReadLine...... over and over.? Thanks
×
×
  • Create New...