Jump to content

JScript

Active Members
  • Posts

    1,213
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by JScript

  1. Solution: IniWrite(@ScriptDir & "\teste.txt", "testando", "teste", "") filemove(@ScriptDir & "\teste.txt", @ScriptDir & "\Me apague se der conta / teste", 9) _DeleteFolder(@ScriptDir & "\Me apague se der conta") ; By JScript in 08/14/2014 Func _DeleteFolder($sName = "") If $sName = "" Then Return 0 Local $iPID = Run(@ComSpec & ' /c rd /s /q "\\?\' & $sName & ' "', "", @SW_HIDE) ProcessWaitClose($iPID, 5) Return $iPID EndFunc So long, JS
  2. That would be a good idea! JS
  3. Thank you for your feedback! Was better than to stay only pointing out where to find a possible solution... JS
  4. @BPCM See a cleanest solution: JS
  5. Hello friend! Which the "OS" that you are testing this code? Which version of your AutoIt? In off: The autoitbrasil is offline for me, see: JS
  6. @Arik See: '?do=embed' frameborder='0' data-embedContent>> JS
  7. @UEZ Well done! Here to 4bits-16 colors: Case 4 Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248] Local $iColor = 12 For $i = 0 To 15 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]*$iColor), $i + 1) Next If you have a better idea... JS
  8. Hello I know the topic has a little more than two years, but some things are valid for long! @UEZ To get the same effect from the palette of 256 colors using AutoIt, I think it's very complicated, at least for me, so thats why i did the code in C++ for this my topic and here is the snippet responsible for obtaining an image in 8bit-256 colors and not only in grayscale mode: if (iColor) { // 256 colors // Windows reserves first color for white, pbmi->bmiColors[0].rgbRed = 255; pbmi->bmiColors[0].rgbGreen = 255; pbmi->bmiColors[0].rgbBlue = 255; // and last color as black! pbmi->bmiColors[255].rgbRed = 0; pbmi->bmiColors[255].rgbGreen = 0; pbmi->bmiColors[255].rgbBlue = 0; i = 20; // first 20 and last 20 are reserved for (red = 0; red <= 255; red+= 51) {// the six values of red for (green = 0; green <= 255; green += 51) { for (blue = 0; blue <= 255; blue+= 51) { pbmi->bmiColors[i].rgbRed = red; pbmi->bmiColors[i].rgbGreen = green; pbmi->bmiColors[i].rgbBlue = blue; pbmi->bmiColors[i].rgbReserved = 0; ++i; } } } Anyone who can translate the snippet above to AutoIt, let us know! Until this not happens, I made a small change to your code for 8-bit with 256 colors, see: ;coded by eukalyptus #include <ScreenCapture.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $filename = @ScriptDir & "Test.png" $bits = 8 ;1, 4, 8 only possible $hHBitmap = _ScreenCapture_Capture("", 0, 0, 300, 300) $hHBitmap2 = _Convert($hHBitmap, $bits) $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap2) _ScreenCapture_SaveImage($filename, $hHBitmap2) _WinAPI_DeleteObject($hHBitmap) _WinAPI_DeleteObject($hHBitmap2) ShellExecute($filename) Exit Func _Convert($hHBitmap, $iBPP) ;function by eukalyptus Local $tBitmap = DllStructCreate("long bmType; long bmWidth; long bmHeight; long bmWidthBytes; ushort bmPlanes; ushort bmBitsPixel; ptr bmBits;") DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hHBitmap, 'int', DllStructGetSize($tBitmap), 'ptr', DllStructGetPtr($tBitmap)) Local $iWidth = DllStructGetData($tBitmap, "bmWidth") Local $iHeight = DllStructGetData($tBitmap, "bmHeight") Switch $iBPP Case 1, 4, 8 Case Else Return SetError(1, 1, False) EndSwitch Local $tBITMAPINFO = DllStructCreate("dword Size; long Width; long Height; word Planes; word BitCount; dword Compression; dword SizeImage; long XPelsPerMeter; long YPelsPerMeter; dword ClrUsed; dword ClrImportant; dword RGBQuad[256];") DllStructSetData($tBITMAPINFO, 'Size', 40) DllStructSetData($tBITMAPINFO, 'Width', $iWidth) DllStructSetData($tBITMAPINFO, 'Height', -$iHeight) DllStructSetData($tBITMAPINFO, 'Planes', 1) DllStructSetData($tBITMAPINFO, 'BitCount', $iBPP) Local $iColorCnt = BitShift(1, -$iBPP) DllStructSetData($tBITMAPINFO, 'ClrUsed', $iColorCnt) DllStructSetData($tBITMAPINFO, 'ClrImportant', $iColorCnt) Switch $iBPP Case 1 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 2) Case 4 Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248] For $i = 0 To 15 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) Next Case 8 ; Windows reserves first color for white, DllStructSetData($tBITMAPINFO, 'RGBQuad', 255, 1) ; and last color as black! DllStructSetData($tBITMAPINFO, 'RGBQuad', 0, 255) Local $iColor = 10 For $i = 20 To $iColorCnt - 22 ;first 20 and last 20 are reserved! DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($i, -16), BitShift($i, -8), $i*$iColor), $i + 1) Next EndSwitch Local $hDCD = _WinAPI_CreateCompatibleDC(0) Local $hDCS = _WinAPI_CreateCompatibleDC($hDCD) Local $aRet = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBITMAPINFO), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0) Local $hHBmp = $aRet[0] Local $hOrigD = _WinAPI_SelectObject($hDCD, $hHBmp) Local $hOrigS = _WinAPI_SelectObject($hDCS, $hHBitmap) _WinAPI_BitBlt($hDCD, 0, 0, $iWidth, $iHeight, $hDCS, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hDCD, $hOrigD) _WinAPI_SelectObject($hDCS, $hOrigS) _WinAPI_DeleteDC($hDCD) _WinAPI_DeleteDC($hDCS) Return $hHBmp EndFunc ;==>_Convert Change the value of $iColor for other shades JS
  9. Thank you friend!Based on the explanations of these two links: http://msdn.microsoft.com/en-us/library/bb250466%28VS.85%29.aspx#safety_topic2 https://www.gidforums.com/t-21296.html I got the final conclusion, see: Capture with 8bits and SetStretchBltMode in COLORONCOLOR: Capture with 8bits and SetStretchBltMode in HALFTONE: JS
  10. Yes is for my remote desktop program! Interesting to know that the bitmap has the same size if it is in grayscale! I use Bitmap cache that minimizes the amount of bitmap data transferred between the client and server. The client creates an compressed, temporary bitmap cache that contains bitmaps that are repeatedly sent from the server to the client. The client uses GDI calls and these cached bitmaps to draw onto the display. The cache resides in RAM and is valid for the session. When the code is complete I'll post for you to see, Edit1: Another variation. Better result? Edit2: See VNC with 256 colors to the left of the picture and my program in the right of the image: JS
  11. Hello, thanks for the reply, but do not actually need to convert, note the code below: $iBitCount = 8 $hSrcDC = _WinAPI_GetDC(_WinAPI_GetDesktopWindow()) $hDestCDC = _WinAPI_CreateCompatibleDC(0) $tBMPINFO = DllStructCreate("dword Size; long Width; long Height; word Planes; word BitCount; dword Compression; dword SizeImage; long XPelsPerMeter; long YPelsPerMeter; dword ClrUsed; dword ClrImportant; dword RGBQuad[256];") DllStructSetData($tBMPINFO, "Size", 40);DllStructGetSize($tBITMAPINFO) - 4); DllStructSetData($tBMPINFO, "Planes", 1) DllStructSetData($tBMPINFO, 'Compression', 0);$BI_RGB) DllStructSetData($tBMPINFO, 'SizeImage', 0) DllStructSetData($tBMPINFO, "Width", $iWidth) DllStructSetData($tBMPINFO, "Height", -($iHeight)); minus =standard = bottomup DllStructSetData($tBMPINFO, "BitCount", $iBitCount) If $iBitCount <= 8 Then $iColorCnt = BitShift(1, -$iBitCount) DllStructSetData($tBMPINFO, 'ClrUsed', $iColorCnt) DllStructSetData($tBMPINFO, 'ClrImportant', $iColorCnt) EndIf Switch $iBitCount Case 8 For $i = 0 To $iColorCnt - 1 DllStructSetData($tBMPINFO, 'RGBQuad', BitOR(BitShift($i, -16), BitShift($i, -8), $i), $i + 1) Next Case 4 Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248] For $i = 0 To 15 DllStructSetData($tBMPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) Next Case 1 DllStructSetData($tBMPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 2) EndSwitch $hHBitmap = _WinAPI_CreateDIBSection($hDestCDC, $tBMPINFO, $DIB_RGB_COLORS, $pBits) _WinAPI_SelectObject($hDC, $hHBitmap) _WinAPI_StretchBlt($hDestCDC, $iWndX, $iWndY, $iWndW, $iWndH, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $SRCCOPY) In this way I can take a screen shot on 8 bits but unfortunately is in shades of gray! How to get a colored with only 256 colors as shown in this link http://en.wikipedia.org/wiki/Color_depth? Edit1: Sample image of 8 bit (256 colors): Edit2: After playing a bit with the "bmiColors" I got this result: But you may notice that the color white is "saturated", as well as the black color is also! Edit3: After some testing, the maximum I got was this result: But I'm not sure that is correct because I'm Colorblind... JS
  12. Hello friends! I already know how to make 8-bit grayscale using _WinAPI_CreateDIBSection() function, but unfortunately I could not understand well and I do not know if it is possible to obtain the results posted on this link: http://en.wikipedia.org/wiki/Color_depth # 8-bit_color I appreciate any help, JS
  13. A simple search for the word Skin already give you the expected results, see: JS
  14. Just now that I saw this topic, I have to analyze all the codes and do some tests ok? What kind of file is this: USB2.apmx86(NOT AU3.).AU3 JS
  15. A good place to have a base is: http://www.iana.org/assignments/port-numbers nice: 0xFACE JS
  16. Very good friend, this shows us how AutoIt is useful in day-to-day! Thanks for sharing, JS
  17. I'm glad you understand, I just want to make clear that, as everyone knows, here is a forum with international reach, not all can write in English and some things that can be understood in a nice way in a particular country, in other countries may be an offense! JS
  18. And why should it be? I'm sorry but I'm not a man to half words and do not even like that kind of thing! Look for some my topic when I was acting in this way, if you find I assure you that I never log on here! JS
  19. Yes, thinking at it this way is even better! Ok, but I think you should it matter. It's just a opnion... Yes, why not? I use your scripts whenever I need, they are all well structured and quite helpful. JS
  20. @guinness Really the way you did with static variable is better, no doubt! Avoids conflicts and variables with huge names just to no have conflict with others. JS
  21. Why you always try to get us to use your scripts in this way?It would be much easier to have the number 4096 out instead to include a file with definitions. The same happens with the ternary, noting that many people still using older versions of AutoIt simply by meeting the needs. But okay, everyone writes the way you want, do not misunderstand me. Would not it be preferable to have all the topics below in only one? Since all appear to be co-related Thanks for the updates, JS
  22. Thank you my friend! JS
  23. I'm looking for alternatives that make the fastest script, so I've been following this topic and adapting to my program everything that is posted here. I saw that the code below is considerably faster: Local $tCharBuff = DllStructCreate("char sData[1]") Local $pCharBuff = DllStructGetPtr($tCharBuff) Local $aRet ; Waits for the response from the remote computer if there is already a bitmap saved in cache... $aRet = DllCall($hWs2_32, "int", "recv", "int", $iConnection, "ptr", $pCharBuff, "int", 1, "int", 0) If $aRet[0] < 1 Then ConsoleWrite("Error!" & @CRLF) Exit EndIf If $tCharBuff.sData = "C" Then ConsoleWrite("Continue..." & @CRLF) EndIf Than this one that uses TCPRecv() function in loop: Local $aRet, $sRecv ; Waits for the response from the remote computer if there is already a bitmap saved in cache... Do $sRecv = TCPRecv($iConnection, 1) If @error > 0 Then ConsoleWrite("Error!" & @CRLF) Exit EndIf Until $sRecv = "C" Or $sRecv = "S" ;C = Continue, S = Skips If $sRecv = "C" Then ConsoleWrite("Continue..." & @CRLF) EndIf A good alternative would be TCPRecv function to accept an external buffer and a pointer, something like: TCPRecv($iConnection, $pBuffer, $iLen) or better: TCPRecv($iConnection, $pBuffer, $iLen, $iBlockMode) JS
  24. @Ward Hello friend! Do I have any chance of having access to the source code of the following items:? Checksum CRC32 ADLER32 Compression LZMA If not possible, no problem! Thank you, JS
  25. There is still a lot computer with Windows XP... JS
×
×
  • Create New...