Wenn die $pid 0 ist, dann wurde der Prozess nicht gefunden und heißt vermutlich anders. Am besten wäre es dann, wenn du $pid=Run("....exe") machst. Run gibt nämlich IMMER die PID aus. (Problem ist nur, wenn du z.b. cmd startest um das programm zu starten. Dann wird die PID von cmd gegeben und nicht von dem Programm selbst.)
Beiträge von Kanashius
-
-
Probier DllStructGetData($tStruct, "fAvatarPosition_x") mal in meinem Script aus. Wenn es dort auch falsch ist guck mal, ob mumble als 32 oder 64 bit kompiliert wurde, und welcher compiler.
Bei win32 wird dort eine andere Struktur genutzt und wchar_t ist compilerabhängig, wie viele bytes das braucht. Ich vermute, dass dort das Problem liegt.Gegebenenfalls mal alles in ein Array aus Bytes lesen, dann mit autoit ausgeben lassen und gucken, wo was steht.
-
Ich denke das wird in diese Richtung gehen. Ich hab mit den Befehlen noch nie gearbeitet
und weiß grad nicht, wie die Struktur von diesem MumbleLink aussieht, aber so etwa sollte es sein:AutoIt
Alles anzeigen#include <WinAPIFiles.au3> global $hMappedFile=0,$pViewAdress=0 ;WCHAR may be different (Compilerspecific see: https://en.wikipedia.org/wiki/Wide_character) global $sStructure32="UINT32 uiVersion;DWORD uiTick;FLOAT fAvatarPosition[3];"& _ "FLOAT fAvatarFront[3];FLOAT fAvatarTop[3];WCHAR name[256];"& _ "FLOAT fCameraPosition[3];FLOAT fCameraFront[3];FLOAT fCameraTop[3];"& _ "WCHAR identity[256];UINT32 context_len;BYTE context[256];"& _ "WCHAR description[2048];" Func _openMumbleLink() $hMappedFile=_WinAPI_OpenFileMapping("MumbleLink") if $hMappedFile=0 then SetError(1) $pViewAdress=_WinAPI_MapViewOfFile($hMappedFile) if $pViewAdress=0 then SetError(2) EndFunc Func _getData() if $hMappedFile=0 then _openMumbleLink() if @error then SetError(1) if $pViewAdress=0 then SetError(2) local $tData = DllStructCreate($sStructure32, $pViewAdress);32Bit ;Die folgenden abfragen müssen angepasst werden $playerInfo.x=DllStructGetData($tData,"fAvatarPosition",0) $playerInfo.y=DllStructGetData($tData,"fAvatarPosition",1) $playerInfo.z=DllStructGetData($tData,"fAvatarPosition",2) $playerInfo.map=DllStructGetData($tData,"context") EndFunc Func _end() if $hMappedFile<>0 then _WinAPI_UnmapViewOfFile($hMappedFile) if $pViewAdress<>0 then _WinAPI_CloseHandle($pViewAdress) EndFunc
Ich hoffe, das hilft dir weiter.EDIT: Hab grad nochmal geschaut und die Struktur in den Code übernommen. So sollte es funktionieren, hoffe ich
(Achte darauf, dass mumble in 32bit compiliert wurde und mit einem compiler der wchar_t wie wchar behandelt, also mit 2Byte)MfG Kanashius
-
Du kannst übrigens auch in deinem Script eine Datei einlesen und dazu passend die Controls erstellen.
Dafür musst du nicht jedesmal ein neues Programm schreibenWas du dafür brauchst:
-Arrays
-FileReadToArray (Oder je nachdem, wie die datei aufgebaut ist etwas anderes)Dann kannst du einfach mit Schleifen durchlaufen:
Beispieldatei:Codename|Erste Umfrage combo|Dies|oder|das check|akzeptiert radio|radio1|radio2|radio3 input|Name:|hier name
Code:AutoIt
Alles anzeigenglobal $sName="unknown" $arControlTexts=FileReadToArray("Beispiel.txt") global $arControls[Ubound($arControlTexts)] for $i=0 to ubound($arControlTexts)-1 step 1 $arControlTexts[$i]=stringsplit($arControlTexts[$i],"|",1+2) local $arTmp=$arControlTexts[$i] if $arTmp[0]="Name" then $sName=$arTmp[1] endif next global $iWidth=800,$iHeight=600 $hGui=guicreate($sName,$iWidth,$iHeight) for $i=0 to ubound($arControlTexts)-1 step 1 local $arTmp=$arControlTexts[$i] switch $arTmp[0] case "combo" $arControls[$i]=guictrlcreatecombo("-",5,5+$i*25,$iWidth-10,25) $sDat="" for $j=1 to ubound($arTmp) step 1 if $sDat<>"" then $sDat&="|" endif $sDat&=$arTmp[$j] next guictrlsetdate(-1,$sDat) case "check" $arControls[$i]=guictrlcreatecheckbox($arTmp[1],5,5+$i*25,$iWidth-10,25) case "radio" local $arC[ubound($arTmp)-1] for $j=1 to ubound($arTmp)-1 step 1 GUIStartGroup() $arC[$j-1]=guictrlcreateradio($arTmp[$j],5,5+$i*25,$iWidth-10,25) next $arControls[$i]=$arC case "input" $arControls[$i]=guictrlcreateinput($arTmp[1],5,5+$i*25,$iWidth-10,25) guictrlsendmsg(-1,0x1501,0,$arTmp[2]) ;... endswitch next guisetstate() While 1 $iMsg=guigetmsg() if $iMsg=-3 then exit WEnd
Das nur mal als Beispiel (kann sein, dass noch irgendwo tippfehler sind, bin auf linux und konnte deshalb nicht testen).
So oder so ähnlich, je nachdem, wie deine Anforderungen sind, kann man das umsetzen.MfG Kanashius
-
Was Übersicht angeht:
Die 2te Gui würde ich auf jedenfall in eine Funktion packen, das sorgt für mehr Übersichtlichkeit in der Hauptschleife.
Außerdem würde ich mit Arrays arbeiten. Damit würdest du viele Redundanzen beim abfragen der Comboboxen sparen (und beim setzen des Status,...)Ich hab das hier mal umgesetzt. Das spart etwa 150 Zeilen, lohnt sich also. Auch weils dann Übersichtlicher ist. (Man kann bestimmt noch mehr verbessern, wenn man genau weiß, was passieren soll. Ich kanns auch momentan nicht ausführen, da ich auf Linux unterwegs bin :))
AutoIt
Alles anzeigen#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> #include <Date.au3> #include <GuiListView.au3> #include <StructureConstants.au3> #include <Array.au3> #include <StaticConstants.au3> #Region ### GRAPHICAL USER INTERFACE (PARENT) ### $GUI = GUICreate("Dienstsuche OST - GMUNDEN", 1600, 900, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) $MenuItem1 = GUICtrlCreateMenu("Aktion") $SubItem1_1 = GUICtrlCreateMenuItem("Dienstsuche starten", $MenuItem1) $SubItem1_2 = GUICtrlCreateMenuItem("Sperren", $MenuItem1) $SubItem1_3 = GUICtrlCreateMenuItem("Beenden", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("Liste") $SubItem2_1 = GUICtrlCreateMenuItem("Anzeigen", $MenuItem2) $SubItem2_2 = GUICtrlCreateMenuItem("Bearbeiten", $MenuItem2) $SubItem2_3 = GUICtrlCreateMenuItem("Exportieren", $MenuItem2) $List1 = GUICtrlCreateListView("", 0, 0, 1600, 880, $LVS_SINGLESEL) GUICtrlSetBkColor($List1, 0X292929) GUICtrlSetFont($List1, 12, 300, -1, "Dunant Light", 5) GUICtrlSetColor($List1, 0XFFFFFF) $contextmenu = GUICtrlCreateContextMenu($List1) $sofort = GUICtrlCreateMenuItem("Sofort", $contextmenu) $dringend = GUICtrlCreateMenuItem("Dringend", $contextmenu) $normal = GUICtrlCreateMenuItem("Normal", $contextmenu) $erledigt = GUICtrlCreateMenuItem("Erledigt", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) $erstellen = GUICtrlCreateMenuItem("Eintrag erstellen", $contextmenu) GUISetState(@SW_SHOWMAXIMIZED) GUISetState(@SW_SHOW) #EndRegion ### GRAPHICAL USER INTERFACE ### _Setup_Scene() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SubItem1_1 ;Dienstsuche starten Case $SubItem1_2 ;Sperren Case $SubItem1_3 ;Beenden Exit Case $SubItem2_1 ;Anzeigen Case $SubItem2_2 ;Bearbeiten Case $SubItem2_3 ;Exportieren Case $sofort ; PRIORITÄTEN werden definiert und eingetragen. _setPriority("█ SOFORT █",1) Case $dringend _setPriority("DRINGEND",2) Case $normal _setPriority("Normal",3) Case $erledigt _setPriority("✔",4) Case $erstellen _createNewEntry() EndSwitch WEnd ; ### FUNKTIONS SEKTION ### ; Hier werden alle Funktionen erstellt. Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func _Setup_Scene() _GUICtrlListView_AddColumn($List1, "Wochentag", 100, 1) _GUICtrlListView_AddColumn($List1, "Datum", 100, 2) _GUICtrlListView_AddColumn($List1, "Priorität", 100, 2) _GUICtrlListView_AddColumn($List1, "Tagdienst 07:00 - 19:00", 250, 2) _GUICtrlListView_AddColumn($List1, "Nachtdienst 19:00 - 07:00", 250, 2) _GUICtrlListView_AddColumn($List1, "Bemerkung", 300, 2) $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($List1, 0xFFFFFF, 16, 16)) ; Weiß _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($List1, 0xFF0000, 16, 16)) ; Rot _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($List1, 0xEC9A4C, 16, 16)) ;Orange _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($List1, 0x00cbff, 16, 16)) ;Blau _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($List1, 0x00FF00, 16, 16)) ;Grün _GUICtrlListView_SetImageList($List1, $hImage, 1) Global $Array[_DateDaysInMonth(@YEAR, @MON) - @MDAY + 1][5] For $i = 0 To _DateDaysInMonth(@YEAR, @MON) - @MDAY Step 1 $Array[$i][1] = _DateTimeFormat(_DateAdd('d', $i, _NowCalcDate()), 2) $Array[$i][0] = _DateDayOfWeek(_DateToDayOfWeek(@YEAR, @MON, @MDAY + $i), 2) Next _GUICtrlListView_AddArray($List1, $Array) EndFunc ;==>_Setup_Scene Func _setPriority($msg,$id) $LastSelection = _GUICtrlListView_GetSelectionMark($List1) _GUICtrlListView_AddSubItem($List1, $LastSelection, $msg, 2) _GUICtrlListView_SetItemImage($List1, $LastSelection, $id) EndFunc Func _createNewEntry() GUISetState(@SW_DISABLE, $GUI) ; Parent-GUI wird disabled. #Region ### Setup Child GUI ### ;Checkbox,Combo local $arControls=[["Einsatzlenker",-1,-1,"-EL"],["Transportführer",-1,-1,"-TF"],["Ambulanzdienst",-1,-1,"-AMD"],["HÄND Lenker",-1,-1,"-HÄND"]] ReDim $arControls[Ubound($arControls)*2][Ubound($arControls,2)] $iControlCount=Ubound($arControls)/2 for $i=$iControlCount to ubound($arControls)-1 step 1 for $j=0 to ubound($arControls,2)-1 step 1 $arControls[$i][$j]=$arControls[$i-$iControlCount][$j] next next $cGUI = GUICreate("Eintrag erstellen", 400, 300, -1, -1, -1, $WS_EX_TOOLWINDOW, $GUI) $cBtn = GUICtrlCreateButton("Erstellen", 10, 270, 380, 30) GUICtrlSetFont($cBtn, 14, 300, -1, "Dunant Medium") GUICtrlCreateGraphic(200, 0, 1, 230, $SS_SUNKEN) ; Trennlinie ;--------- TAGDIENST ------- $cLable_TD = GUICtrlCreateLabel("Tagdienst ( 7 - 19 Uhr )", 10, 20, 180, 30, $SS_Center) GUICtrlSetFont($cLable_TD, 14, 300, -1, "Dunant Light") for $i=0 to $iControlCount-1 step 1 $arControls[$i][1]=GUICtrlCreateCheckbox($arControls[$i][0], 10, 70+$i*30, 130) GUICtrlSetFont($arControls[$i][1], 12, 300, -1, "Dunant Light") $arControls[$i][2]=GUICtrlCreateCombo("-", 140, 70+$i*30, 50, 30) GUICtrlSetData($arControls[$i][2], "1|2|3|4|5|6|7|8|9|10") GUICtrlSetState($arControls[$i][2], 128) next ;--------- NACHTDIENST ------- $cLable_ND = GUICtrlCreateLabel("Nachtdienst ( 19 - 7 Uhr )", 210, 20, 180, 30, $SS_Center) GUICtrlSetFont($cLable_ND, 14, 300, -1, "Dunant Light") for $i=$iControlCount to $iControlCount*2-1 step 1 $arControls[$i][1]=GUICtrlCreateCheckbox($arControls[$i][0], 210, 70+($i-$iControlCount)*30, 130) GUICtrlSetFont($arControls[$i][1], 12, 300, -1, "Dunant Light") $arControls[$i][2]=GUICtrlCreateCombo("-", 340, 70+($i-$iControlCount)*30, 50, 30) GUICtrlSetData($arControls[$i][2], "1|2|3|4|5|6|7|8|9|10") GUICtrlSetState($arControls[$i][2], 128) next $cLable_Bemerkung = GUICtrlCreateLabel("Bemerkung:", 10, 210, 180, 30, $SS_LEFT) GUICtrlSetFont($cLable_Bemerkung, 14, 300, -1, "Dunant Light") $cInput = GUICtrlCreateInput("", 10, 235, 380, 25) GUICtrlSetFont($cInput, 12, 300, -1, "Dunant Light") GUISetState(@SW_SHOW) #EndRegion ### Setup Child GUI ### While 1 $nMsg = GUIGetMsg() for $i=0 to ubound($arControls)-1 step 1 if $nMsg=$arControls[$i][1] then If _IsChecked($arControls[$i][1]) Then GUICtrlSetState($arControls[$i][2], 64) Else GUICtrlSetState($arControls[$i][2], 128) EndIf endif next Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $GUI) GUIDelete($cGUI) ExitLoop Case $cBtn ; <------ BUTTON ERSTELLEN $LastSelection = _GUICtrlListView_GetSelectionMark($List1) ; Die letzte Auswahl des Listviews wird in eine Variable gespeichert. local $arDienste[8] ;Wenn die Checkbox aktiv ist, wird der Inhalt ausgelesen, sonst nicht. Gibts da keine schönere Variante? ;Doch: Standartmäßig ist das Combo -, also prüfen ob - drinsteht for $i=0 to Ubound($arControls)-1 step 1 if guictrlread($arControls[$i][2])<>"-" then $arDienste[$i]="[" & GUICtrlRead($arControls[$i][2]) &$arControls[$i][3]& "]" endif next $BEM = GUICtrlRead($cInput) _GUICtrlListView_AddSubItem($List1, $LastSelection, $BEM, 5) ;Bemerkung in Listview eintragen. _GUICtrlListView_AddSubItem($List1, $LastSelection, $arDienste[0]&$arDienste[1]&$arDienste[2]&$arDienste[3], 3) ;Tagdienst Output in LV eintragen. _GUICtrlListView_AddSubItem($List1, $LastSelection, $arDienste[4]&$arDienste[5]&$arDienste[6]&$arDienste[7], 4) ;Nachtdienst Output in LV eintragen. GUISetState(@SW_ENABLE, $GUI) ;Enabled Parent-GUI GUIDelete($cGUI) ;Löscht Child-GUI ExitLoop ;Tritt aus dem Loop des Child-GUI's aus um wieder in den Loop des Parent-GUI's zu gelangen. EndSwitch WEnd EndFunc
Falls du daran etwas nicht verstehst, gerne Fragen
MfG Kanashius
-
Sortieren kannst du mit _ArraySort oder du schreibst in das SQL-Statement, wonach sortiert werden soll.
Was die Tabellenüberschrift angeht: Starte einfach einen Index höher. Sonst könnte man nen neues Array anlegen das eins kleiner ist und das mit Werten befüllen. Der Aufwand lohnt aber nicht. -
Naja. Muss er so nicht. Man könnte es an die EXE anhängen, hinter dem QUellcode mit ner Zeichenkette zu filtern, die nicht im Porgramm vorkommt.
Schwierigkeit -> Dein Programm darf nicht laufen, während der kram in die EXE geschrieben wird, da sonst der Zugriff blockiert wird. Also erstmal die Programmdatei kopieren, dann die kopie ausführen mit parametern. In dem Fall soll das Programm dann warten, bis das andere Programm beendet ist und dann die EXE einlesen, alles hinter der Zeichenkette löschen und die neue Datenbank dort anhängen.
Anschließend muss es beendet werden und sich selbst löschen.Die Eigentliche Frage ist: Warum sollte man das wollen? Das ist nicht sehr Performant, die EXE wird irgendwann riesig,...
Da wärs einfacher die Datenbank einfach irgendwo in nem Unterordner abzulegen oder so... -
Ah ja, war noch ein Fehler in der Schleife. Habs oben korrigiert.
Hier auch noch ein Beispiel mit der Listview (erfordert meine ListView UDF (ist im Anhang)):
AutoIt
Alles anzeigen#include <GuiListView.au3> #include "ListViewEditInput.au3" Opt("GuiOnEventMode",1) global $iWidth=800,$iHeight=600 $hGui=GUICreate("ListviewEditExample",$iWidth,$iHeight,-1,-1) $hListView=GUICtrlCreateListView("Person|wichtelt für",5,5,$iWidth-20,$iHeight-45) GUICtrlCreateButton("Zuteilen",$iWidth-100,$iHeight-30,80,25) GUICtrlSetOnEvent(-1,"_calculatePartners") GUICtrlCreateButton("Neue Person",5,$iHeight-30,100,25) GUICtrlSetOnEvent(-1,"_addRow") GUICtrlCreateButton("Lösche ausgewählte Person",110,$iHeight-30,200,25) GUICtrlSetOnEvent(-1,"_delRow") ;Starten des Editierens (Label erstellen und die MessageFunktionen aktivieren ;Startup Editing __ListViewEditInput_StartUp($hGui) ;Listview hinzufügen (Nur Spalte 0 darf bearbeitet werden) (Doppelklick) __ListViewEditInput_AddListview($hGui,$hListView,"0") ;ESC zum abbrechen und ENTER zum abschicken initialisieren __ListViewEditInput_InitializeKeys($hGui) GUISetOnEvent($GUI_EVENT_CLOSE,"_close") GUISetState(@SW_SHOW) while 1 WEnd Func _close() exit EndFunc Func _addRow() GUICtrlCreateListViewItem("",$hListView) GUICtrlSetBkColor(-1,0xDDDDDD) EndFunc Func _delRow() _GUICtrlListView_DeleteItemsSelected($hListView) EndFunc Func _calculatePartners() for $i=0 to _GUICtrlListView_GetItemCount($hListView)-1 step 1 _GUICtrlListView_SetItemText($hListView,$i,"",1) next for $i=0 to _GUICtrlListView_GetItemCount($hListView)-1 step 1 $iNr=Random(0,_GUICtrlListView_GetItemCount($hListView)-1,1) while _GUICtrlListView_GetItemText($hListView,$iNr,1)<>"" $iNr+=1 if $iNr>_GUICtrlListView_GetItemCount($hListView)-1 then $iNr=0 endif WEnd _GUICtrlListView_SetItemText($hListView,$iNr,_GUICtrlListView_GetItemText($hListView,$i,0),1) next for $i=0 to _GUICtrlListView_GetItemCount($hListView)-1 step 1 if _GUICtrlListView_GetItemText($hListView,$i,0)=_GUICtrlListView_GetItemText($hListView,$i,1) then if $i<_GUICtrlListView_GetItemCount($hListView)-1 then local $tmp=_GUICtrlListView_GetItemText($hListView,$i,0) _GUICtrlListView_SetItemText($hListView,$i,_GUICtrlListView_GetItemText($hListView,$i+1,1),1) _GUICtrlListView_SetItemText($hListView,$i+1,$tmp,1) else local $tmp=_GUICtrlListView_GetItemText($hListView,$i,0) _GUICtrlListView_SetItemText($hListView,$i,_GUICtrlListView_GetItemText($hListView,0,1),1) _GUICtrlListView_SetItemText($hListView,0,$tmp,1) endif endif next EndFunc
MfG Kanashius
-
Hab das ganze mal mit nem Script kombiniert, was ich noch hier liegen hatte. Ne Listview mit editierbaren Feldern hätte es vermutlich auch getan
AutoIt
Alles anzeigen#include <array.au3> #include <GuiScrollBars.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GuiComboBoxEx.au3> Global Const $SIF_DISABLENOSCROLL = 0x8 Global $iWidth = 800, $iHeight = 600, $iScrollControlHeight = 25, $iEntryColWidth = 150, $iEntryOperWidth = 40,$iScrollControllHeightSpace=5,$iScrollControllWidthSpace=5 Global $iLastItemWidth,$iLastItemHeigt,$iLastHorizontalScrolled,$iLastVerticalScrolled Global $arCols = [["Name", "col"], ["Name2", "col2"]],$arOper=["+","-","*","/"],$arScrollControls[0],$sNoSelection="- -" $hMainGui = GUICreate("Export", $iWidth, $iHeight,-1,-1,BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU,$WS_MAXIMIZEBOX,$WS_SIZEBOX)) $hAddRow = GUICtrlCreateButton("Add Col", 5, $iHeight - 30, 60, 25) $hReady = GUICtrlCreateButton("Ready", $iWidth-65, $iHeight - 30, 60, 25) $hScrollGui=GUICreate("",$iWidth-15,$iHeight-40,5,5,$WS_CHILD,$WS_EX_CLIENTEDGE,$hMainGui) GUISetState(@SW_SHOW,$hScrollGui) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISetState(@SW_SHOW,$hMainGui) _GUIScrollBars_Init($hScrollGui) _GUIScrollBars_ShowScrollBar($hScrollGui,$SB_BOTH,true) While 1 $msg = GUIGetMsg(1) if $msg[1]=$hMainGui then Switch $msg[0] case -3 exit case $hAddRow _addScrollControl() case $hReady _calculatePartners() _getResult() EndSwitch else for $i=0 to UBound($arScrollControls)-1 step 1 local $tmp=$arScrollControls[$i] for $j=0 to UBound($tmp)-1 step 1 if $msg[0]=$tmp[$j] then if $j=0 then ;exit _removeControl($i) elseif $j=1 then ;top _switchControl($i,$i-1) elseif $j=2 then ;down _switchControl($i,$i+1) endif ExitLoop 2 endif next next endif WEnd Func _calculatePartners() for $i=0 to UBound($arScrollControls)-1 step 1 $iNr=Random(0,UBound($arScrollControls)-1,1) local $arTmp=$arScrollControls[$iNr] while GUICtrlRead($arTmp[4])<>"" $iNr+=1 if $iNr>UBound($arScrollControls)-1 then $iNr=0 endif $arTmp=$arScrollControls[$iNr] WEnd local $arTmp2=$arScrollControls[$i] GUICtrlSetData($arTmp[4],GUICtrlRead($arTmp2[3])) next for $i=0 to UBound($arScrollControls)-1 step 1 local $arTmp=$arScrollControls[$i] if GUICtrlRead($arTmp[3])=GUICtrlRead($arTmp[4]) then if $i<UBound($arScrollControls)-1 then local $tmp=GUICtrlRead($arTmp[4]) local $arTmp2=$arScrollControls[$i+1] GUICtrlSetData($arTmp[4],$arTmp2[4]) GUICtrlSetData($arTmp2[4],$tmp) else local $tmp=GUICtrlRead($arTmp[4]) local $arTmp2=$arScrollControls[0] GUICtrlSetData($arTmp[4],$arTmp2[4]) GUICtrlSetData($arTmp2[4],$tmp) endif $i+=1 if $i>UBound($arScrollControls)-1 then $i=0 endif endif next EndFunc Func _getResult() local $string="" for $i=0 to UBound($arScrollControls)-1 step 1 local $arTmp=$arScrollControls[$i] $string&=GUICtrlRead($arTmp[3])&" wichtelt für "&GUICtrlRead($arTmp[4]) if $i<>UBound($arScrollControls)-1 then $string&=@crlf endif next msgbox(48,"",$string) EndFunc Func _removeAllControlsBehind($index,$j) local $tmp=$arScrollControls[$index] for $i=$j+1 to UBound($tmp)-1 step 1 GUICtrlDelete($tmp[$i]) next ReDim $tmp[$j+1] $arScrollControls[$index]=$tmp EndFunc Func _addScrollControl() GUISwitch($hScrollGui) if UBound($arScrollControls)>0 then local $arControlsLast=$arScrollControls[UBound($arScrollControls)-1] GUICtrlSetState($arControlsLast[2],$GUI_ENABLE) endif ReDim $arScrollControls[UBound($arScrollControls)+1] local $arControls[5],$iActEntry=UBound($arScrollControls)-1,$iTopSpace=5+$iScrollControllHeightSpace+($iActEntry*($iScrollControlHeight+$iScrollControllHeightSpace)) $arControls[0]=GUICtrlCreateButton("X",5+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,20,$iScrollControlHeight) $arControls[1]=GUICtrlCreateButton(ChrW(8679),30+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,20,$iScrollControlHeight) if UBound($arScrollControls)=1 then GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlSetFont(-1,20) $arControls[2]=GUICtrlCreateButton(ChrW(8681),55+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,20,$iScrollControlHeight) GUICtrlSetFont(-1,20) GUICtrlSetState(-1,$GUI_DISABLE) $arControls[3]=GUICtrlCreateInput("",80+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,$iEntryColWidth,$iScrollControlHeight) GUICtrlSendMsg(-1, 0x1501, 0, "Name") GUICtrlSetFont(-1,$iScrollControlHeight-15) $arControls[4]=GUICtrlCreateInput("",80+$iEntryColWidth+$iScrollControllWidthSpace+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,$iEntryColWidth,$iScrollControlHeight) GUICtrlSendMsg(-1, 0x1501, 0, "Nicht zugeordnet") GUICtrlSetFont(-1,$iScrollControlHeight-15) GUICtrlSetState(-1,$GUI_DISABLE) $arScrollControls[$iActEntry]=$arControls _setVertScroll() _setHoriScroll() EndFunc Func _switchControl($i,$j) local $tmpI=$arScrollControls[$i] local $tmpJ=$arScrollControls[$j] $arScrollControls[$i]=$tmpJ $arScrollControls[$j]=$tmpI $iTopSpaceJ=5+$iScrollControllHeightSpace+($i*($iScrollControlHeight+$iScrollControllHeightSpace)) for $k=0 to UBound($tmpJ)-1 step 1 ControlMove($hScrollGui,"",$tmpJ[$k],ControlGetPos($hScrollGui,"",$tmpJ[$k])[0]-7+$iLastHorizontalScrolled,$iTopSpaceJ+$iLastVerticalScrolled) next $iTopSpaceI=5+$iScrollControllHeightSpace+($j*($iScrollControlHeight+$iScrollControllHeightSpace)) for $k=0 to UBound($tmpI)-1 step 1 ControlMove($hScrollGui,"",$tmpI[$k],ControlGetPos($hScrollGui,"",$tmpI[$k])[0]-7+$iLastHorizontalScrolled,$iTopSpaceI+$iLastVerticalScrolled) next if $i=0 then GUICtrlSetState($tmpI[1],$GUI_ENABLE) GUICtrlSetState($tmpJ[1],$GUI_DISABLE) endif if $j=0 then GUICtrlSetState($tmpJ[1],$GUI_ENABLE) GUICtrlSetState($tmpI[1],$GUI_DISABLE) endif if $i=UBound($arScrollControls)-1 then GUICtrlSetState($tmpI[2],$GUI_ENABLE) GUICtrlSetState($tmpJ[2],$GUI_DISABLE) endif if $j=UBound($arScrollControls)-1 then GUICtrlSetState($tmpJ[2],$GUI_ENABLE) GUICtrlSetState($tmpI[2],$GUI_DISABLE) endif _WinAPI_RedrawWindow($hScrollGui) EndFunc Func _removeControl($i) local $tmp=$arScrollControls[$i] for $j=0 to UBound($tmp)-1 step 1 GUICtrlDelete($tmp[$j]) next for $j=$i+1 to UBound($arScrollControls)-1 step 1 $arScrollControls[$j-1]=$arScrollControls[$j] local $tmp=$arScrollControls[$j-1] $iTopSpace=5+$iScrollControllHeightSpace+(($j-1)*($iScrollControlHeight+$iScrollControllHeightSpace)) for $k=0 to UBound($tmp)-1 step 1 ControlMove($hScrollGui,"",$tmp[$k],ControlGetPos($hScrollGui,"",$tmp[$k])[0]-7+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled) next next ReDim $arScrollControls[UBound($arScrollControls)-1] _setVertScroll() _WinAPI_RedrawWindow($hScrollGui) EndFunc Func _setVertScroll() local $elements=UBound($arScrollControls) local $clientHeight=WinGetPos($hScrollGui)[3] local $itemHeight=($iScrollControlHeight+$iScrollControllHeightSpace) $iLastItemHeigt=$itemHeight Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE,$SIF_DISABLENOSCROLL)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $elements) DllStructSetData($tSCROLLINFO, "nPage", int($clientHeight/$itemHeight)) _GUIScrollBars_SetScrollInfo(HWnd($hScrollGui), $SB_VERT, $tSCROLLINFO) EndFunc Func _setHoriScroll() local $elements=0 for $i=0 to UBound($arScrollControls)-1 step 1 if $elements<UBound($arScrollControls[$i]) then $elements=UBound($arScrollControls[$i]) endif next local $clientWidth=WinGetPos($hScrollGui)[2] local $spaces=$iScrollControllWidthSpace*($elements-3) local $combos=$iEntryColWidth*Int(($elements-4)/2+0.5) local $opers=$iEntryOperWidth*(Int(($elements-4)/2)) local $itemWidth=(80+$iEntryColWidth+$spaces+$combos+$opers)/$elements $iLastItemWidth=$itemWidth Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE,$SIF_DISABLENOSCROLL)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $elements) DllStructSetData($tSCROLLINFO, "nPage", int($clientWidth/$itemWidth)) _GUIScrollBars_SetScrollInfo(HWnd($hScrollGui), $SB_HORZ, $tSCROLLINFO) EndFunc Func _getColString() local $string="" for $i=0 to UBound($arCols)-1 step 1 $string&=$arCols[$i][0] if $i<>UBound($arCols)-1 then $string&="|" endif next return $string EndFunc Func _getOperString() local $string="" for $i=0 to UBound($arOper)-1 step 1 $string&=$arOper[$i] if $i<>UBound($arOper)-1 then $string&="|" endif next return $string EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) _setVertScroll() _setHoriScroll() Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) Local $iScrollCode = BitAND($wParam, 0x0000FFFF) local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iLastItemWidth * ($iPosX - $iPos), 0) $iLastHorizontalScrolled+=$iLastItemWidth * ($iPosX - $iPos) endif Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iLastItemHeigt * ($iPosY - $iPos)) $iLastVerticalScrolled+=$iLastItemHeigt * ($iPosY - $iPos) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL
MfG Kanashius
-
Kurz und knapp wäre das eine Lösung:
AutoIt
Alles anzeigen#include <array.au3> ;Array (Liste) mit den Namen anlegen global $arNames=[["Name1",-1],["Name2",-1],["Name3",-1],["Name4",-1]] ;Zahlen von 0 bis zur Anzahl der Namen in der Liste durchgehen (nur noch Anzahl genannt) for $i=0 to UBound($arNames)-1 step 1 ;Zufallszahl zwischen 0 und Anzahl $iNr=Random(0,UBound($arNames)-1,1) ;Solange erhöhen, bis der Eintrag an der Stelle noch nicht zugewiesen wurde, bei überschreiten von Anzahl wieder vorne Anfangen while $arNames[$iNr][1]<>-1 $iNr+=1 if $iNr>UBound($arNames)-1 then $iNr=0 endif WEnd ;Zahl zuweisen $arNames[$iNr][1]=$i next _ArrayDisplay($arNames) ;Alle Zahlen durch die Namen ersetzen for $i=0 to UBound($arNames)-1 step 1 $arNames[$i][1]=$arNames[$arNames[$i][1]][0] next _ArrayDisplay($arNames)
Ich wähle zufällig einen Arrayeintrag aus und Zähle immer weiter, bis der nchste nach dem zufällig ausgewählten frei ist. Ist nicht komplett zufällig, aber fast
Sonst könnte man noch die UDF von Oscar nutzen: Random-Number-GeneratorDu musst somit nurnoch die Namen in die Liste oben eintragen und das Programm läuft durch und gibt dir das Ergebnis
MfG Kanashius
-
Das liegt daran, dass du im Regex (\d+) stehen hast. \d steht für 0-9 und das + sagt 1 oder mehrere. Deshalb werden dort nur Zahlen gefunden.
Du kannst stattdessen (.*?) schreiben. Dann wird alles zwischen den <td> und </td> gefunden. -
Ja, das meinte ich mir Konsolenausgabe. Aber du brauchst für die zukunft nicht alles Posten. Es reicht:
Code"C:\Users\Muecke\Desktop\AutoIt\Script\WEB-Lesen\Web-test_20_10_16.au3" (83) : ==> Subscript used on non-accessible variable.: FileWrite($File, $aDatum & "-" & @hour & ":" & @min & ":" & @sec & ";" & $aHerstellernummer[0] & ";" & $aEAN[0] & ";" & $aLiName[$i] & ";" & $aEK[$i] & ";" & $aURL & @CRLF) FileWrite($File, $aDatum & "-" & @hour & ":" & @min & ":" & @sec & ";" & $aHerstellernummer[0] & ";" & $aEAN^ ERROR
Ja, der Error sagt, dass auf $aEAN nicht mit [] zugegriffen werden kann. Verhindern tut man so etwas normal auf diese Weise:
AutoIt;@error: ; 1: Keine EAN gefunden ; 2: ... Func _func() ;... $aEAN = StringRegExp($sSource, "(?s)<td><strong>EAN</strong></td>\s*<td>(\d+)</td>", 3) if @error then SetError(1,0,-1) ;... EndFunc
Da du das direkt mit hotkey aufrufst kannst du so nicht auf den Fehler reagieren, also am besten in deinem Fall etwa so:
AutoIt
Alles anzeigenFunc hotkeyPressed() _readData() Switch @error case 1 MsgBox(16,"Error","Keine Ean gefunden") case 2 MsgBox(16,"Error","...") EndSwitch EndFunc ;@error: ; 1: Keine EAN gefunden ; 2: ... Func _readData() ;deine alte hotkeypressed methode mit dem SetError kram SetError(1) ;Beispiel Fehlermeldung EndFunc
Wenn du hinter dem Stringregexp dir mal die @error ausgeben lässt siehst du auch, was genau für ein Fehler aufgetreten ist (vermutlich ist @error 1 -> Array is invalid. No matches.)Wenn du nicht immer Messageboxen für ausgaben nehmen möchtest ist ConsoleWrite("Nachricht"&@crlf) nützlich, damit schreibst du einen Text in das Fenster unten in SciTE
Wenn dein Programm fertig ist kannst du es compilieren, dann hast du eine ausführbare datei (exe)
EDIT: Hab grad gesehen, dass du im Fehlerfall weitermachen willst. In dem Fall kannst du einfach das @error statt dem IsArray nehmen.
Du musst nur aufpassen. Zwischen dem Aufruf der Funktion und dem abfragen des @error darf keine andere Funktion aufgerufen werden, da dann der @error überschrieben wird.MfG Kanashius
-
Auf den schnellen Blick seh ich nichts, was das verursachen könnte... Am besten startest du es mal in SciTE mit F5 und guckst mal, ob in der Konsole etwas steht.
Es kann gut sein, dass es abstürzt, wenn etwas beim auslesen der webseite nicht gefunden wird, da du auf Arrayeinträge zugreifst, ohne zu testen, ob sie vorhanden sind...
(Du nutzt stringregexp... in dem fall, dass ein text nicht gefunden wird wird dort kein Array zurückgegeben. Rufst du dann Dim $a...[...] (Zeile 88+) auf stürzt das Programm ab (OnAutoitExit wird ausgeführt).)Was mir aufgefallen ist: Du nutzt Processexists("ieexplorer.exe"). Das ist Fehleranfällig, da es mehrfach vorhanden sein kann,... (Manche Programme nutzen den auch intern uvm.) und manchmal auch mit *32 heißt uvm.
Sicherer wäre folgendes:AutoIt
Alles anzeigen#include <ie.au3> $oIE=_IECreate("www.google.de") $hIE=HWnd($oIE.HWND);Fensterhandle (eindetuige Identifikationsnummer) abfragen msgbox(48,"",$hIE&" "&WinGetTitle($hIE));Nur die Ausgabe, dass es funktioniert hat while WinExists($hIE);Warten, dass das Fenster nicht mehr existiert sleep(10) WEnd msgbox(48,"","Ended") _IEQuit($oIE)
Damit kannst du dir sicher sein, dass du auch das richtige Fenster überwachst
-
Schade
Habs trotzdem mal ohne den "Fehler" oben reingestellt. Vielleicht kanns ja jemand brauchenGut das dus dann selbst gefunden hast
MfG Kanashius
-
Naja, das können aber die meisten user nicht... und willst du denen wirklich die Macht geben
-
Mich hat das interessiert, deshalb hab ich mich mal drangesetzt etwas zu bauen, was du verwenden kannst.
Statt das ganze über String zu machen habe ich mir überlegt, dass man alle Möglichen Spalten in ein Array schreibt (mit Namen, falls er nicht identisch mit dem in der Datenbank sein soll) und dann dort mit Comboboxen die Spalte auswählen kann. Wird nichts ausgewählt bleibt die Spalte leer. Will man Spalten zusammenführen kann man einen Operator anfügen (hab grad +,-,* und /, kannst du aber beliebig selber vergeben) und es erscheint eine neue Combobox, in der man eine Spalte auswählen kann und das "beliebig oft".
Später kannst du dann einfach über das Array laufen und auslesen, was in den Controls steht und das verarbeiten. (Siehe Zeile 85-105)Beim Positionieren der Controls ist noch ein kleiner Fehler und beim Scrollen vertikal muss ich nochmal schauen. Hab grad keine Zeit mehr, mach ich die tage(Glaube das hängt mit der veränderten Fensterposition beim Scrollen zusammen...)
EDIT: Fehler behoben. Das Problem war, dass Controls abhängig vom gescrollten sind, da die aktuelle Sichtfläche zum erstellen/verschieben von Controls genommen wird.Ich hoffe, das ist es was du umsetzen möchtest
Das ausgelesene kann man dann ja recht einfach in eine passende SQLite abfrage umwandelnAutoIt
Alles anzeigen#include <GuiScrollBars.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GuiComboBoxEx.au3> Global Const $SIF_DISABLENOSCROLL = 0x8 Global $iWidth = 800, $iHeight = 600, $iScrollControlHeight = 25, $iEntryColWidth = 150, $iEntryOperWidth = 40,$iScrollControllHeightSpace=5,$iScrollControllWidthSpace=5 Global $iLastItemWidth,$iLastItemHeigt,$iLastHorizontalScrolled,$iLastVerticalScrolled Global $arCols = [["Name", "col"], ["Name2", "col2"]],$arOper=["+","-","*","/"],$arScrollControls[0],$sNoSelection="- -" $hMainGui = GUICreate("Export", $iWidth, $iHeight,-1,-1,BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU,$WS_MAXIMIZEBOX,$WS_SIZEBOX)) $hAddRow = GUICtrlCreateButton("Add Col", 5, $iHeight - 30, 60, 25) $hReady = GUICtrlCreateButton("Ready", $iWidth-65, $iHeight - 30, 60, 25) $hScrollGui=GUICreate("",$iWidth-15,$iHeight-40,5,5,$WS_CHILD,$WS_EX_CLIENTEDGE,$hMainGui) GUISetState(@SW_SHOW,$hScrollGui) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISetState(@SW_SHOW,$hMainGui) _GUIScrollBars_Init($hScrollGui) _GUIScrollBars_ShowScrollBar($hScrollGui,$SB_BOTH,true) While 1 $msg = GUIGetMsg(1) if $msg[1]=$hMainGui then Switch $msg[0] case -3 exit case $hAddRow _addScrollControl() case $hReady _getResult() EndSwitch else for $i=0 to UBound($arScrollControls)-1 step 1 local $tmp=$arScrollControls[$i] for $j=0 to UBound($tmp)-1 step 1 if $msg[0]=$tmp[$j] then if $j=0 then ;exit _removeControl($i) elseif $j=1 then ;top _switchControl($i,$i-1) elseif $j=2 then ;down _switchControl($i,$i+1) ;3 nicht notwendig (spaltenname) elseif $j>3 then if Mod($j,2)=0 then ;combo if GUICtrlRead($tmp[$j])=$sNoSelection then _removeAllControlsBehind($i,$j) else if NOT $j<UBound($tmp) then ;ist letztes Item _addOper($i) endif endif else ;oper if GUICtrlRead($tmp[$j])=$sNoSelection then _removeAllControlsBehind($i,$j) else if NOT $j<UBound($tmp) then ;ist letztes Item _addCombo($i) endif endif endif endif ExitLoop 2 endif next next endif WEnd Func _getResult() local $sResult="" for $i=0 to UBound($arScrollControls)-1 step 1 local $tmp=$arScrollControls[$i] local $string="Spaltenname: "&GUICtrlRead($tmp[3])&" Aufbau: " for $j=4 to UBound($tmp)-1 step 1 if Mod($j,2)=0 then ;combo $index=_GUICtrlComboBoxEx_GetCurSel(GUICtrlGetHandle($tmp[$j])) if $index>0 then $string&=$arCols[$index-1][1]&" " endif else ;operant if GUICtrlRead($tmp[$j])<>$sNoSelection then $string&=GUICtrlRead($tmp[$j])&" " endif endif next $sResult&=$string&@crlf next MsgBox(48,"",$sResult) EndFunc Func _addCombo($index) local $iTopSpace=5+$iScrollControllHeightSpace+($index*($iScrollControlHeight+$iScrollControllHeightSpace)) local $tmp=$arScrollControls[$index] ReDim $tmp[UBound($tmp)+1] local $elements=UBound($tmp)-1 local $spaces=$iScrollControllWidthSpace*($elements-3) local $combos=$iEntryColWidth*Int(($elements-4)/2+0.5) local $opers=$iEntryOperWidth*(Int(($elements-4)/2)) $tmp[UBound($tmp)-1]=GUICtrlCreateCombo($sNoSelection,80+$iEntryColWidth+$spaces+$combos+$opers+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,$iEntryColWidth,$iScrollControlHeight) GUICtrlSetFont(-1,$iScrollControlHeight-15) GUICtrlSetData(-1,_getColString()) $arScrollControls[$index]=$tmp _setHoriScroll() EndFunc Func _addOper($index) local $iTopSpace=5+$iScrollControllHeightSpace+($index*($iScrollControlHeight+$iScrollControllHeightSpace)) local $tmp=$arScrollControls[$index] ReDim $tmp[UBound($tmp)+1] local $elements=UBound($tmp)-1 local $spaces=$iScrollControllWidthSpace*($elements-3) local $combos=$iEntryColWidth*Int(($elements-4)/2+0.5) local $opers=$iEntryOperWidth*(Int(($elements-4)/2)) $tmp[UBound($tmp)-1]=GUICtrlCreateCombo($sNoSelection,80+$iEntryColWidth+$spaces+$combos+$opers+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,$iEntryOperWidth,$iScrollControlHeight) GUICtrlSetFont(-1,$iScrollControlHeight-15) GUICtrlSetData(-1,_getOperString()) $arScrollControls[$index]=$tmp _setHoriScroll() EndFunc Func _removeAllControlsBehind($index,$j) local $tmp=$arScrollControls[$index] for $i=$j+1 to UBound($tmp)-1 step 1 GUICtrlDelete($tmp[$i]) next ReDim $tmp[$j+1] $arScrollControls[$index]=$tmp EndFunc Func _addScrollControl() GUISwitch($hScrollGui) if UBound($arScrollControls)>0 then local $arControlsLast=$arScrollControls[UBound($arScrollControls)-1] GUICtrlSetState($arControlsLast[2],$GUI_ENABLE) endif ReDim $arScrollControls[UBound($arScrollControls)+1] local $arControls[5],$iActEntry=UBound($arScrollControls)-1,$iTopSpace=5+$iScrollControllHeightSpace+($iActEntry*($iScrollControlHeight+$iScrollControllHeightSpace)) $arControls[0]=GUICtrlCreateButton("X",5+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,20,$iScrollControlHeight) $arControls[1]=GUICtrlCreateButton(ChrW(8679),30+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,20,$iScrollControlHeight) if UBound($arScrollControls)=1 then GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlSetFont(-1,20) $arControls[2]=GUICtrlCreateButton(ChrW(8681),55+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,20,$iScrollControlHeight) GUICtrlSetFont(-1,20) GUICtrlSetState(-1,$GUI_DISABLE) $arControls[3]=GUICtrlCreateInput("",80+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,$iEntryColWidth,$iScrollControlHeight) GUICtrlSendMsg(-1, 0x1501, 0, "Spaltenname") GUICtrlSetFont(-1,$iScrollControlHeight-15) $arControls[4]=GUICtrlCreateCombo($sNoSelection,80+$iEntryColWidth+$iScrollControllWidthSpace+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled,$iEntryColWidth,$iScrollControlHeight) GUICtrlSetData(-1,_getColString()) GUICtrlSetFont(-1,$iScrollControlHeight-15) $arScrollControls[$iActEntry]=$arControls _setVertScroll() _setHoriScroll() EndFunc Func _switchControl($i,$j) local $tmpI=$arScrollControls[$i] local $tmpJ=$arScrollControls[$j] $arScrollControls[$i]=$tmpJ $arScrollControls[$j]=$tmpI $iTopSpaceJ=5+$iScrollControllHeightSpace+($i*($iScrollControlHeight+$iScrollControllHeightSpace)) for $k=0 to UBound($tmpJ)-1 step 1 ControlMove($hScrollGui,"",$tmpJ[$k],ControlGetPos($hScrollGui,"",$tmpJ[$k])[0]-7+$iLastHorizontalScrolled,$iTopSpaceJ+$iLastVerticalScrolled) next $iTopSpaceI=5+$iScrollControllHeightSpace+($j*($iScrollControlHeight+$iScrollControllHeightSpace)) for $k=0 to UBound($tmpI)-1 step 1 ControlMove($hScrollGui,"",$tmpI[$k],ControlGetPos($hScrollGui,"",$tmpI[$k])[0]-7+$iLastHorizontalScrolled,$iTopSpaceI+$iLastVerticalScrolled) next if $i=0 then GUICtrlSetState($tmpI[1],$GUI_ENABLE) GUICtrlSetState($tmpJ[1],$GUI_DISABLE) endif if $j=0 then GUICtrlSetState($tmpJ[1],$GUI_ENABLE) GUICtrlSetState($tmpI[1],$GUI_DISABLE) endif if $i=UBound($arScrollControls)-1 then GUICtrlSetState($tmpI[2],$GUI_ENABLE) GUICtrlSetState($tmpJ[2],$GUI_DISABLE) endif if $j=UBound($arScrollControls)-1 then GUICtrlSetState($tmpJ[2],$GUI_ENABLE) GUICtrlSetState($tmpI[2],$GUI_DISABLE) endif _WinAPI_RedrawWindow($hScrollGui) EndFunc Func _removeControl($i) local $tmp=$arScrollControls[$i] for $j=0 to UBound($tmp)-1 step 1 GUICtrlDelete($tmp[$j]) next for $j=$i+1 to UBound($arScrollControls)-1 step 1 $arScrollControls[$j-1]=$arScrollControls[$j] local $tmp=$arScrollControls[$j-1] $iTopSpace=5+$iScrollControllHeightSpace+(($j-1)*($iScrollControlHeight+$iScrollControllHeightSpace)) for $k=0 to UBound($tmp)-1 step 1 ControlMove($hScrollGui,"",$tmp[$k],ControlGetPos($hScrollGui,"",$tmp[$k])[0]-7+$iLastHorizontalScrolled,$iTopSpace+$iLastVerticalScrolled) next next ReDim $arScrollControls[UBound($arScrollControls)-1] _setVertScroll() _WinAPI_RedrawWindow($hScrollGui) EndFunc Func _setVertScroll() local $elements=UBound($arScrollControls) local $clientHeight=WinGetPos($hScrollGui)[3] local $itemHeight=($iScrollControlHeight+$iScrollControllHeightSpace) $iLastItemHeigt=$itemHeight Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE,$SIF_DISABLENOSCROLL)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $elements) DllStructSetData($tSCROLLINFO, "nPage", int($clientHeight/$itemHeight)) _GUIScrollBars_SetScrollInfo(HWnd($hScrollGui), $SB_VERT, $tSCROLLINFO) EndFunc Func _setHoriScroll() local $elements=0 for $i=0 to UBound($arScrollControls)-1 step 1 if $elements<UBound($arScrollControls[$i]) then $elements=UBound($arScrollControls[$i]) endif next local $clientWidth=WinGetPos($hScrollGui)[2] local $spaces=$iScrollControllWidthSpace*($elements-3) local $combos=$iEntryColWidth*Int(($elements-4)/2+0.5) local $opers=$iEntryOperWidth*(Int(($elements-4)/2)) local $itemWidth=(80+$iEntryColWidth+$spaces+$combos+$opers)/$elements $iLastItemWidth=$itemWidth Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE,$SIF_DISABLENOSCROLL)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $elements) DllStructSetData($tSCROLLINFO, "nPage", int($clientWidth/$itemWidth)) _GUIScrollBars_SetScrollInfo(HWnd($hScrollGui), $SB_HORZ, $tSCROLLINFO) EndFunc Func _getColString() local $string="" for $i=0 to UBound($arCols)-1 step 1 $string&=$arCols[$i][0] if $i<>UBound($arCols)-1 then $string&="|" endif next return $string EndFunc Func _getOperString() local $string="" for $i=0 to UBound($arOper)-1 step 1 $string&=$arOper[$i] if $i<>UBound($arOper)-1 then $string&="|" endif next return $string EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) _setVertScroll() _setHoriScroll() Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) Local $iScrollCode = BitAND($wParam, 0x0000FFFF) local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iLastItemWidth * ($iPosX - $iPos), 0) $iLastHorizontalScrolled+=$iLastItemWidth * ($iPosX - $iPos) endif Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iLastItemHeigt * ($iPosY - $iPos)) $iLastVerticalScrolled+=$iLastItemHeigt * ($iPosY - $iPos) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL
MfG Kanashius
-
Du kannst einfach das hier verwenden:
AutoItLocal $sFileData = FileRead("datei.txt") $arResult=StringRegExp($sFileData,'(?s)<Pop(?:.*?)id="'&$MM_LastPopUsed&'"(?:.*?)>(?:.*?)<Hosts(?:.*?)port="(.*?)"(?:.*?)>(?:.*?)<Host(?:.*?)ip="(.*?)"(?:.*?)>',1) _ArrayDisplay($arResult) msgbox(48,"","IP: "&$arResult[1]&" Port: "&$arResult[0]&@crlf)
Wir haben den Text nur in der Variable gespeichert, weil wir die Datei nicht haben/anlegen wollten. Du kannst irgendwas anderes in die Variable schreiben, also auch das ergebnis von FileRead. (Sind beides Strings, also Text)
Danach wende ich ein RegEx an, um die beiden Werte einzulesen. Die stehen dann in einem Array, einer Art Liste, auf die man mit $variable[0],$variable[1],... zugreifen kann. So wie es in der msgbox auch gemacht wird.
Somit kannst du hier einfach $host=$arResult[1] schreiben, und die Ip steht in der Variable. Beim FileRead einfach den Dateinamen eingeben.Was deinen anderen Versuch angeht: Natürlich bekommst du die PID von cmd, schließlich startest du ja auch ein cmd-prozess. (Drück mal F1 nachdem du Run angelickt (Cursor dort positioniert) hast. Dann erscheint die Hilfe zu der Funktion.
Mit StdoutRead kannst du die Ausgaben der Konsole auslesen.MfG Kanashius
-
Ich hab mal ein kleines Script geschrieben. Vielleicht magst du die Idee auch lieber als das mit dem extra Browserfenster.
Ich hab alles Kommentiert.
Die Lösung zu den Zeilenumbrüchen ist in Zeile 36-39. Das Problem ist, dass Linux/Mac als Zeilenumbruch das unsichtbare Zeichen @LF nutzt, Windows aber die beiden Zeichen @CRLF. Deshalb sind die Zeilenumbrüche unter Windows dann nicht sichtbar. Spezielle Programme, wie das von autoiter genannte Notepad++ (sehr zu empfehlen) zeigen auch @LF als Zeilenumbruch an.OnAutoitExitRegister sorgt nur dafür, dass wenn dein Programm beendet wird, vorher noch die genannte Funktion aufgerufen wird.
Wird eigentlich nur genutzt, wenn man noch irgendwas unbedingt machen muss, bevor das Programm beendet. Zum Beispiel Speicherfreigeben, Dateihandle schließen,...
Das FileOpen/FileClose kannst du hier auch weglassen. Das ist eigentlich nur dann wichtig, wenn man die Parameter von Fileopen braucht, oder sehr oft in eine Datei schreibt.
Du hast ja nur einen einzigen Schreibvorgang, deshalb kann es hier weggelassen werden.AutoIt
Alles anzeigen#include <ie.au3> #include <WindowsConstants.au3> Global $iWidth=800,$iHeight=600 ;Fensterhöhe/Breite, damit die Controls bei Änderungen noch passend liegen, hier die Variable ändern Global $startUrl="www.google.de" Global $startMaximized=true Global $file=@DesktopDir & "\test.txt";Die Datei, wo der quelltext gespeichert werden soll GUICreate("",$iWidth,$iHeight,-1,-1,BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU,$WS_MAXIMIZEBOX ));Fenster erstellen (Die Parameter sind nur dafür, dass es maximiert werden kann. Der Rest ist standartmäßig dabei. $oIE=_IECreateEmbedded();Eine Instanz vom IE öffnen, die im eigenen Fenster angezeigt wird (Kein eigener IE-Prozess) $cIE=GUICtrlCreateObj($oIE,5,35,$iWidth-10,$iHeight-45);Den Browser in diesem Control darstellen lassen. (Eigentlich nur zum ändern der Größe wichtig, und zum darstellen lassen^^) GUICtrlSetResizing(-1,BitOR(2,4,32,64));Damit bei einer Größenänderung des Fensters alles passend liegt: 2 steht für Dock-Left->Das Control soll am linken Rand den gleichen Abstand behalten, das selbe für die anderen (siehe Hilfe) $cUrl=GUICtrlCreateInput($startUrl,5,5,$iWidth-60,25);Input, falls eine andere URL aufgerufen werden soll GUICtrlSetResizing(-1,BitOR(2,4,512,32)) $cGO=GUICtrlCreateButton("GO",$iWidth-55,5,50,25);Die im Inputfeldbefindene Url aufrufen GUICtrlSetResizing(-1,BitOR(4,512,32,256)) GUISetState(@SW_SHOW);Fenster anzeigen HotKeySet("^{SPACE}", "saveData");Bei Tastendruck die FUnktion saveData aufrufen if $startMaximized then GUISetState(@SW_MAXIMIZE);Wenns maximiert werden soll, hier maximieren _IENavigate($oIE,$startUrl);Zur Standart URL navigieren while 1 $msg=GUIGetMsg();Abfragen, ob in dem Fenster was passiert ist switch $msg case -3;Wenn schließen geklickt wurde: Programm beenden exit case $cGO;Wenn G= gedrückt wurde: URL aufrufen _IENavigate($oIE,GUICtrlRead($cUrl));guictrlread ließt den Inhalt des Inputfeldes aus EndSwitch WEnd Func saveData() $sSource = _IEDocReadHTML($oIE) ; Aktuellen Quelltext aus dem Internet Explorer Lesen if NOT StringInStr($sSource,@CRLF) then ;Wenn keine Zeilenumbrüche in Windows sichtbar $sSource=StringReplace($sSource,@LF,@CRLF);Ersetze Linux/Mac Zeilenumbrüche durch die von Windows $sSource=StringReplace($sSource,@CR,@CRLF);Keine Ahnung, warum jemand cr nutzen sollte, aber man weiß ja nie^^ endif MsgBox(0, "Quelltext", $sSource) ; Quelltext in Info Box ausgeben ;FileWrite($file, $sSource) ; Quelltext in Datei Exportiren $aTitel = StringRegExp($sSource, "<title>(.+)</title>", 3) ; Titel der Seite auslesen If Not @error And IsArray($aTitel) Then ; Wenn kein Fehler und $aTitel ein Array ist dann mache MsgBox(0, "", "Der Titel der aktuellen Seite ist '" & $aTitel[0] & "'") ; Ausgabe des Array[0] was den Titel enspricht Else ; Wenn Bedingung nicht zutrift dann MsgBox(16, "", "Fehler beim Auslesen!") ; Fehlermeldung ausgeben EndIf EndFunc
Am besten erst einmal ausführen und dann alles durchlesen, dann sind die Kommentare verständlicher schätze ich
Ich hoffe das hilft dir weiterMfG Kanashius
-
Das Problem wirst du aber bei allen Programmiersprachen haben...
Bei manchen ist es schwerer als bei anderen, aber einen ähnlichen Code kann man eigentlich immer disassemblen.
Das Problem entsteht meistens erst, wenn es so viel Code ist, dass man den ohne Kommentare kaum versteht...
Der Computer kann dein compiliertes lesen, also kann man auch *irgendwie* wieder einen ähnlichen Code darausbekommen.
Von Vorteil ist es dabei oft, wenn man weiß, in welcher Sprache das Programm geschrieben ist, da man dann nicht viel Probieren muss, sondern gleich den passenden Disassembler suchen kann.
Vielleicht kennt ja jemand hier eine Programmiersprache für die es (noch) keinen Disassembler gibt :).Wenn wirklich niemand an die Berechnungen kommen darf ist PHP die Lösung, da es auf deinem Server ausgeführt wird und der Benutzer so garnicht an den Code herankommt, bzw. das compilierte. Kostet aber auch für dich mehr.
Die wichtigste Frage, die du dir Stellen musst ist: Wer kommt an das Programm heran -> Wie gut kennen die sich mit Computern aus -> Wie wahrscheinlich ist es, dass sie deine Sicherheitsmechanismen aushebeln können
und vor allem: Wie wichtig könnte es anderen sein, an deinen Code heranzukommen, bzw. wie viel Arbeit/Zeit ist jemand bereit, da hinein zu investieren. -
Vorsicht, @autoiter !
Die Reihenfolge bei XML-Elementen muss nicht immer gleich sein!
Bei den Bespieldaten von Thorkfumble kann zum Beispiel schon ein Problem mit dem Pop und der ID entstehen, da das nicht immer direkt hintereinander steht:
<Pop name="ServerB" id="Id_2" source="User">
<Pop id="Id_1" name="ServerMain" source="User">Local $aPopIDs = _StringBetween($sString, 'Pop id="', '"') würde Id_2 nicht finden...