Beiträge von Kanashius
-
-
Hi,
Ich hab mir ein Script für Firefox-Greasemonkey geschrieben, was die Shoutbox kompakter macht und um 100px vergrößert, sodass man mehr als die letzten 1-2 Nachrichten lesen kann.
Falls das noch jemand nutzen möchte:
Code
Alles anzeigen// ==UserScript== // @name Autoit Shoutbox // @version 1 // @grant none // ==/UserScript== var cssStyle = document.createElement('style'); cssStyle.type = 'text/css'; cssStyle.appendChild(document.createTextNode(".userMessage p { margin: 0px; }")); // space around the text cssStyle.appendChild(document.createTextNode(".containerHeadline ~ .containerContent { margin-top: 0px; }")); // space between username and text cssStyle.appendChild(document.createTextNode(".shoutbox.classicDesign .shoutboxEntryList li.shoutboxEntry { padding: 0px; }")); // space around a message entry cssStyle.appendChild(document.createTextNode(".shoutbox { --shoutboxHeight: 350px; }")); // shoutbox height document.getElementsByTagName("head")[0].appendChild(cssStyle);
Vorher/Nachher:
Spoiler anzeigen
MfG,
Kanashius
-
Hi
Das hab ich tatsächlich übersehenHier eine Lösung:
AutoIt
Alles anzeigen#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <ListBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $iWidth = 800, $iHeight = 600, $iSpace = 10, $iCtrlHeight = 25 Global $arActions = [["Msgbox 1", "_msgbox", True], ["Msgbox 2", "_msgbox", True], ["Msgbox 3", "_msgbox", True], _ ["Msgbox 4", "_msgbox", True], ["Msgbox 5", "_msgbox", True], ["Msgbox 6", "_msgbox", True], _ ["Msgbox 7", "_msgbox", True], ["Msgbox 8", "_msgbox", True], ["Test Moin", "_testmoin", False], _ ["Just do", "_justdo"]] Global $arActionsCurr[UBound($arActions)] ;Local $arActions[300][3] ;For $i=0 To UBound($arActions)-1 Step 1 ;$arActions[$i][0] = "Msgbox "&$i ;$arActions[$i][1] = "_msgbox" ;$arActions[$i][2] = True ;Next $hGui = GUICreate("Search test", $iWidth, $iHeight) GUISetFont(10, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Suche: ", $iSpace, $iSpace+5, 45, $iCtrlHeight-5) $iInputSearch = GUICtrlCreateInput("", 45+$iSpace*2, $iSpace, ($iWidth-45)-3*$iSpace, $iCtrlHeight) $hInputSearch = GUICtrlGetHandle($iInputSearch) GUICtrlSetCursor (-1, 5) $iListActions = GUICtrlCreateList("", $iSpace, $iSpace*2+$iCtrlHeight, $iWidth-2*$iSpace, $iHeight-3*$iSpace-$iCtrlHeight, BitOR($WS_BORDER, $WS_VSCROLL)) $hListActions = GUICtrlGetHandle($iListActions) _FilterList() GUICtrlSetCursor (-1, 0) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _msgbox($iIndex) MsgBox(64, "Info", $arActions[$iIndex][0]&" >> At list index "&$iIndex&" was pressed.") EndFunc Func _testmoin() MsgBox(64, "Info", "Test Moin") EndFunc Func _justdo() MsgBox(64, "Info", "Just Do") EndFunc ; Error: 1 -> Illegal index argument ; Error: 2 -> No item selected ; Error: 3 -> Index not specified in action array Func _ActionListSelect($iIndex=Default) If $iIndex<>Default Then ; Check if the index is a number and in range If Not IsInt($iIndex) Or $iIndex<0 Or $iIndex>=_GUICtrlListBox_GetCount($iListActions) Then Return SetError(1, 0, -1) _GUICtrlListBox_SetCurSel($iListActions, $iIndex) EndIf $iIndex = _GUICtrlListBox_GetCurSel($iListActions) If $iIndex<0 Then Return SetError(2, 0, -1) _GUICtrlListBox_SetCurSel($iListActions, -1) If Not $iIndex<UBound($arActionsCurr) Then SetError(3, 0, -1) ConsoleWrite($iIndex&":"&$arActionsCurr[$iIndex]&@crlf) $iIndex = $arActionsCurr[$iIndex] ; map index from filtered to original If $arActions[$iIndex][1]<>"" Then If $arActions[$iIndex][2]<>"" Or $arActions[$iIndex][2] Then Call($arActions[$iIndex][1], $iIndex) Else Call($arActions[$iIndex][1]) EndIf EndIf EndFunc Func _FilterList($sSearch="") _GUICtrlListBox_BeginUpdate($iListActions) _GUICtrlListBox_ResetContent($iListActions) Local $iCount = 0 If $sSearch="" Then For $i=0 To UBound($arActions)-1 Step 1 _GUICtrlListBox_AddString($iListActions, $arActions[$i][0]) $arActionsCurr[$iCount] = $i $iCount+=1 Next Else For $i=0 To UBound($arActions)-1 Step 1 If StringInStr($arActions[$i][0], $sSearch, 0) Then _GUICtrlListBox_AddString($iListActions, $arActions[$i][0]) $arActionsCurr[$iCount] = $i $iCount+=1 EndIf Next EndIf _GUICtrlListBox_EndUpdate($iListActions) EndFunc Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $iIDFrom = _WinAPI_LoWord($iwParam), $iCode = _WinAPI_HiWord($iwParam) Switch $ilParam Case $hInputSearch Switch $iCode Case $EN_CHANGE _FilterList(GUICtrlRead($iInputSearch)) EndSwitch Case $hListActions If $iCode=$LBS_NOTIFY Then _ActionListSelect() If @error Then Switch @error ; 1 cannot happen; no index provided Case 2 MsgBox(16, "Error", "No Action was selected!") Case 3 MsgBox(16, "Error", "There is no Action for the index of the selected item!") EndSwitch EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc
MfG,
Kanashius
-
Hi,
so würde ich das umsetzen.
Ein Array mit allen Actions (2D mit Name zum anklicken, Function zum Aufrufen und ein Bool, ob der Index übergeben werden soll.
Wenn man sich für WM_COMMAND Messages registriert, wird die Methode unten aufgerufen, wenn mit einem Control interagiert wird; Hier das anklicken in der Listbox und das Tippen im Inputfeld.
Die Funktionen _ActionListSelect($iIndex=Default) und _FilterList($sSearch="") werden dann aufgerufen. Sie sind aber gleichzeitig auch so gestaltet, dass sie auch manuell aufgerufen werden können.
Das mach ich z.B. um am Anfang die Liste zu füllen.
AutoIt
Alles anzeigen#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <ListBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $iWidth = 800, $iHeight = 600, $iSpace = 10, $iCtrlHeight = 25 Global $arActions = [["Msgbox 1", "_msgbox", True], ["Msgbox 2", "_msgbox", True], ["Msgbox 3", "_msgbox", True], _ ["Msgbox 4", "_msgbox", True], ["Msgbox 5", "_msgbox", True], ["Msgbox 6", "_msgbox", True], _ ["Msgbox 7", "_msgbox", True], ["Msgbox 8", "_msgbox", True], ["Test Moin", "_testmoin", False], _ ["Just do", "_justdo"]] $hGui = GUICreate("Search test", $iWidth, $iHeight) GUISetFont(10, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Suche: ", $iSpace, $iSpace+5, 45, $iCtrlHeight-5) $iInputSearch = GUICtrlCreateInput("", 45+$iSpace*2, $iSpace, ($iWidth-45)-3*$iSpace, $iCtrlHeight) $hInputSearch = GUICtrlGetHandle($iInputSearch) GUICtrlSetCursor (-1, 5) $iListActions = GUICtrlCreateList("", $iSpace, $iSpace*2+$iCtrlHeight, $iWidth-2*$iSpace, $iHeight-3*$iSpace-$iCtrlHeight, BitOR($WS_BORDER, $WS_VSCROLL)) $hListActions = GUICtrlGetHandle($iListActions) _FilterList() GUICtrlSetCursor (-1, 0) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _msgbox($iIndex) MsgBox(64, "Info", $arActions[$iIndex][0]&" >> At list index "&$iIndex&" was pressed.") EndFunc Func _testmoin() MsgBox(64, "Info", "Test Moin") EndFunc Func _justdo() MsgBox(64, "Info", "Just Do") EndFunc ; Error: 1 -> Illegal index argument ; Error: 2 -> No item selected ; Error: 3 -> Index not specified in action array Func _ActionListSelect($iIndex=Default) If $iIndex<>Default Then ; Check if the index is a number and in range If Not IsInt($iIndex) Or $iIndex<0 Or $iIndex>=_GUICtrlListBox_GetCount($iListActions) Then Return SetError(1, 0, -1) _GUICtrlListBox_SetCurSel($iListActions, $iIndex) EndIf $iIndex = _GUICtrlListBox_GetCurSel($iListActions) If $iIndex<0 Then Return SetError(2, 0, -1) _GUICtrlListBox_SetCurSel($iListActions, -1) If Not $iIndex<UBound($arActions) Then SetError(3, 0, -1) If $arActions[$iIndex][1]<>"" Then If $arActions[$iIndex][2]<>"" Or $arActions[$iIndex][2] Then Call($arActions[$iIndex][1], $iIndex) Else Call($arActions[$iIndex][1]) EndIf EndIf EndFunc Func _FilterList($sSearch="") _GUICtrlListBox_BeginUpdate($iListActions) _GUICtrlListBox_ResetContent($iListActions) If $sSearch="" Then For $i=0 To UBound($arActions)-1 Step 1 _GUICtrlListBox_AddString($iListActions, $arActions[$i][0]) Next Else For $i=0 To UBound($arActions)-1 Step 1 If StringInStr($arActions[$i][0], $sSearch, 0) Then _GUICtrlListBox_AddString($iListActions, $arActions[$i][0]) Next EndIf _GUICtrlListBox_EndUpdate($iListActions) EndFunc Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $iIDFrom = _WinAPI_LoWord($iwParam), $iCode = _WinAPI_HiWord($iwParam) Switch $ilParam Case $hInputSearch Switch $iCode Case $EN_CHANGE _FilterList(GUICtrlRead($iInputSearch)) EndSwitch Case $hListActions If $iCode=$LBS_NOTIFY Then _ActionListSelect() If @error Then Switch @error ; 1 cannot happen; no index provided Case 2 MsgBox(16, "Error", "No Action was selected!") Case 3 MsgBox(16, "Error", "There is no Action for the index of the selected item!") EndSwitch EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc
Ich hoffe, das hilft dir weiter.
Mfg, Kanashius
-
Meines Wissens nach müssen nicht alle Inserts in ein _SQLite_Exec um in eine Transaktion ("BEGIN;...COMMIT;") zu kommen.
Du solltest also einfach
AutoIt_SQLite_Exec($hSQL, 'BEGIN TRANSACTION;') For $i=0 to 10 Step 1 _SQLite_Exec($hSQL, StringFormat("INSERT INTO tab1 VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s');", $i, _ $aSplit[0], $aSplit[1], $aSplit[2], $aSplit[3], $aSplit[4], $aSplit[5])) Next _SQLite_Exec($hSQL, 'COMMIT;')
aufrufen können.
Ansonsten halt in mehrere Transaktionen aufteilen.
Ich weiß nicht, ob die dann trotzdem als ein command gelten, oder nacheinander ausgeführt werden und nur für ein mögliches rollback relevant sind.
Ansonsten dürfte das hier relevant sein:
Code
Alles anzeigenMaximum Length Of An SQL Statement The maximum number of bytes in the text of an SQL statement is limited to SQLITE_MAX_SQL_LENGTH which defaults to 1,000,000,000. If an SQL statement is limited to be a million bytes in length, then obviously you will not be able to insert multi-million byte strings by embedding them as literals inside of INSERT statements. But you should not do that anyway. Use host parameters for your data. Prepare short SQL statements like this: INSERT INTO tab1 VALUES(?,?,?); Then use the sqlite3_bind_XXXX() functions to bind your large string values to the SQL statement. The use of binding obviates the need to escape quote characters in the string, reducing the risk of SQL injection attacks. It also runs faster since the large string does not need to be parsed or copied as much. The maximum length of an SQL statement can be lowered at run-time using the sqlite3_limit(db,SQLITE_LIMIT_SQL_LENGTH,size) interface.
Die länge einer einzelnen insert value (die Musashi erwähnte) dürfte dabei nicht so relevant sein.
-
Hi
C:\Utils32\svcl.exe /SetVolume "Stereomix" 80 ist Run("C:\Utils32\svcl.exe /SetVolume "Stereomix" 80, @SW_HIDE) ist kein valider AutoIt Code, von daher vermute ich einfach mal, dass du es mit Run versuchst...
Dein Problem ist vermutlich, dass du " zeichen in dem Befehl hast, weil der Lautsprechername Leerzeichen enthält.
In AutoIt werden Quotes (") für Strings genutzt. Um das Zeichen in einem String zu haben musst du entweder das Alternative Zeichen ' nutzen, um den String zu umschließen, oder du musst die " escapen, was in AutoIt mit Doppelung => "" gemacht wird.
Also:
AutoItLocal $sString $sString = "Dies ist ein String" $sString = 'Dies ist ein "String"' $sString = "Dies ist ein ""String""" $sString = "Dies ist ein " & '"' & "String" & '"'
Um mehrfach den gleichen Code zu vermeiden und Fehlerbehandlung hinzuzufügen, würde ich das ganze vermutlich so, oder so ähnlich umsetzen:
AutoIt
Alles anzeigen; https://www.nirsoft.net/utils/sound_volume_command_line.html Local $sNvidia = "NVIDIA High Definition Audio\Device\ROG PG348Q\Render", $sHighDef = "High Definition Audio Device\Device\Lautsprecher\Render", $sStereomix = "Stereomix", $sSpeaker = "Lautsprecher" _audioSetVolume($sStereomix, 80) If @error Then MsgBox(16, "Error", @error&":"&@extended) _audioSetState($sNvidia, False) If @error Then MsgBox(16, "Error", @error&":"&@extended) _audioSetState($sNvidia) If @error Then MsgBox(16, "Error", @error&":"&@extended) _audioSetDefault($sHighDef) If @error Then MsgBox(16, "Error", @error&":"&@extended) _audioSetVolume($sSpeaker, 60) If @error Then MsgBox(16, "Error", @error&":"&@extended) Func _audioSetVolume($sSpeaker, $iVolume) _runUtils("/SetVolume", $sSpeaker, String($iVolume)) If @error Then Return SetError(@error, @extended, -1) Return 1 EndFunc Func _audioSetDefault($sSpeaker, $bAll = True) If $bAll Then _runUtils("/SetDefault", $sSpeaker, "all") Else _runUtils("/SetDefault", $sSpeaker) EndIf If @error Then Return SetError(@error, @extended, -1) Return 1 EndFunc Func _audioSetState($sSpeaker, $bEnable = True, $bAll = True) If $bAll Then _runUtils($bEnable?"/Enable":"/Disable", $sSpeaker, "all") Else _runUtils($bEnable?"/Enable":"/Disable", $sSpeaker) EndIf If @error Then Return SetError(@error, @extended, -1) Return 1 EndFunc Func _runUtils($sCommand, $sParam0 = Default, $sParam1 = Default, $sParam2 = Default, $sParam3 = Default, $sParam4 = Default, $sParam5 = Default) For $i=0 To @NumParams-2 Step 1 Local $sParam = String(Eval("sParam"&$i)) If StringInStr($sParam, " ") Then $sParam='"'&$sParam&'"' $sCommand&=" "&$sParam Next ConsoleWrite("C:\Utils32\svcl.exe "&$sCommand&@crlf) Run("C:\Utils32\svcl.exe "&$sCommand, @ScriptDir, @SW_HIDE) ; or this: ShellExecute("C:\Utils32\svcl.exe", $sCommand, @ScriptDir, @SW_HIDE) If @error Then Return SetError(1, @error, -1) ; todo: use the stdout to check if the command was successful Return 1 EndFunc
-
Hi
Deine Fehlermeldung zeigt, dass die genutzte Version von MySQL zu alt ist und nicht mehr funktioniert.Laut https://github.com/BugFix/AutoIt_…sql_version.au3 nutzt die UDF MySQL 5.1.37
Wenn man auf https://endoflife.date/mysql geht, kann man sehn, dass das schon länger nicht mehr unterstützt wird und nach dem was ich gelesen habe auch keine Verschlüsselung (TLS) unterstützt.
Sprich: Jeder MITM (man in the middle) kann mitlesen, was du über die Verbindung sendest/empfängst.
Wenn ne Webseite dir also die Verbindung damit erlaubt, würde ich mir überlegen den Anbieter zu wechseln, der scheint nämlich keinen großen Wert auf Sicherheit zu legen.
-
Ich würde sagen: Wissen ist macht .
Also füg am besten logging zu deinem Programm hinzu, sodass du herausfinden kannst, wo genau das Programm hängen bleibt, sodass du das beheben kannst.
Ein "Hilfsprogramm" zum beenden ist keine wirklich gute Lösung, sondern nur ein (meiner Meinung nach schlechter) Workaround, weil das eigentliche Problem komplett ignoriert wird.
Und ja, Fehlersuche+Behebung kann nervig sein, dafür wird man mit einem gut laufenden Programm belohnt
-
Ich denke du hast da Regular Expressions mit dem Pseudo Zeug verwechselt, das manchmal bei Pfaden,... verwendet wird.
* ist bei Regular Expressions ein Quantifier, der nur angibt, wie oft das vorher auftauchen muss. * steht dabei für 0 oder mehr.
Die Quickreference auf https://regex101.com/ ist recht nett, wenn du mal schauen möchtest, was es alles gibt und die Webseite ist auch sehr hilfreich um zu sehen, was ein RegExp macht, weil an der rechten Seite aufgelistet wird, was genau passiert.
-
Du suchst nach StringStripWS, da kannst du auch angeben ob führende/endende,... whitespaces (leerzeichen, tabs, zeilenende,...) entfernt werden sollen.
-
Wortspiel der Ersteller. Dracula ist auch nen Theme, hat aber nen complett anderes Farbschema
Ich hab auch erst nach Dracula gesucht und war verwirrt
-
-
Ich hab mein SciTE vor einiger Zeit auch aufs Darktheme umgestellt, mich dabei aber an JetBrains IntelliJ darktheme orientiert (In Scite geändert mit Tools -> Scite Config -> Editor Colors).
Falls jemand das design lieber mag
EDIT: Hab die Datei hier gelöscht, da ich das ganze neu+besser umgesetzt habe: Beitrag weiter unten
-
Da das Programm, mit dem du die CD/DVD beschreibst für den Inhalt verantwortlich ist, der geschrieben wird, wäre die Systemzeit zu ändern vmtl. am einfachsten...
Ansonsten müsstest du das Programm zum beschreiben der CD/DVD ändern/selbst schreiben, was etwas komplexer wäre
-
Wenn du damit andere Server meinst lautet das Stichwort NTP.
Ist Netzwerk, also mit TCP/UDP machbar. Hab auch direkt was gefunden:
Update system time based on NTP server timeBased on codes in an old AutoIt Forum, I made the following code and it works perfectly. But I have couple of questions on how it works. I have to ask the…www.autoitscript.com -
Hi
Ich konnte das Problem leider nicht nachstellen. Vermutlich ist meine Hardware etwas schneller.
Mein erster Ansatz wäre das Neuzeichnen des Childs während des Scrollens zu verhindern (evtl. auch des Parents).
AutoIt#include <WindowsConstants.au3> _SendMessage($hGui, $WM_SETREDRAW, False) ; disable window drawing ; scrolling => your code >> _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, $iCurScrollPos + 5) _SendMessage($hGui, $WM_SETREDRAW, True) ; enable window drawing _WinAPI_RedrawWindow($hGui) ; manually trigger a redraw
-
Hi
Wenns nur mit Zahlen zugegriffen werden soll: Nen 2D-Array
Wenns auch mit andere Variablentypen gehen soll: Maps
Beides in dem Beispiel hier:
AutoIt
Alles anzeigen#include<Array.au3> ; 2D Array Local $arData[12][4] For $i=0 To UBound($arData)-1 Step 1 For $j=0 To UBound($arData, 2)-1 Step 1 $arData[$i][$j] = $i*UBound($arData, 2)+$j Next Next _ArrayDisplay($arData) ConsoleWrite($arData[3][2]&@crlf) ; Map Local $mData[], $arData1 = [1,4,3,5], $arData2 = [3,2,2,4] $mData["Array1"] = $arData1 $mData["Array2"] = $arData2 _ArrayDisplay($mData["Array1"]) _ArrayDisplay($mData["Array2"])
Lg, Kanashius
-
Ich vermute mal du nutzt SQLite.
SQLite kann zwar mit mehreren Anwendungen gleichzeitig lesen, aber nur mit einer schreiben.
SQLite FAQ: Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. But only one process can be making changes to the database at any moment in time, however.
In diesem Fall würde ich aber vermuten, dass Windows die Datei lokal cached, solange sie offen ist und erst am Ende auf die Netzwerkdatei schreibt.
Probier mal aus, ob die Daten da sind, wenn du deine schreibende Anwendung beendest.
Wenn das der Fall ist: Probier mal mit SQLITE_Close die Datenbank zu schließen und schau ob dann die Daten geschrieben wurden.
Wäre etwas doof, weils mehr Zeit kostet, wenn du jedesmal die Datenbank öffnen und wieder schließen musst, aber wenn du nur zwischendurch mal was schreibst sollte das gehen.
-
Deine Problemstellung hat mich zu dieser Lösung inspiriert
Es geht in Richtung UDF, es fehlen aber noch setter/getter Methoden und die documentation,... . Ich werds vermutlich demnächst dazu machen und das dann auch hier im Forum posten; mir fehlt grad die Zeit.
Mit der Methode kann ein GridLayout erstellt werden, bei dem dann andere Controls, GridLayouts oder auch einfach Funktionen (mit den passenden Parametern) hinzugefügt werden.
Dabei wird die Position im Grid mit dem Index für die Reihe/Spalte angegeben und dann wird noch die Höhe der Reihe/Breite der Spalte als Prozent wert von 0 bis 1 angegeben. Es zählt immer der letzte Aufruf, wenn mehrere Einträge in einer Reihe eine Höhe angeben; Default behält die vorherige angabe bei.
Wenn gar kein Wert angegeben wird, werden von allen angegebenen Reihen/Spalten die Prozent-Werte abgezogen und der übrige Platz wird gleichmäßig auf die übrigen Reihen/Spalten verteilt.
AutoIt
Alles anzeigen#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Global $iStartWidth = @DesktopWidth/1.7, $iStartHeight = @DesktopHeight/1.7, $iSpace = 10 Global $hMainGui = GUICreate('Gui', $iStartWidth, $iStartHeight, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) GUISetBkColor(0x555555, $hMainGui) GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") Global $idButton = GUICtrlCreateButton("RESIZE", $iSpace, $iSpace, $iStartWidth-2*$iSpace) GUICtrlSetOnEvent($idButton, "_buttonResize") ; generate button and button grid layout Global $mLayoutButtons = __GuiCtrlGridLayout_Create($hMainGui, 10, 10, 10, 10, 10) Global $arButtons[2][4] For $i=0 To UBound($arButtons)-1 Step 1 For $j=0 To UBound($arButtons, 2)-1 Step 1 $arButtons[$i][$j] = GUICtrlCreateButton("Test "&$i&":"&$j, 10, 10, 10, 10) __GuiCtrlGridLayout_Add($mLayoutButtons, $arButtons[$i][$j], $i, $j) Next Next ; generate labels Global $arLabels[4] For $i=0 To UBound($arLabels)-1 Step 1 $arLabels[$i] = GUICtrlCreateLabel("Test "&$i, 10, 10, 10, 10) GUICtrlSetBkColor($arLabels[$i], 0x999999) Next ; generate treeviews Global $arTreeViews[4] For $i=0 To UBound($arTreeViews)-1 Step 1 $arTreeViews[$i] = GUICtrlCreateTreeView(120, 10, 100, 100, $GUI_SS_DEFAULT_TREEVIEW) Local $idRoot = GUICtrlCreateTreeViewItem("Root", $arTreeViews[$i]) GUICtrlCreateTreeViewItem("Child 1", $idRoot) GUICtrlCreateTreeViewItem("Child 2", $idRoot) Next ; create main layout Global $mLayoutMain = __GuiCtrlGridLayout_Create($hMainGui, $iSpace, $iSpace+50, $iStartWidth-$iSpace*2, $iStartHeight-$iSpace*2-50, $iSpace) __GuiCtrlGridLayout_Add($mLayoutMain, $arTreeViews[0], 0, 0, 0.4, 0.4) __GuiCtrlGridLayout_Add($mLayoutMain, $mLayoutButtons, 0, 1) __GuiCtrlGridLayout_Add($mLayoutMain, $arTreeViews[1], 0, 2, 0.3) __GuiCtrlGridLayout_Add($mLayoutMain, $arTreeViews[2], 2, 0, 0.3, 0.6) __GuiCtrlGridLayout_Add($mLayoutMain, "_resizeLabels", 2, 1) __GuiCtrlGridLayout_Add($mLayoutMain, $arTreeViews[3], 2, 2, 0.4) ;__GuiCtrlGridLayout_Add($mLayoutTreeViews, "_resizeButtons", 0, 1) __GuiCtrlGridLayout_Update($mLayoutMain) GUIRegisterMsg($WM_SIZE, "_WM_SIZE") GUISetState(@SW_SHOW) While Sleep(10) Wend Func _buttonResize() __GuiCtrlGridLayout_Update($mLayoutMain, $iSpace, $iSpace+50, $iStartWidth/2, $iStartHeight/2) EndFunc Func _resizeLabels($iLeft, $iTop, $iWidth, $iHeight) For $i=0 To UBound($arLabels)-1 Step 1 GUICtrlSetPos($arLabels[$i], $iLeft, $iTop+$i*30, $iWidth, 25) Next EndFunc Func OnExit() Exit EndFunc Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) If $hWnd=$hMainGui Then Local $arSize = WinGetClientSize($hWnd) __GuiCtrlGridLayout_Update($mLayoutMain, $iSpace, $iSpace+50, $arSize[0]-$iSpace*2, $arSize[1]-$iSpace*2-50) EndIf Return $GUI_RUNDEFMSG EndFunc ; below here is needed for the grid layout; above is just the example Func __GuiCtrlGridLayout_Create($hGui, $iLeft, $iTop, $iWidth, $iHeight, $iControlSpace = 10) Local $mData[] $mData.gui = $hGui $mData.left = $iLeft $mData.top = $iTop $mData.width = $iWidth $mData.height = $iHeight $mData.space = $iControlSpace Local $mRows[] $mData.rows = $mRows Return $mData EndFunc ; $idControl: control id OR a string with the function name of a function with 4 parameters (fLeft, fTop, fWidth, fHeight) OR a map->other grid layout Func __GuiCtrlGridLayout_Add(ByRef $mLayout, $idControl, $iRow, $iCol, $iColWidthFactor = Default, $iRowHeightFactor = Default) Local $mRows = $mLayout.rows If Not MapExists($mRows, $iRow) Then Local $mData[] $mData.heightFactor = $iRowHeightFactor Local $mTmp[] $mData.cols = $mTmp $mRows[$iRow] = $mData Else Local $mData = $mRows[$iRow] If $iRowHeightFactor<>Default Then $mData.heightFactor = $iRowHeightFactor $mRows[$iRow] = $mData EndIf Local $mCols = $mRows[$iRow].cols If Not MapExists($mCols, $iCol) Then Local $mData[] $mData.control = $idControl $mData.widthFactor = $iColWidthFactor $mCols[$iCol] = $mData Else Local $mData=$mCols[$iCol] $mData.control = $idControl If $iColWidthFactor<>Default Then $mData.widthFactor = $iColWidthFactor $mCols[$iCol] = $mData EndIf $mRows[$iRow].cols = $mCols $mLayout.rows = $mRows __GuiCtrlGridLayout_Update($mLayout) EndFunc Func __GuiCtrlGridLayout_Update(ByRef $mLayout, $iLeft = Default, $iTop = Default, $iWidth = Default, $iHeight = Default, $iControlSpace = Default) ; update $mLayout with parameters If $iLeft<>Default And IsNumber($iLeft) Then $mLayout.left = $iLeft If $iTop<>Default And IsNumber($iLeft) Then $mLayout.top = $iTop If $iWidth<>Default And IsNumber($iWidth) And $iWidth>=0 Then $mLayout.width = $iWidth If $iHeight<>Default And IsNumber($iHeight) And $iHeight>=0 Then $mLayout.height = $iHeight If $iControlSpace<>Default And IsNumber($iControlSpace) And $iControlSpace>=0 Then $mLayout.space = $iControlSpace Local $arRows = MapKeys($mLayout.rows) If UBound($arRows)>0 Then _ArraySort($arRows) Local $iMaxRow = $arRows[UBound($arRows)-1] If $iMaxRow<>UBound($arRows)-1 Then ReDim $arRows[$iMaxRow+1] EndIf Local $iHFact = 0, $iHAmountFact = 0 For $i=0 To UBound($arRows)-1 Step 1 If MapExists($mLayout.rows, $i) And $mLayout.rows[$i].heightFactor<>Default Then $arRows[$i] = $mLayout.rows[$i].heightFactor $iHFact += $arRows[$i] $iHAmountFact+=1 Else $arRows[$i] = -1 EndIf Next Local $iHUnspezRows = (1-$iHFact)/(UBound($arRows)-$iHAmountFact) If $iHUnspezRows<0 Then $iHUnspezRows=0 For $i=0 To UBound($arRows)-1 Step 1 If $arRows[$i]<0 Then $arRows[$i] = $iHUnspezRows Next $iTop = $mLayout.top $iHeight = $mLayout.height-$mLayout.space*(UBound($arRows)-1) If $iHeight<0 Then $iHeight = 0 For $i=0 To UBound($arRows)-1 Step 1 Local $iRowHeight = $iHeight*$arRows[$i] If MapExists($mLayout.rows, $i) Then Local $arCols = MapKeys($mLayout.rows[$i].cols) _ArraySort($arCols) Local $iMaxCol = $arCols[UBound($arCols)-1] If $iMaxCol<>UBound($arCols)-1 Then ReDim $arCols[$iMaxCol+1] EndIf Local $iWFact = 0, $iWAmountFact = 0 For $j=0 To UBound($arCols)-1 Step 1 If MapExists($mLayout.rows[$i].cols, $j) And $mLayout.rows[$i].cols[$j].widthFactor<>Default Then $arCols[$j] = $mLayout.rows[$i].cols[$j].widthFactor $iWFact += $arCols[$j] $iWAmountFact+=1 Else $arCols[$j] = -1 EndIf Next Local $iWUnspezCols = (1-$iWFact)/(UBound($arCols)-$iWAmountFact) If $iWUnspezCols<0 Then $iWUnspezCols=0 For $j=0 To UBound($arCols)-1 Step 1 If $arCols[$j]<0 Then $arCols[$j] = $iWUnspezCols Next $iLeft = $mLayout.left $iWidth = $mLayout.width-$mLayout.space*(UBound($arCols)-1) For $j=0 To UBound($arCols)-1 Step 1 Local $iColWidth = $iWidth*$arCols[$j] If MapExists($mLayout.rows[$i].cols, $j) Then If IsString($mLayout.rows[$i].cols[$j].control) Then Call($mLayout.rows[$i].cols[$j].control, $iLeft, $iTop, $iColWidth, $iRowHeight) ElseIf IsMap($mLayout.rows[$i].cols[$j].control) Then Local $mMap = $mLayout.rows[$i].cols[$j].control __GuiCtrlGridLayout_Update($mMap, $iLeft, $iTop, $iColWidth, $iRowHeight) $mLayout["rows"][$i]["cols"][$j]["control"] = $mMap Else GUICtrlSetPos($mLayout.rows[$i].cols[$j].control, $iLeft, $iTop, $iColWidth, $iRowHeight) EndIf ;ConsoleWrite($mLayout.rows[$i].cols[$j].control&" :> "&$i&":"&$j&">>"&$iTop&" "&$iRowHeight&" > "&$iLeft&" "&$iColWidth&@crlf) ;Else ;ConsoleWrite("- :> "&$i&":"&$j&">>"&$iTop&" "&$iRowHeight&" > "&$iLeft&" "&$iColWidth&@crlf) EndIf $iLeft+=$iColWidth+$mLayout.space Next EndIf $iTop+=$iRowHeight+$mLayout.space Next EndIf EndFunc
Das ganze wird dann zu diesem Design:
Dabei werden die TreeViews als Control in das GridLayout eingefügt, die Buttons in ein weiteres GridLayout, welches dann in das Main GridLayout integriert wird.
Die Labels werden mithilfe einer Funktion an die richtige Position gebracht. Es kann also auch für "CustomControls",... verwendet werden, man muss sich dann halt selber um das resizing an die gewollte position/größe selbst kümmern.
Wenn sich die Größe des Fensters ändert wird mit WM_SIZE die position/größe für das MainLayout angepasst.
Viel Spaß damit
-
Hi
Dein Problem liegt darin, dass du For...In...Next nutzt und dann auf das Array zugreifst, als ob es eine Zahl wäre.
Bei For $element In $array wird der Wert, der in dem Array steht in die Variable ($elem) gespeichert, hier also: "1", "2", "3", "4", "{TAB}", "{ALT}". Mich wunderts eher, dass du beim Array-Zugriff keinen Fehler bekommen hast...
Im Code unten hab ich beide Methoden eingebaut, die Funktionieren: Entweder du arbeitest mit For...To...Next und nutzt die Variable als Zahl, oder du nimmst For...In...Next und verwendest den Wert direkt.
Achtung: Mit For...In...Next darfst du das Array während des durchlaufens nur auslesen, aber nicht verändern!
AutoIt
Alles anzeigen#include <Misc.au3> #include <Array.au3> Global $hDLL = DllOpen("user32.dll") #Region ### HotKeys # HotKeySet("{F11}", "Done") Global $gS_ToggleScript = "_KeyToggle" Global $gA_ToggleKeys = ["1", "2", "3", "4", "{ALT}", "{TAB}"] _SetHotToggle() #EndRegion # HotKeys #Region ### Func # Func Done() DllClose($hDLL) Exit EndFunc Func _SetHotToggle() For $i=0 to UBound($gA_ToggleKeys)-1 step 1 HotKeySet($gA_ToggleKeys[$i], $gS_ToggleScript) Next ;- HotKeySet("{TAB}", "_KeyToggle") EndFunc Func _SetHotDefault() For $elem in $gA_ToggleKeys HotKeySet($elem) Next EndFunc Func _KeyToggle() _SetHotDefault() Send("Test3241") _SetHotToggle() EndFunc #EndRegion # Func #Region ### Schleife # While Sleep(10) WEnd #EndRegion # Schleife
Du kannst Arrays direkt bei der deklaration auch initalisieren => mit den Werten füllen. Spart mehrere Zeilen Code und ist auch schneller, weil jedes _ArrayAdd bei jedem Aufruf das gesamte Array kopiert und dann den neuen Wert einträgt, was ziemlich langsam ist. Wird dir hier nicht auffallen, aber wenn du größere Datenmengen verarbeitest und schon vorher weißt, wie viele es sind: Erstell das Array direkt mit der richtigen Größe und trag nur noch die Werte ein.