Jump to content

AndyG

Active Members
  • Posts

    409
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by AndyG

  1. Hi, why do you use the "casesense=0"-flag? The searching is much faster when casesense=1 #include <array.au3> #include <String.au3> Dim $occur[100][2] $Read = FileRead("SampleDataFile.txt") $Counter = 10000 $Location = 0 ;start searching For $i = 1 To 100 ;10001 to 10100 $hits = -1 Do $hits += 1 ;we found a string $Location = StringInStr($Read, $Counter + $i, 1, 1, $Location + 1) Until $Location = 0 ;no string found $occur[$i - 1][0] = $Counter + $i ;strings $occur[$i - 1][1] = $hits ;number strings found Next _ArrayDisplay($occur, "occurrence/hits")it becomes increasingly harder to beat the regex engine //EDIT Interesting: if i run the following script on my laptop (AMD A6-3400M APU (quadcore)) with clockspeed 700Mhz (the script is not able to pull the processor out of the sleepmode), the speed of the RegEx-part is a little bit faster than the StringInStr()-loop. But if i force the processor to run with fullspeed (2300Mhz), the StringInStr()-loop is twice as fast as the RegEx!? //EDIT2, Depending on other activities (HDD) on my computer, the RegEx is much more sensitive to these activities! Often the RegEx runs twice as long, while the speed of the StringInStr() is every time the same...
  2. ​ ​hmm, and you want to tell us seriously that an old "DOS"-Program needs mouseklicks to install? Really? No shortcuts? Really? No batchfile or installation-routine? Really? And a screenshot of the installation violates trade secrets? Really? I admire all those other users here replying to such a b***sh**! Really!
  3. Hi, can you post a screenshot to explain the whole workflow? What do you mean by "really slow"? After placing the mousecursor into a checkbox and pressing the "c"-key, the script is looking for (and find) the borders and finally "drag&drop" within 200milliseconds...
  4. All is fine.... Today we have 16/32/64/80(FPU)/128 Bit "width" to store a floating point number into the processor registers, In the future there are perhaps 20GBit to store a floating point number, but this does not change the fact that (with your example) only incredible many zeros stand before the last "one" ... You have definetly not limited the displayed number of the decimal digits! If you only want to see 3 decimal digits, use some of the available rounding funtions (Round(), Ceiling(), Floor() ) or (better imho) StringFormat().
  5. Hi, C&P - Failure.... should be $segments[$m] = StringReplace ($segments[$m], @CRLF, " ") $segments[$m] = StringReplace ($segments[$m], @LF, " ") $segments[$m] = StringReplace ($segments[$m], @CR, " ")
  6. Hi, an other one... $split=stringsplit("AVAIL:13:20",":",2) Msgbox(0,0,$split[1]&":"&$split[2])
  7. _GDIPlus_BitmapCreateFromScan0() Pixelformat: $GDIP_PXF01INDEXED = 1 bit per pixel, indexed $GDIP_PXF04INDEXED = 4 bits per pixel, indexed $GDIP_PXF08INDEXED = 8 bits per pixel, indexed $GDIP_PXF16GRAYSCALE = 16 bits per pixel, grayscale $GDIP_PXF16RGB555 = 16 bits per pixel; 5 bits for each RGB component $GDIP_PXF16RGB565 = 16 bits per pixel; 5 bits for red, 6 bits for green and 5 bits blue $GDIP_PXF16ARGB1555 = 16 bits per pixel; 1 bit for alpha and 5 bits for each RGB component $GDIP_PXF24RGB = 24 bits per pixel; 8 bits for each RGB component $GDIP_PXF32RGB = 32 bits per pixel; 8 bits for each RGB component. No alpha component. $GDIP_PXF32ARGB = 32 bits per pixel; 8 bits for each RGB and alpha component $GDIP_PXF32PARGB = 32 bits per pixel; 8 bits for each RGB and alpha component, pre-mulitiplied
  8. Nobody said that! But this is a Forum about programming. For me, the sense of a Forum is to ask a question, show what i have already done and wait for other people´s ideas to evolve my skill. Three FOR/TO loops and a line of IF´s are not a challenge... you asked, you got answers
  9. hehe, easy problems require easy solutions I know the restrictions of these "easy solutions" and you too! (i like your Eigen-udf ) But I am sure, those "bruteforcers" are not able to understand what we are talking about....feed their "algorythm" with some suitable numbers and they will find....nothing!
  10. long time ago i wrote a little script to solve linear equation systems. You can use the GUI to input your variables, or, like in RTFC´s post, an array. #include <GUIConstantsEx.au3> ;linearer gleichungslöser nach Gaußschem Eliminationsverfahren, ;~ #include <array.au3> ;~ $n = 3 ;~ Dim $a[$n][$n] = [[1, 1, 0],[0, 1, 1],[1, 0, 1]] ;matrix ;~ Dim $b[$n] = [100, 200, 240] ;lösungen ;$n = 4 ;Dim $a[$n][$n] = [[1, 3, -2, 1],[-2, 1, -4, -5],[1, -3, 1, 0],[-3, 4, -6, 2]] ;matrix ;Dim $b[$n] = [-7, -6, 6, -21] ;lösungen ;~ $s = _solve_linear_quad($a, $b) ;~ _ArrayDisplay($s) Global $num_unknowns = Number(InputBox("Lösung Lineare Gleichungssysteme", "Anzahl Unbekannte?", 3)) Dim $coeff[$num_unknowns][$num_unknowns] ;matrix Dim $values[$num_unknowns + 1][$num_unknowns + 2] ; Dim $b[$num_unknowns] ;lösungen GUICreate("Enter Equations:", (48 * $num_unknowns) + 121, (26 * $num_unknowns) + 77) For $n = 1 To $num_unknowns For $r = 1 To $num_unknowns $values[$n][$r] = GUICtrlCreateInput("", 48 * $r, 26 * $n, 25, 21) GUICtrlCreateLabel(StringMid("abcdefghijklmnopqrstuvwxyz", $r, 1), (48 * $r) + 26, (26 * $n) + 5, 10, 17) If $r < $num_unknowns Then GUICtrlCreateLabel("+", (48 * $r) + 37, (26 * $n) + 5, 10, 17) Else GUICtrlCreateLabel("=", (48 * $r) + 37, (26 * $n) + 5, 10, 17) EndIf Next $values[$n][$r] = GUICtrlCreateInput("", 48 * $r, 26 * $n, 25, 21) Next $solve_button = GUICtrlCreateButton("Lösen", (48 * $num_unknowns) + 38, (26 * $num_unknowns) + 36, 50, 25) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $solve_button For $n = 0 To $num_unknowns - 1 For $r = 0 To $num_unknowns - 1 $coeff[$n][$r] = Number(GUICtrlRead($values[$n + 1][$r + 1])) Next $b[$n] = Number(GUICtrlRead($values[$n + 1][$num_unknowns + 1])) Next ;~ _arraydisplay($b) ;~ _arraydisplay($coeff) GUISetState(@SW_HIDE) $sols = _solve_linear_quad($coeff, $b) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sols = ' & $sols & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $solutWin = GUICreate("Lösungen:", 280, (21 * UBound($sols)) + 42) For $n = 0 To UBound($sols) - 1 GUICtrlCreateLabel(StringMid("abcdefghijklmnopqrstuvwxyz", $n + 1, 1) & " = " & Round($sols[$n], 3) & " (Max. 3 Nachkommastellen)", 30, 21 * ($n + 1), 200, 20) Next GUISetState(@SW_SHOW, $solutWin) EndSwitch WEnd Func _solve_linear_quad($a, $b) ;matrix,lösung Gaußsches Eliminationsverfahren, löst x gleichungen mit x unbekannten ;by Andy www.autoit.de Local $n, $t Dim $Y[UBound($b)] ;ergebnisse $n = UBound($a) - 1 ;anzahl der zeilen/spalten ;falls erforderlich, zeilen und spalten tauschen If $a[0][0] = 0 Then ;wenn erster koeffizient = 0, dann kann das system nicht starten => spalten tauschen ggf zeilen tauschen For $k = 0 To $n ;jede zeile For $j = 0 To $n ;alle spalten in dieser Zeile testen If $a[$k][$j] <> 0 Then For $m = 0 To $n ;treffer, die erste spalte mit der j. tauschen $t = $a[$m][$j] ;sichern $a[$m][$j] = $a[$m][0] ;mit erster spalte tauschen $a[$m][0] = $t Next For $j = 0 To $n ;zeilen tauschen $t = $a[0][$j] ;sichern $a[0][$j] = $a[$k][$j] ;mit erster spalte tauschen $a[$k][$j] = $t Next $t = $b[0] ;ergebnisse auch tauschen $b[0] = $b[$k] $b[$k] = $t ExitLoop 2 EndIf Next Next EndIf If $a[0][0] = 0 Then Return SetError(1, 0, 1) ;endlich rechnen :) For $I = 0 To $n ;alle zeilen If $a[$I][$I] <> 0 Then ;erstes element auf 1 bringen indem man gesamte zeile durch erstes Element teilt For $k = $I To $n $t = $a[$k][$I] ;erstes element merken If $t <> 0 Then ;nur, wenn das erste element ungleich null ist... For $j = $I To $n $a[$k][$j] /= $t ;alle zeilenmitglieder durch erstes element teilen Next ;b durch i teilen $b[$k] /= $t ;ergebnis natürlich auch EndIf Next ; _ArrayDisplay($a, "oben " & $I) ;zeile i von allen weiteren zeilen subtrahieren, erstes element wird zu 0 For $k = $I + 1 To $n If $a[$k][$I] <> 0 Then ;wenn null, dann überspringen For $j = $I To $n $a[$k][$j] -= $a[$I][$j] ;die i.zeile von der aktuellen zeile subtrahieren Next $b[$k] -= $b[$I] ;ergebnisse natürlich auch EndIf Next ; _ArrayDisplay($a, "unten " & $I) Else ;null in aktueller spalte ;zeilen tauschen ; msgbox(0,$i,"null gefunden") For $k = $I + 1 To $n If $a[$k][$I] <> 0 Then ;zeile tauschen For $j = $I To $n ;zeilen tauschen $t = $a[$I][$j] ;sichern $a[$I][$j] = $a[$k][$j] ;mit erster spalte tauschen $a[$k][$j] = $t Next $t = $b[$I] ;ergebnisse auch tauschen $b[$I] = $b[$k] $b[$k] = $t EndIf ;erstes element auf 1 bringen indem man gesamte zeile durch erstes Element teilt For $k = $I To $n $t = $a[$k][$I] ;erstes element merken If $t <> 0 Then ;nur, wenn das erste element ungleich null ist... For $j = $I To $n $a[$k][$j] /= $t ;alle zeilenmitglieder durch erstes element teilen Next ;b durch i teilen $b[$k] /= $t ;ergebnis natürlich auch EndIf Next ; _ArrayDisplay($a, "oben1 " & $I) ;zeile i von allen weiteren zeilen subtrahieren, erstes element wird zu 0 For $k = $I + 1 To $n If $a[$k][$I] <> 0 Then ;wenn null, dann überspringen For $j = $I To $n $a[$k][$j] -= $a[$I][$j] ;die i.zeile von der aktuellen zeile subtrahieren Next $b[$k] -= $b[$I] ;ergebnisse natürlich auch EndIf Next ;_ArrayDisplay($a, "unten1 " & $I) Next EndIf Next ;alle parameter bestimmen durch rückwärtseinsetzen $Y[$n] = $b[$n] ;letzter ist bereits bekannt For $I = $n - 1 To 0 Step -1 For $j = $n To $I + 1 Step -1 $b[$I] -= $a[$I][$j] * $Y[$j] Next $Y[$I] = $b[$I] Next Return $Y EndFunc ;==>_solve_linear_quad Exit
  11. three equations with three unknown... no need to bruteforce c = (z+y-x)/2 = 340/2 = 170 b = y-c = 200-170 = 30 a = x-b = 100-30 =70 less then one minute...without any computer
  12. Hi, schau mal hier I had this problem too, my solution was to change the codepage first to 1252, then send all text outputs into a file via > (ie. dir c: > dateien.txt and read then the outputs with fileread(). out from the textfile) After that, change the codepage to 850. The problem with this method is, that you can not make use of the Umlauts from Keyboard until the codepage is switched back!
  13. Hi, You could use GDI with Function _GDIPlus_ImageRotateFlip() ;original by UEZ ;o) #include <ScreenCapture.au3> _GDIPlus_Startup() Global Const $iDiv = @DesktopHeight Global Const $hHBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, $iDiv) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) Global Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _WinAPI_DeleteObject($hHBitmap) Global Const $hBitmap_Temp = _GDIPlus_BitmapCreateFromScan0(@DesktopWidth, $iDiv) Global Const $hCtxt_Temp = _GDIPlus_ImageGetGraphicsContext($hBitmap_Temp) Global $iStep = 0 _GDIPlus_GraphicsDrawImageRectRect($hCtxt_Temp, $hBitmap, $iStep, 0, $iDiv, $iDiv, 0, 0, $iDiv, $iDiv) _GDIPlus_ImageRotateFlip($hBitmap_Temp,6) _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBitmap_Temp, 0, 0, $iDiv, $iDiv, $iStep, 0, $iDiv, $iDiv) Global Const $hGUI = GUICreate("Flipped Images", @DesktopWidth, $iDiv) GUISetState() Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, @DesktopWidth, $iDiv) Do Until GUIGetMsg() = -3 _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Temp) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_GraphicsDispose($hCtxt_Temp) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete() Exit
  14. 1417732821397.44 is not 2014/12/05 06:41:0.000 imho 1417732821.39744 is 2014/12/04 22:40:andsomething... read http://fczaja.blogspot.ca/2011/06/convert-excel-date-into-timestamp.html
  15. http://regex101.com After inserting the pattern into the input-field, the explanation shows you instantly, how the RegEx works... Understanding this is an other question
  16. #include <Array.au3> $txt = FileRead("1.csv") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $txt = ' & $txt & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $s = "," ; separator $column = "G" $col = Asc(StringUpper($column)) - 64 ; column to get $pattern = '(?m)^(?:[^' & $s & ']*' & $s & '){' & $col - 1 & '}([^' & $s & ']*)' $res = StringRegExp($txt, $pattern, 3) _ArrayDisplay($res)
  17. Func atan2($y, $x) Return (2 * ATan($y / ($x + Sqrt($x * $x + $y * $y)))) EndFunc ;==>atan2
  18. multiple columns to select what? 1 result....
  19. I would recommend a combobox^^ If $more_then_1_reult then GUICtrlCreateCombo(bla) else code post#1 endif
  20. Hi, a$ = inkey$ REM if i remember correctly from GW-Basic 1983 or 84, returns the pressed key.... I don´t know why this BASIC (hehe, isn´t that funny^^) function to get a keyboard-code is not implemented in AutoIt. "Prohibition on keyloggers" is a weak excuse.
  21. Replacing a char into a string with "nothing" doesn´t work as expected in case of "character position" instead of "substring" $input = "ABCDEFG" $output = StringReplace($input, "D", "X") ;replaces "D" with "X" , works ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $output = ' & $output & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $output = StringReplace($input, 4 , "X") ;replaces "D"(4th char) with "X" , works ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $output = ' & $output & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $output = StringReplace($input, "D", "") ;replaces "D" with "nothing" , works ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $output = ' & $output & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $output = StringReplace($input, 4 , "") ;replaces "D"(4th char) with "nothing" , doesn´t work, why? ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $output = ' & $output & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  22. I disagree, because "better" is the wrong word. Easier to read/debug, yes, easier to translate to other languages, yes, slower in execution / faster in runtime performance, who knows/cares? But "better"? No! naaaah, you are kidding Wash me, but don´t make me wet! Excessive use of ternary results in code like this...it´s like "a bit pregnant", isn´t it? Less is more i think
  23. Hi, Func _DecToBin($d) If $d < 256 Then Return $_aBin256[$d] If $d < 65536 Then Return $_aBin256[BitShift($d,8)] & $_bBin256[BitAND($d, 255)] If $d < 16777216 Then Return $_aBin256[BitShift($d,16)] & $_bBin256[BitAND(BitShift($d,8), 255)] & $_bBin256[BitAND($d, 255)] Return $_aBin256[BitShift($d,24)] & $_bBin256[BitAND(BitShift($d,16), 255)] & $_bBin256[BitAND(BitShift($d,8), 255)] & $_bBin256[BitAND($d, 255)] EndFunc Func _DecToBin($d) Return $d<256?$_aBin256[$d]:$d<65536?$_aBin256[BitShift($d,8)]& _ $_bBin256[BitAND($d,255)]:$d<16777216?$_aBin256[BitShift($d,16) _ ]&$_bBin256[BitAND(BitShift($d,8),255)]&$_bBin256[BitAND($d,255 _ )]:$_aBin256[BitShift($d,24)]&$_bBin256[BitAND(BitShift($d,16), _ 255)]&$_bBin256[BitAND(BitShift($d,8),255)]&$_bBin256[BitAND($d,255)] EndFunc same functionality... Ask yourself, which one is easier to read and debug? Which one NEEDS comments necessarily? For me, there is no question.... Remembers me to the very old discussion about XOR eax,eax vs. MOV eax,0...
  24. Hi, the structure of the Bitmap File Format BMP is very easy. There is a 54 Bytes header which contains the description / properties of the picture, followed by (in your case a color-table) and the raw "Pixel"-Data. Your RAW Data contains SizeWidth + SizeHeight and the indices to the color-table. So if you only need to transform 8-BitPerPixel to SizeX-SizeY-RAW the following Script will do the job... $bmp = FileRead("alt2.bmp") ;load File $width_lowbyte = (StringMid($bmp, 0x13, 1)) ;extract width $width_highbyte = (StringMid($bmp, 0x14, 1)) ;you only need 2 Bytes of 4 for width in your case $height_lowbyte = (StringMid($bmp, 0x17, 1)) ;extract height $height_highbyte = (StringMid($bmp, 0x18, 1)) ;you only need 2 Bytes of 4 for height in your case $width = Asc($width_lowbyte) + 255 * Asc($width_highbyte); $height = Asc($height_lowbyte) + 255 * Asc($height_highbyte) $bmp_size = $width * $height ;math... $data = StringRight($bmp, $bmp_size) ;cut header and colorpalette $data_raw = "" ;data ist Bottom-up, so we have to transform... For $i = $bmp_size - $width + 1 To 1 Step -$width ;...lines from bottom to top $data_raw &= StringMid($data, $i, $width) Next FileDelete("alt2.raw") ;quick and dirty FileWrite("alt2.raw", $width_lowbyte & $width_highbyte & $height_lowbyte & $height_highbyte & $data_raw) ;put width and height and pixel together in a file If you have a valid color-table (palette) in an existing Bitmap-File, all you have to do is to edit the view bytes of width and height into the header and replace the "Pixel" (from the RAW)
  25. while 1 tooltip("0x"&hex(pixelgetcolor(MouseGetPos(0),mousegetpos(1)),6) &" x:"&MouseGetPos(0)&" y:"&mousegetpos(1)) wend These kinds of scripts doesn´t detect the color of pixels into a window which displays Direct3d or OpenGL.
×
×
  • Create New...