Jump to content

AndyG

Active Members
  • Posts

    409
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by AndyG

  1. Hi, i have written some OOCalc-Functions two Years ago. An example of the used functions and the collection of these functions is available here: oocalc_4.au3. Feel free to put anything useful into your UDF!
  2. In the German AutoIt-Forum, Jautois has published his Version of Game of Life
  3. with Ward´s FASM-Assembly-UDF it is possible to call AutoIt-functions from Assemblercode. Look at the nice examples. With FASM the forward-jumps are also now possible.
  4. Yes. The "light blue" functions (if you use Scite) with a prefixed underscore are not in "native" code. They are not executable by a standalone AutoIt.exe like the "dark blue" functions. These "light blue" functions are written in AutoIt-code. You can found many of them in the helpfile, after pressing F1 in Scite. If you want to use these functions in one of your scripts, you have to insert ("#include") them into your code. Many functions on a subject are grouped together in a so called UDF (UserDefinedFunction)-file. An UDF is a collection of functions. With one line of code "#include <collection.au3>" you have access to every function in this collection.
  5. Sometimes someone invents the wheel again. Sometimes this can be useful. If someone doesn't want to waste time, he buys a wheel at MSDN. Many intelligent people do so. I think, the dev-team of AutoIt is very intelligent... Click here to buy a wheel! Sourcecode is available at gdi32.dll with any disassembler. For FREE!
  6. ;MouseCoordMode ;Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window: ;0 = relative coords to the active window ;1 = absolute screen coordinates (default) ;2 = relative coords to the client area of the active window $a = Opt("MouseCoordMode") ;save mode $hgui = GUICreate("MouseCoordMode") ;gui $mode0 = GUICtrlCreateLabel("", 10, 10, 300, 30) ;coord-mode 0 $mode1 = GUICtrlCreateLabel("", 10, 50, 300, 30) ;coord-mode 1 $mode2 = GUICtrlCreateLabel("", 10, 100, 300, 30) ;coord-mode 2 GUISetState() ;show gui Do ;loop until exit For $i = 0 To 2 ;all modes Opt("MouseCoordMode", $i) ;set mode GUICtrlSetData(Eval("mode" & $i), "Coordmode " & $i & " x=" & MouseGetPos(0) & " Y=" & MouseGetPos(1)) ;set label with coords depending on mode Next Until GUIGetMsg() = -3 ; exit Opt("MouseCoordMode", $a) ;restore mode
  7. if you load the MS-Word text into Scite and type CTRL*SHIFT+8 and CTRL+SHIFT+9 you will see the spaces and the EOL
  8. make a struct containing a float, copy the bytes from memory into this struct and read it;check something in the memory... $Something_in_Memory_struct=dllstructcreate("byte[20]") ;some bytes in the memory dllstructsetdata($Something_in_Memory_struct,1,"0x4F4D472C207468697320697320706921DB0F4940") ;fill the memory with some data ;it seems to be, that there is a string and a float in the memory....lets have a look! $stringstruct=dllstructcreate("char [16]",dllstructgetptr($Something_in_Memory_struct)) ;prepare to catch the string $string=dllstructgetdata($stringstruct,1) ;got it! $floatstruct=dllstructcreate("float",dllstructgetptr($Something_in_Memory_struct)+16) ;prepare to catch the float $float=dllstructgetdata($floatstruct,1) ;got it! msgbox(0,$String,$float)
  9. stringreplace works well...if you use chr() instead of asc() $string="Test1"&chr(0)&chr(13)&"Test2" ;string with some ascii-codes <32 MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$string' & @lf & @lf & 'Return:' & @lf & $string) ;### Debug MSGBOX $string=stringreplace($string,chr(0),"",0,1) ;remove the nul-byte MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$string' & @lf & @lf & 'Return:' & @lf & $string) ;### Debug MSGBOX $string=stringreplace($string,chr(13),"",0,1) ;remove the CarriageReturn MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$string' & @lf & @lf & 'Return:' & @lf & $string) ;### Debug MSGBOX
  10. i dont know what you want to do, but writing "pixel" into an array to compare 2 Pic´s to get the difference is one of the slowest things ever.... A much faster way to compare two Bitmaps is shown here (Pictures needed are in the first post of the thread) A very fast way to compare is using _WinApi_BitBlt(). The Example shows the result of blitting two pics with the several $iROP-Parameter #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <GDIConstants.au3> ;#include <Misc.au3> _GDIPlus_Startup() ;no manipulating with gdi+ in this script, but it´s easy to load files other than bmp... $picfile1 = "earth1.jpg" ;get them from here http://www.autoitscript.com/forum/index.php?showtopic=106815&view=findpost&p=753759 $picfile2 = "earth2.jpg" $hgui = GUICreate("Example for comparing 2 pic´s with _winapi_bitblt()", 500, 200) ;create a gui $lsource1 = GUICtrlCreateLabel($picfile1, 10, 35, 100, 30) ; some labels and a button... $lsource2 = GUICtrlCreateLabel($picfile2, 150, 35, 100, 30) $lresult = GUICtrlCreateLabel("Result", 350, 35, 200, 30) $lblittingtime = GUICtrlCreateLabel("Blitting", 10, 165, 300, 30) $lmethod = GUICtrlCreateLabel("Combine the two pics with iROP-Method #", 10, 10, 250, 20) $button = GUICtrlCreateButton("Next iROP", 350, 5, 100) ;button to choose the next method to combine 2 pics ;$hGUI1 = GUICreate("DESTINATION", 100, 100, 0, 0) ;we could save the destination into an other window or into a file ;$pic1=GUICtrlCreatePic($picfile1,10,60,200,200) ;we dont need that, we could "blit" the pics into the window.... ;$pic2=GUICtrlCreatePic($picfile2,250,60,200,200) $hdc_gui = _WinAPI_GetDC($hgui) ;device context of the window GUISetState(@SW_SHOW, $hgui) ;get a DeviceContext from the bitmap-file, if alphachannel is not needed, 24Bit saves 25% ram and is faster when searching or manipulating pixels^^ Local $pointer1, $pointer2 ;no need for them in this script, but the variables are used ByRef $hdc_pic1 = _getdcfromfile32($picfile1, $pointer1) ;pointer is the pointer to the bitmapdata, if you want to manipulate pixels $hdc_pic2 = _getdcfromfile32($picfile2, $pointer2) ;pointer is the pointer to the bitmapdata, if you want to manipulate pixels _WinAPI_BitBlt($hdc_gui, 10, 60, 100, 100, $hdc_pic1, 0, 0, $SRCCOPY) ;"copy" the pic into the gui, remember, we don´t need the gui to manipulate the pics _WinAPI_BitBlt($hdc_gui, 150, 60, 100, 100, $hdc_pic2, 0, 0, $SRCCOPY) ;because we don´t want to destroy the pics (overwrite), we "paint" into a Buffer, so we have to create a new bitmap Local $pointer_buffer ;we dont need this variable in this script, pointer to the pixeldata ;this variable is used ByRef Local $hbmp_buffer ;no need to do something with gdi+ , but this variable is used ByRef Local $iwidth_buffer = 100 ;size of the buffer, we need width and height of the pics, but i am lazy... Local $iheight_buffer = 100 ;...could get them with _GDIPlus_ImageGetWidth()....but lazyness^^ $hdc_buffer = _CreateNewBmp32($iwidth_buffer, $iheight_buffer, $pointer_buffer, $hbmp_buffer) ;returns all what you need, a DC, a pointer to the 32Bit-"pixels", and a handle to use with gdi+ Dim $iRop[20] ;see the helpfile for _winapi_bitblt $iRop[0] = $BLACKNESS ;- Füllt das Ziel-Rechteck mit der Farbe, die mit dem Paletten-Index 0 verknüpft ist $iRop[1] = $CAPTUREBLT ;- Inkludiert jegliche Fenster, die das eigene Fenster überlagern in das resultierende Bild $iRop[2] = $DSTINVERT ;- Invertiert die Farben des Ziel-Rechtecks (umkehren) $iRop[3] = $MERGECOPY ;- Mischt die Farben des Quell-Rechtecks mit dem in hDest aktuell gewähltem Füllmuster (Brush), unterVerwendung des AND Operators. $iRop[4] = $MERGEPAINT ;- Mischt die invertierten Farben des Quell-Rechtecks mit den Farben des Ziel-Rechtecks unter Verwendung des OR Operators. $iRop[5] = $NOMIRRORBITMAP ;- Verhindert das spiegeln der Bitmap $iRop[6] = $NOTSRCCOPY ;- Kopiert das invertierte Quell-Rechteck ins Ziel-Rechteck $iRop[7] = $NOTSRCERASE ;- Kombiniert die Farben des Quell- und Ziel-Rechtecks unter Verwendung des OR Operators undinvertiert dann die daraus resultierenden Farben. $iRop[8] = $PATCOPY ;- Kopiert das in hdcDest gewählte Füllmuster in die Ziel-Bitmap $iRop[9] = $PATINVERT ;- Kombiniert die Farben des Quell-Rechtecks mit dem in hDest aktuell gewähltem Füllmuster, mit den Farben desZiel-Rechtecks unter Verwendung des XOR Operators. $iRop[10] = $PATPAINT ;- Kombiniert die Farben des in hDest aktuell gewähltem Füllmusters, mit den Farben desinvertiertem Quell-Rechtecks unter Verwendung des OR Operators. Das Resultat dieser Operation wird wiederum mit den Farbendes Ziel-Rechtecks kombiniert, unter Verwendung des OR Operators. $iRop[11] = $SRCAND ;- Kombiniert die Farben des Quell- und Ziel-Rechtecks unter Verwendung des AND Operators $iRop[12] = $SRCCOPY ;- Kopiert das Quell-Rechteck direkt ins Ziel-Rechteck $iRop[13] = $SRCERASE ;- Kombiniert die invertierten Farben des Ziel-Rechtecks mit den Farben des Quell-Rechtecks unter Verwendung des AND Operators. $iRop[14] = $SRCINVERT ;- Kombiniert die Farben des Quell- und Ziel-Rechtecks unter Verwendung des XOR Operators $iRop[15] = $SRCPAINT ;- Kombiniert die Farben des Quell- und Ziel-Rechtecks unter Verwendung des OR Operators $iRop[16] = $WHITENESS ;- Füllt das Ziel-Rechteck mit der Farbe, die mit dem Index 1 in der PhysikalischenPalette verknüpft ist. While 1 For $i = 0 To 16 ;from the first iROP to the last _WinAPI_BitBlt($hdc_gui, 10, 60, 100, 100, $hdc_pic1, 0, 0, $SRCCOPY) ;"copy" the pic into the gui, _WinAPI_BitBlt($hdc_gui, 150, 60, 100, 100, $hdc_pic2, 0, 0, $SRCCOPY) ;someone could move the window or minimize it GUICtrlSetData($lmethod, "Combine the two pics with iROP-Method #" & $i) ;set label $t = TimerInit() ;save timestamp ;we want to combine the two pics with each of the $iROP-methods _WinAPI_BitBlt($hdc_buffer, 0, 0, 200, 200, $hdc_pic1, 0, 0, $SRCCOPY) ;copy the pic1 into the buffer _WinAPI_BitBlt($hdc_buffer, 0, 0, 200, 200, $hdc_pic2, 0, 0, $iRop[$i]) ;use a method to combine pic1 with pic2 ;at this time, "comparing" is done! Because we have all the data, i.e. pointer to the "pixeldata" we could count different pixels (because they are not black) or something else ;blitting is done awsome fast(depending on CPU and bus), lets see how fast it is.. $m = TimerDiff($t) GUICtrlSetData($lblittingtime, StringFormat("Time to blt the two pics: %.4f milliseconds", $m)) ;set label _WinAPI_BitBlt($hdc_gui, 350, 60, 100, 100, $hdc_buffer, 0, 0, $SRCCOPY) ;copies the buffer into the window to show what we have done Do ;exit or button pressed? $msg = GUIGetMsg() If $msg = -3 Then _Exit() ;end of program Until $msg = $button ;if button pressed, move on... Next WEnd Func _exit() _DeleteBitmap32($hdc_pic1, $pointer1, 0) _DeleteBitmap32($hdc_pic2, $pointer2, 0) _DeleteBitmap32($hdc_buffer, $pointer_buffer, $hbmp_buffer) _GDIPlus_Shutdown() Exit EndFunc ;==>_exit ;~ filedelete("ergebnis.jpg") ;~ $t=timerinit() ;~ Local $hCDC = _WinAPI_CreateCompatibleDC($hpic1dc) ;~ Local $hBMP = _WinAPI_CreateCompatibleBitmap($hpic1dc, 100, 100) ;~ ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hpic1dc = ' & $hpic1dc & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;~ _WinAPI_SelectObject($hCDC, $hBMP) ;~ _WinAPI_BitBlt($hCDC, 0, 0, 100,100, $hpic1dc, 0,0, $SRCCOPY) ;~ _WinAPI_ReleaseDC($hgui1, $hpic1dc) ;~ _WinAPI_DeleteDC($hCDC) ;~ _ScreenCapture_SaveImage("ergebnis.jpg", $hBMP) ;~ $m=timerdiff($t) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $m = ' & $m & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;~ shellexecute("ergebnis.jpg") ;~ _GDIPlus_GraphicsDispose($hGraphic1) ;~ _GDIPlus_GraphicsDispose($hGraphic2) ;~ _GDIPlus_ImageDispose($himg1) ;~ _GDIPlus_ImageDispose($hBild) ;~ _GDIPlus_GraphicsReleaseDC($hGraphic1,$hpic1dc) ;~ _GDIPlus_GraphicsReleaseDC($hGraphic2,$hSrcDC) ;~ _GDIPlus_Shutdown() Func _getDCfromfile32($bmpfile, ByRef $ptr) ;ptr to bitmapdata, it is possible to manipulate one pixel if needed Local $hbitmap = _GDIPlus_BitmapCreateFromFile($bmpfile) Local $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap) Local $iwidth = _GDIPlus_ImageGetWidth($hbitmap) Local $iheight = _GDIPlus_ImageGetHeight($hbitmap) Local $ibitcount = 32 ;if alpha is not needed, 24Bit saves 25% of space Local $tBMI = DllStructCreate($tagBITMAPINFO) DllStructSetData($tBMI, "Size", DllStructGetSize($tBMI) - 4) DllStructSetData($tBMI, "Width", $iwidth) DllStructSetData($tBMI, "Height", -$iheight) DllStructSetData($tBMI, "Planes", 1) DllStructSetData($tBMI, "BitCount", $ibitcount) Local $hdc = _WinAPI_GetDC(0) Local $hcdc = _WinAPI_CreateCompatibleDC($hdc) Local $adib = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'ptr', 0, 'ptr', DllStructGetPtr($tBMI), 'uint', $DIB_RGB_COLORS, 'ptr*', 0, 'ptr', 0, 'uint', 0) ; select object _WinAPI_SelectObject($hcdc, $adib[0]) ; copy the content of the bitmap into the buffer ... _WinAPI_GetDIBits($hdc, $hbmp, 0, $iheight, $adib[4], DllStructGetPtr($tBMI), $DIB_RGB_COLORS) ; create the a dllstruct with the pointer $aDIB[4] Local $stride = 3 * $iwidth + Mod($iwidth, 4) ;number of bytes in one line (filled with some bytes, because it must be a multiple of four!) Local $tBits = DllStructCreate('byte[' & $stride * $iheight & ']', $adib[4]) $ptr = DllStructGetPtr($tBits) _GDIPlus_BitmapDispose($hbitmap) _WinAPI_DeleteObject($adib[0]) Return $hcdc ;MemoryDC of bitmap EndFunc ;==>_getDCfromfile32 Func _CreateNewBmp32($iwidth, $iheight, ByRef $ptr, ByRef $hbmp) ;erstellt leere 32-bit-Bitmap; Rückgabe $HDC und $ptr und handle auf die Bitmapdaten Local $hcdc = _WinAPI_CreateCompatibleDC(0) ;Desktop-Kompatiblen DeviceContext erstellen lassen Local $tBMI = DllStructCreate($tagBITMAPINFO) ;Struktur der Bitmapinfo erstellen und Daten eintragen DllStructSetData($tBMI, "Size", DllStructGetSize($tBMI) - 4);Structgröße abzüglich der Daten für die Palette DllStructSetData($tBMI, "Width", $iwidth) DllStructSetData($tBMI, "Height", -$iheight) ;minus =standard = bottomup DllStructSetData($tBMI, "Planes", 1) DllStructSetData($tBMI, "BitCount", 32) ;32 Bit = 4 Bytes => AABBGGRR Local $adib = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBMI), 'uint', $DIB_RGB_COLORS, 'ptr*', 0, 'ptr', 0, 'uint', 0) $hbmp = $adib[0] ;hbitmap handle auf die Bitmap, auch per GDI+ zu verwenden $ptr = $adib[4] ;pointer auf den Anfang der Bitmapdaten, vom Assembler verwendet ;_arraydisplay($adib) _WinAPI_SelectObject($hcdc, $hbmp) ;objekt hbitmap in DC Return $hcdc ;DC der Bitmap zurückgeben EndFunc ;==>_CreateNewBmp32 Func _DeleteBitmap32($DC, $ptr, $hbmp) _WinAPI_DeleteDC($DC) _WinAPI_DeleteObject($hbmp) $ptr = 0 EndFunc ;==>_DeleteBitmap32if someone wants to know if 2 pics are different, there are 2 ways: - compare each pixel of the two pics, if there is a difference between 2 pixels, pics are not the same. Comparing pixels need some time.....see link above or use something like prospeed.dll - bitblt them with $SRCINVERT-parameter (XOR transferes same pixel to black), copy the result into a string and use the awesome fast AutoIt-stringfunctions . Example:(yes i know that comparing "files" is not very useful, but with only a few changes it´s possible to compare bitmaps from memory, f.e. for motion detection) #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <GDIConstants.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() ;no manipulating with gdi+ in this script, but it´s easy to load files other than bmp... $picfile1 = "earth1.jpg" ;get them from here http://www.autoitscript.com/forum/index.php?showtopic=106815&view=findpost&p=753759 $picfile2 = "earth2.jpg" ;or use your own ;example of very big pictures ;~ _ScreenCapture_Capture("fullscreen1.jpg") ;makes fullscreenshot ;~ $picfile1 = "fullscreen1.jpg" ;~ $picfile2 = "fullscreen1.jpg" ;shows, that the 2 pics are the same $t = TimerInit() ;save timestamp ;get a DeviceContext from the bitmap-file, if alphachannel is not needed, 24Bit saves 25% ram and is faster when searching or manipulating pixels^^ Local $pointer1, $pointer2 ;we don´t need them in this script, the variables are used ByRef Local $struct1, $struct2 ;struct is need to copy Data into string, will be returned ByRef from the following function Local $width1, $height1, $width2, $height2 ;size of the pics, will be returned ByRef from the following function $hdc_pic1 = _getdcfromfile24_struct($picfile1, $pointer1, $struct1, $width1, $height1) ;get DC ,pointer is the pointer to the bitmapdata, if you want to manipulate pixels $hdc_pic2 = _getdcfromfile24_struct($picfile2, $pointer2, $struct2, $width2, $height2) ;get DC ,pointer is the pointer to the bitmapdata, if you want to manipulate pixels _WinAPI_BitBlt($hdc_pic1, 0, 0, $width1, $height2, $hdc_pic2, 0, 0, $SRCINVERT) ;XOR the 2 pics, compare is done, result is in pic1, XOR sets the same pixel to black ;because we have the struct (where are the bitmapdata-"pixels" inside), it is easy to copy the bitmapdata into a string $bmpstring = BinaryToString(DllStructGetData($struct1, 1)) ;makes string of RGB-Bytes StringReplace($bmpstring, Chr(0), "", 0, 1) ;count every black pixel in @extended, yeah, i like stringfunctions :o) $same = @extended ;number of same bytes $m = TimerDiff($t) ;difference between timestamp If $same = StringLen($bmpstring) Then MsgBox(0, "Compared " & StringLen($bmpstring) & " Bytes", "Pics are the same" & @CRLF & StringFormat("%.3f Milliseconds", $m)) Else MsgBox(0, "Compared " & StringLen($bmpstring) & " Bytes", "Pics are different" & @CRLF & StringFormat("%.3f Milliseconds", $m) & @CRLF & StringFormat("%.0f% are different", 100 - ($same * 100 / StringLen($bmpstring)))) EndIf _exit() Func _exit() _DeleteBitmap32($hdc_pic1, $pointer1, 0) _DeleteBitmap32($hdc_pic2, $pointer2, 0) _GDIPlus_Shutdown() Exit EndFunc ;==>_exit Func _getDCfromfile24_struct($bmpfile, ByRef $ptr, ByRef $tbits, ByRef $iwidth, ByRef $iheight) ;ptr to bitmapdata, it is possible to manipulate one pixel if needed, and struct Local $hbitmap = _GDIPlus_BitmapCreateFromFile($bmpfile) Local $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap) $iwidth = _GDIPlus_ImageGetWidth($hbitmap) $iheight = _GDIPlus_ImageGetHeight($hbitmap) Local $ibitcount = 24 ;if alpha is not needed, 24Bit saves 25% of space Local $tBMI = DllStructCreate($tagBITMAPINFO) DllStructSetData($tBMI, "Size", DllStructGetSize($tBMI) - 4) DllStructSetData($tBMI, "Width", $iwidth) DllStructSetData($tBMI, "Height", -$iheight) DllStructSetData($tBMI, "Planes", 1) DllStructSetData($tBMI, "BitCount", $ibitcount) Local $hdc = _WinAPI_GetDC(0) Local $hcdc = _WinAPI_CreateCompatibleDC($hdc) Local $adib = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'ptr', 0, 'ptr', DllStructGetPtr($tBMI), 'uint', $DIB_RGB_COLORS, 'ptr*', 0, 'ptr', 0, 'uint', 0) ; select object _WinAPI_SelectObject($hcdc, $adib[0]) ; copy the content of the bitmap into the buffer ... _WinAPI_GetDIBits($hdc, $hbmp, 0, $iheight, $adib[4], DllStructGetPtr($tBMI), $DIB_RGB_COLORS) ; create the a dllstruct with the pointer $aDIB[4] Local $stride = 3 * $iwidth + Mod($iwidth, 4) ;number of bytes in one line (filled with some bytes, because it must be a multiple of four!) $tbits = DllStructCreate('byte[' & $stride * $iheight & ']', $adib[4]) $ptr = DllStructGetPtr($tbits) _GDIPlus_BitmapDispose($hbitmap) _WinAPI_DeleteObject($adib[0]) Return $hcdc ;MemoryDC of bitmap EndFunc ;==>_getDCfromfile24_struct Func _DeleteBitmap32($DC, $ptr, $hbmp) _WinAPI_DeleteDC($DC) _WinAPI_DeleteObject($hbmp) $ptr = 0 EndFunc ;==>_DeleteBitmap32//EDIT with help of some CPU-Mnemonics, comparing is really fast (tested XP32, Errorhandling is on your own....) _WinAPI_BitBlt($hdc_pic1, 0, 0, $width1, $height2, $hdc_pic2, 0, 0, $SRCINVERT) ;XOR the 2 pics, compare is done, result is in pic1, XOR sets the same pixel to black $tCodeBuffer = DllStructCreate("byte[30]") ;Memory for bytecode DllStructSetData($tCodeBuffer, 1, "0x5589E58B7D088B4D0CB800000000F3AF89C85DC3") ;a little assemblercode which compares a part of the memory with 0 $a = DllCall("user32.dll", "int", "CallWindowProcW", "ptr", DllStructGetPtr($tCodeBuffer),"ptr",dllstructgetptr($struct1),"int",DllStructGetSize($struct1)/4, "int", 0,"int",0);bytecode aufrufen, rückgabe in a[0] if $a[0]=0 then ;pics are the same Else ;pics are different endif
  11. OT, but could be useful.... If you "recompile" a .NET-dll (tool is here) it is possible to use VB.NET and C#-dll´s with AutoIt. .Net-Framework/Visual Studio (Express) is required.
  12. it would be better if you had posted some of the filenames you want to run $format = "2010CO001" For $a = 1 to 273 Step 1 If StringLen ($a) = 1 then $filename = $format + ".000" & $a If StringLen ($a) = 2 then $filename = $format + ".00" & $a If StringLen ($a) = 3 then $filename = $format + ".0" & $a ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $filename = ' & $filename & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console If FileExists(@ScriptDir & "\pic\" & $filename & ".pdf") Then RunWait("pdftk " & @ScriptDir & "\dj\" & $filename & ".pdf " & "stamp " & @ScriptDir & "\pic\" & $filename & ".pdf " & @ScriptDir & "\out\" & $filename & ".pdf") Else FileCopy(@ScriptDir & "\dj\" & $filename & ".pdf",@ScriptDir & "\out\" & $filename & ".pdf") EndIf Nextthe script shows the filenames you create, it seems they are wrong....or are they right?
  13. Hi, not an udf but not far away . I copied your "list" from your posting 0x00000001 (0) - A 0x00000002 (1) - B and so on... into a file named test.txt #include <Array.au3> Dim $array[30][4] ;[0-31] [0=hex 1=number 2=- 3=Letters ] $string = FileRead("test.txt") ;get 0x00000001 (0) - A and all the others.... $lines = StringSplit($string, @CRLF, 3) ;splits file into lines For $i = 0 To UBound($lines) - 1 ;each line $a = StringSplit($lines[$i], " ", 3) ;split into items For $z = 0 To UBound($a) - 1 ;all items $array[$i][$z] = $a[$z] ;all items into array Next Next Dim $examples[3] = [0x181, 0x21008421, 0x40020022] For $i = 0 To UBound($examples) - 1 ;examples $letters = _hextoletters($examples[$i]) MsgBox(0, Hex($examples[$i]), $letters) Next Func _HexToLetters($hex) ;returns the letters Local $letters = "" For $i = 0 To 29 ;all hex´es If BitAND($hex, $array[$i][0]) = $array[$i][0] Then $letters &= $array[$i][3] ;compare hex from array with example, if equal, get letter Next Return $letters EndFunc ;==>_HexToLetters hope this is what you are looking for...
  14. now it is academically....i ran 10000 loops with each solution.... dll-call 250 ms vs string 165 ms both equally fast.... But the bigger the struct, the faster the dll......i would prefer the dll
  15. $nBytes = 1024 $hBuffer = DllStructCreate("ubyte buffer[" & $nBytes & "]") $pBuffer = DllStructGetPtr($hBuffer) $word = BinaryToString("0x55AA") $t = TimerInit() Do ;create string $word &= $word & $word ;grows fast.... Until StringLen($word) >= $nBytes $word = StringLeft($word, $nBytes) ;strip DllStructSetData($hBuffer, 1, $word) $m = TimerDiff($t) ;verify MsgBox(0, "Filled $hbuffer in " & $m & " ms", DllStructGetData($hBuffer, 1))
  16. You may ask this guy to help you with your problem! And I am really sure that he will "enlighten" you....
  17. Hi, i use some functions which (or is it where?) may help you Func _extracturl($sURL) ;ersten teil der url holen, um das icon auf der page zu finden Local $a = StringRegExp($sURL, '^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))', 3) If @error = 0 Then Return $a[0] MsgBox(0, 0, $sURL & " ist keine url") EndFunc ;==>_extracturl Func _isurl($sURL) ;test ob string im url-Format vorliegt, regex hier gefunden: http://geekswithblogs.net/casualjim/archive/2005/12/01/61722.aspx $a = StringRegExp($sURL, "^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?{:content:}quot;, 3) If @error = 0 Then Return 1 ;url ist im korrekten Format If $sURL <> "" Then MsgBox(262144 + 64, "Information", "Ihre angegebene URL: " & @CRLF & $sURL & @CRLF & "entspricht nicht dem URL-Format!" & @CRLF & "Bitte ändern sie die URL!") Return 0 EndFunc ;==>_isurl Func _domain_from_url($url) ;gibt ein www.xxxx.de von http://www.xxxx.de/test/test2 zurück Local $t = StringRegExp(_extracturl($url), "(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))", 3) Return $t[0] EndFunc ;==>_domain_from_url
  18. Hi, an example how to get the return of the call. The * after the ptr is described in the help of dllcall() #include <Array.au3> $dll=dllopen("advapi32.dll") local $ppsidOwner,$ppsidGroup,$ppDacl,$ppSacl, $ppSecurityDescriptor local $ObjectType=1 ;file http://msdn.microsoft.com/en-us/library/aa379593(v=VS.85).aspx local $pObjectName="c:\windows\explorer.exe" local $SecurityInfo=1 ;http://msdn.microsoft.com/en-us/library/cc230369(PROT.10).aspx if fileexists($pObjectName) then $erg=dllcall($dll,"int","GetNamedSecurityInfo","str",$pObjectName,"int",$ObjectType,"dword",$SecurityInfo, _ "ptr*", $ppsidOwner, _ "ptr*", $ppsidGroup, _ "ptr*", $ppDacl, _ "ptr*", $ppSacl, _ "ptr*", $ppSecurityDescriptor) _arraydisplay($erg) endif
  19. $a=123.456789 $b=number(stringtrimleft(string($a),stringinstr(string($a),".",1))) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b = ' & $b & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;failed...^^....sometimes it is overtaken by the reality $a=123.456789 $b=number(stringtrimleft(string($a-int($a)),2)) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b = ' & $b & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
  20. -open file -set filepointer to byte -write byte
  21. Hi, hard stuff is our daily job $dll = DllOpen("sub20.dll") ;dll with globals $result = DllCall($dll, "int:cdecl", "sub_set_debug_level", "int", 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' & $result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console global $global_number=$result[0] ConsoleWrite($global_number&@CRLF) DllClose($dll)returns something without crash, i didn´t found a function that "init" the device and returns a handle to feed the other functions...btw. i don´t know anything about C/C++/C#. So if Richard says "it does not work", then it does not work...
  22. Hi, $dll = DllOpen("GlobalString_GlobalNumber.dll") ;dll with globals $result = DllCall($dll, "int", "GlobalNumber", "int", 0) global $global_number=$result[0] $result = DllCall($dll, "str", "GlobalString", "str", " ") global $global_string=$result[0] DllClose($dll)works fine for me.... Or do you think about a "resource"? Something that you can edit with a resource editor? #386541 could help... /edit/ VB.net example: Dll: Public Class MeineLib Public Shared variablenName As Integer = 655 Program: global_number = MeineLib.variablenNameSry, but I don´t know how to do something like this in AutoIt....
  23. If the developer has given no documentation to his dll's, he will have his reasons ... But if you don´t find some useful information to one of those thousands LAMExxxx.DLL´s, something is going wrong...
  24. Hi, you should try the following step by step: - First step, connection on your local machine: First, compile the example-script of TCPRecv() from the autoit helpfile to SERVER.EXE and run it on your computer. Some firewalls want to block this, allow it or deactivate the firewall. Then load the example-script of TCPSend() from the helpfile and run the script (you could name it CLIENT.au3). If the input from the clientwindow appears in the server window, the first step is done. If not, then you have a problem in your network, fix it! - Second step, connection in the local network. If you have 2 computers in your local network, start the SERVER.EXE at the other computer (remember the firewall...). In the top border of the SERVER-window appears an IP-Address, something like 192.168.105.101. Replace the @IPAddress1 in the line 18 in the CLIENT-script ( Local $szIPADDRESS = @IPAddress1) with the IP from the SERVER-window. Like this: Local $szIPADDRESS = "192.168.105.101"DONT take the 192.168.105.101, take the IP from the SERVER-window.... Then run the client script at your local computer. The data you put into the client-window should be appear in the SERVER-window. Step 2 is done....If not, fix the problem in your network..... - Third step, connection via internet. Run the SERVER.EXE on your local computer. If you have a router, you have to "inform" this router, that a server process (which is expect data) is running at the local machine. Take a look at the router-handbook or ask a friend who knows something about "port forwarding" or "Firewall rules". The router MUST know the IP of the SERVER (shown into the server-window) and the PORT (you find it in the AutoIt-sourcecode of the SERVER-script $nPort=xxxxx) so that the router knows to whom he must pass on the ip-packets where are coming from the internet. Next step, find out your WAN-IP. This is the IP that your router has been assigned by your internet provider. You can receive it from www.whatismyip.com (from your local computer). Then you should give this WAN-IP to your friend, which has the CLIENT-Script at his computer. (There shold be no problems with Step 1 and Step 2 on the computer of your friend!). He could try to ping this (your) WAN-IP. If your router allows pings, he gets an answer. Everything is fine! Your friend needs to to replace the @IPAddress1 in line 18 of the CLIENT-script with "YOUR.WAN.IP" (which you got from www.whatismyip.com). If he runs the CLIENT-sript and the data from his input will arrive at your SERVER, step 3 is is completed successfully! There is no need to make any "port forwarding" at a client computer! If your WAN-IP changes often, its time to get a "personal URL" from a DNS-Service-Provider for free. This URL (something like "randomname.dns-serviceprovider.net") must be registered into your router. Then your friend don't have to ask you every day which WAN-IP actually you have. Replace the "YOUR.WAN.IP" in the CLIENT-script with TCPNameToIP("randomname.dns-serviceprovider.net") and he can connect to you regardless of your current WAN-IP. I hope it is understandable, what I have written here. Happy TCP-ing.... Andy
  25. regardless of the fact that '==' is a string comparison.... 2 cases are possible in if/then: if TRUE then if FALSE then ;or if 0 then ... everything other than 0 is TRUE so you have to distinguish if the expression (($Var = Function(..., ...)) = 0) is true or not ($Var = Function(..., ...)) could be TRUE or FALSE, nothing else! so the expression TRUE=0 has the result FALSE and FALSE=0 has the result TRUE Example: For $var = 1 To 3 For $para = 1 To 2 If ($var = _Function($para)) = 0 Then ;is it true or false? MsgBox(0,"$var="&$var&" $para="&$para&" --> "& (($var = _Function($para)) = 0), "(" & $var & " = _Function(" & $para & ")) is " & ($var = _Function($para)) & @CRLF & "so " & ($var = _Function($para)) & " = 0 is " & (($var = _Function($para)) = 0)) Else MsgBox(0,"$var="&$var&" $para="&$para&" --> "& (($var = _Function($para)) = 0), "(" & $var & " = _Function(" & $para & ")) is " & ($var = _Function($para)) & @CRLF & "so " & ($var = _Function($para)) & " = 0 is " & (($var = _Function($para)) = 0)) EndIf Next Next Func _function($a) Return $a EndFunc ;==>_function
×
×
  • Create New...