Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/28/2017 in all areas

  1. jannikrendle, Something to get you started... #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <editconstants.au3> Local $mygui = GUICreate('Test Gui', 300, 70) GUICtrlCreateLabel('Second to Run GUI', 10, 13, 100, 20) Local $mytime = GUICtrlCreateInput('', 110, 10, 20, 20, $ES_NUMBER) Local $start = GUICtrlCreateButton('Start Timer', 190, 10, 100, 20) GUICtrlSetLimit(-1, 2) Local $status = GUICtrlCreateLabel('', 10, 40, 280, 20, BitOR($SS_SUNKEN, $SS_CENTER)) GUICtrlSetColor($status, 0xff0000) GUICtrlSetFont($status, 10, 800) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $gui_event_close Exit Case $mytime ; ; if you want to do something with the input value do it here ; Case $start $timer = TimerInit() chk_time() AdlibRegister('chk_time', 1000) GUICtrlSetState($mytime, $GUI_DISABLE) GUICtrlSetState($start, $GUI_DISABLE) EndSwitch WEnd Func chk_time() Local $diff = Int(TimerDiff($timer)) If $diff > GUICtrlRead($mytime) * 1000 Then Exit MsgBox(0, '$$$$$$$$$$', 'Quitting', 2) GUICtrlSetData($status, 'Quitting in ' & GUICtrlRead($mytime) - Int($diff / 1000) & ' Seconds') EndFunc ;==>chk_time Note - one of many ways to do this...also, this is just an example. How you calc the time will depend on factors you have not given. kylomas
    2 points
  2. If you look to output PDF's from your application (generate reports, graphics, tables etc), this UDF can be very useful. In the zip file are examples, images for testing and the UDF. Enjoy! I have removed some of the previous versions due to the lack of space, but they are still available on request. [uPDATED June 22] v.1.0.1 Added more page formats, two more fonts, example table ... [uPDATED July 30] v1.0.2 Solved issues with Adobe Reader. StuffByDennis added two more functions (Thanks Dennis). [uPDATED August 10] v1.0.3 Rewrote entirely _LoadResImage function - optimize for speed/size of the pdf. Fixed the Example_Image2PDF Thanks to xavierh for finding a missing space in the _LoadFontTT function (even it looks insignificant, that solved an issue with text justification when using Adobe Reader, not Foxit Reader) Total downloads old versions: 2044 + 21 Version 1.0.3: MPDFv103.zip
    1 point
  3. [New Version] - 16 Apr 2022 Added: A new function _GUIExtender_Hidden_Control which allows you to specify which controls should not be automatically reshown when it redraws the GUI. You no longer need to hide/show the control within the script - this function does that as well as telling the UDF whether or not to show it on redraw. New UDF and an additional example in the zip below. Previous changes: Changelog.txt ........................................................................... The GUIExtender UDF allows you to have multiple sections within your GUIs which can be either static or extendable. The extendable sections can be extended and retracted either by UDF created buttons or programmatically by other controls or HotKeys. The controls on the sections are fully functional and there is no overlap problem when retracted (see the details section if you want to know how). The UDF can be used in both MessageLoop and OnEvent modes and with both native and UDF created controls, as well as embedded objects and child GUIs. -------------------------------------------------------------- Note: This is a new recoded and (I hope) simplified version of my earlier UDF of the same name. If you move to this new version there are several script-breaking changes, so please look carefully at the included example scripts to see where things have changed. Here is a quick guide to how the UDF function list has been altered: Old function New function Comment _Init _Init Unchanged _Clear _Clear Unchanged _Section_Start _Section_Create New default parameters for position and size _Section_End Deprecated _Section_Create used to end all section creation _Section_Action _Section_Activate Simple rename _Action _EventMonitor Simple rename _Section_Extend _Section_Action Simple rename, but now uses integer parameter for required state _Section_State _Section_State Unchanged _Restore Deprecated Now automatic _ActionCheck Deprecated Now automatic _HandleCheck Deprecated Now automatic _Obj_Data _Obj_Data Unchanged - _Handle_Data Single call on creation replaces multiple _HandleCheck calls Note: The _EventMonitor function must be added to the idle loop for the automatic actions above to occur -------------------------------------------------------------- Details of how the UDF works for those who are interested: The UDF and plenty of commented examples are in the attached zip: GUIExtender.zip M23
    1 point
  4. water

    PowerPoint UDF

    Version 1.5.0.0

    1,391 downloads

    Extensive library to control and manipulate Microsoft PowerPoint. Threads: Help & Support, Wiki BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    1 point
  5. Melba23

    Infinite Loop in GUI

    jannikrendl, This question gets asked about once a week - have you searched the forum for previous solutions? Or looked at the HotKeySet page in the help file where the example script shows how to do it? M23
    1 point
  6. Try this: ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <GDIPlus.au3> #include <MemoryConstants.au3> #include <Memory.au3> #include <Misc.au3> #include <GUIConstants.au3> #include <StaticConstants.au3> #include <Array.au3> #include <ScreenCapture.au3> #Region ### GUI section ### Global $GUI_MAIN = GUICreate("LCD", 435, 300, 192, 124) Global $Pic1 = GUICtrlCreatePic("", 8, 50, 128, 64, $SS_SUNKEN + $SS_CENTERIMAGE + $SS_BITMAP) Global $SetImg = GUICtrlCreateButton("Set TEXT", 8, 152, 75, 25) Global $ClearScrn = GUICtrlCreateButton("Clear Image", 152, 152, 75, 25) Global $rdStart = GUICtrlCreateButton("Read Image", 152, 50, 75, 25) Global $Msgs = GUICtrlCreateLabel("Messages go here", 8, 30, 200, 20) Global $TxT = GUICtrlCreateInput("Testing TEXT", 8, 120, 128, 20) GUISetState(@SW_SHOW) #EndRegion ### GUI section ### Global $aBitmaps, $Text, $sFontName, $sFileName, $arPixel[0] GUICtrlSetData($Msgs, $sFileName) _GDIPlus_Startup() Global $hBmp_Empty = _GDIPlus_BitmapCreateFromScan0(128, 64) Global $hCtx_Empty = _GDIPlus_ImageGetGraphicsContext($hBmp_Empty) _GDIPlus_GraphicsClear($hCtx_Empty, 0xFFF0F0F0) Global $hHBmp_Empty = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp_Empty) _GDIPlus_GraphicsDispose($hCtx_Empty) _GDIPlus_BitmapDispose($hBmp_Empty) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBmp_Empty) _GDIPlus_ImageDispose($hBmp_Empty) If IsArray($aBitmaps) Then _WinAPI_DeleteObject($aBitmaps[0]) _GDIPlus_ImageDispose($aBitmaps[1]) EndIf _GDIPlus_Shutdown() Exit Case $SetImg $Text = GUICtrlRead($TxT, 0) If IsArray($aBitmaps) Then _WinAPI_DeleteObject($aBitmaps[0]) _GDIPlus_ImageDispose($aBitmaps[1]) EndIf $aBitmaps = Draw_Text($Text) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic1, 0x0172, 0, $aBitmaps[0])) Case $ClearScrn ; do something here to clear the image control _WinAPI_DeleteObject(GUICtrlSendMsg($Pic1, 0x0172, 0, $hHBmp_Empty)) Case $rdStart Get_Pixels() EndSwitch WEnd Func Font_Set() Local $a_vFont = _ChooseFont() $sFontName = $a_vFont[2] ;Local $iFontSize = $a_vFont[3] ;Local $iColorRef = $a_vFont[5] ;Local $iFontWeight = $a_vFont[4] ;Local $bItalic = BitAND($a_vFont[1], 2) ;Local $bUnderline = BitAND($a_vFont[1], 4) ;Local $bStrikethru = BitAND($a_vFont[1], 8) EndFunc ;==>Font_Set Func Image_AR() EndFunc ;==>Image_AR Func Get_Pixels() If IsArray($aBitmaps) Then Return _GDIPlus_ImageSaveToFile($aBitmaps[1], @ScriptDir & "\LCD_Test.png") EndIf Return 0 EndFunc ;==>Get_Pixels Func Draw_Text($sString = "") Local $hGraphic, $hBrush, $hFormat, _ $hFamily, $hFont, $tLayout, _ $aInfo, $hBitmap, $FontSize, _ $iWidth, $iHeight, $fontStyle, _ $hImage $iWidth = 128 $iHeight = 64 $FontSize = 11 $fontStyle = 1 $hImage = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF01INDEXED) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("consolas") $hFont = _GDIPlus_FontCreate($hFamily, $FontSize, $fontStyle) $tLayout = _GDIPlus_RectFCreate($iWidth / 2 / 5, $iHeight / 3, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) Local $aBitmaps[2] = [$hBitmap, $hImage] Return $aBitmaps EndFunc ;==>Draw_Text You thought too complicated.
    1 point
  7. You would need to read the file extension using something like If StringRight($Filepath, 4) = ".jpg" Then do something.. Alternatively you could use GDIPlus functions which supports png format, see post by UEZ
    1 point
  8. @jannikrendl Floops is quite right. Given the Runescape window and your variables of $harvesting, please familiarize yourself with the forum rules before you post again. Hope to see you soon with a legitimate question.
    1 point
  9. The image above is a png file, GuiCtrlCreatePic doesn't support png.
    1 point
  10. What exactly is the purpose of your script? Taken from the forum rules:
    1 point
  11. antonioj84, Simply replace GUICtrlCreateButton with GUICtrlCreateRadio. M23
    1 point
  12. Hi jannikrendl, Try this: Local $Shell = ObjCreate("shell.application") Global $tots $TimeInput = InputBox("AutoTimeCount", "Enter your specified time(minutes): ") $tots = $TimeInput * 60 $tots = $tots * 1000 sleep($tots) Send("{ENTER}") This is to automatically hit enter based on your input desired/specified amount of time. If you wan't to have it in seconds count, change "$tots * 60" to "$tots * 10" and "$tots * 1000" to "$tots * 100". Or if you don't wan't to hit enter automatically try below: Local $Shell = ObjCreate("shell.application") Global $tots $TimeInput = InputBox("AutoTimeCount", "Enter your specified time(minutes): ") $tots = $TimeInput * 60 $tots = $tots * 1000 sleep($tots) ; do something here... Hope I've understand your problem correctly. KS15
    1 point
  13. Here's one way -- #include <IE.au3> Local $oIE = _IE_Example("form") Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm") Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample") Local $oOptions = _IETagNameGetCollection($oSelect, 'option') For $oOption In $oOptions ConsoleWrite("Option: " & $oOption.value & @CRLF) ConsoleWrite("Option: " & $oOption.innertext & @CRLF) Next
    1 point
  14. Wasn't 100% sure what you were after maybe something like this? #include <IE.au3> Local $oIE = _IE_Example("form") Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm") Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample") _IEFormElementOptionSelect($oSelect, "Freepage", 1, "byText") ConsoleWrite("Selected: " & _IEFormElementGetValue($oSelect) & @CRLF) Local $oOptions = _IETagNameGetCollection($oSelect, "Option") For $oOption In $oOptions ConsoleWrite($oOption.InnerText & @CRLF) Next
    1 point
  15. Subz

    Get value from radio button

    Can you replace _CheckPatrol with the following and yes please leave $categ = $chkPatrol Func _CheckPatrol() Local $bChkPatrol = False Select Case GUICtrlRead($radio1) = $GUI_CHECKED If GUICtrlRead($radio1, 1) <> $chkPatrol Then $chkPatrol = $Wise $bChkPatrol = True EndIf Case GUICtrlRead($radio2) = $GUI_CHECKED If GUICtrlRead($radio2, 1) <> $chkPatrol Then $chkPatrol = $Internet $bChkPatrol = True EndIf EndSelect If $bChkPatrol = True Then GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo()) $bChkPatrol = False EndIf
    1 point
  16. I know your question has been solved but here's another one for you. It's a lot more complex and you may not understand it but you may find it useful in the future. (to create hyperlink looking labels) #include <GUIConstants.au3> #include <WinAPIShellEx.au3> Global Const $sStructFormat = "struct;int iCtrlId;char path[256];endstruct" Enum $idProcLabel = 9999 Global $hMain = GUICreate("Example") Global $lblVlc = GUICtrlCreateLabel("VLC", 10, 10, 50, 25) GUICtrlSetFont(-1, 12, 400, "", "Segoe UI") Global $lblIE = GUICtrlCreateLabel("Internet Explorer", 10, 45, 150, 25) GUICtrlSetFont(-1, 12, 400, "", "Segoe UI") Global $lblGoogle = GUICtrlCreateLabel("https://www.google.com", 10, 80, 175, 25) GUICtrlSetFont(-1, 12, 400, 4, "Segoe UI") GUICtrlSetColor(-1, 0x0066CC) Global $hLblVlc = GUICtrlGetHandle($lblVlc) Global $hLblIE = GUICtrlGetHandle($lblIE) Global $hLblGoogle = GUICtrlGetHandle($lblGoogle) Global $hNewWindowProc = DllCallbackRegister("NewWindowProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") Global $pNewWindowProc = DllCallbackGetPtr($hNewWindowProc) ; How the DLLStructGetPtr thing works: ; First call the CreateLabelStruct to create a struct with the ID of the label and the corresponding path to execute ; Then get a pointer to it and use that in the $dwRefData of the NewWindowProc function ; Subclass the VLC label _WinAPI_SetWindowSubclass($hLblVlc, $pNewWindowProc, $idProcLabel, DllStructGetPtr(CreateLabelStruct($lblVlc, "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"))) ; Subclass the IE label _WinAPI_SetWindowSubclass($hLblIE, $pNewWindowProc, $idProcLabel, DllStructGetPtr(CreateLabelStruct($lblIE, @ProgramFilesDir & "\Internet Explorer\iexplore.exe"))) ; Subclass the google label _WinAPI_SetWindowSubclass($hLblGoogle, $pNewWindowProc, $idProcLabel, DllStructGetPtr(CreateLabelStruct($lblGoogle, "https://www.google.com"))) GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE _WinAPI_RemoveWindowSubclass($hLblVlc, $pNewWindowProc, $idProcLabel) _WinAPI_RemoveWindowSubclass($hLblIE, $pNewWindowProc, $idProcLabel) _WinAPI_RemoveWindowSubclass($hLblGoogle, $pNewWindowProc, $idProcLabel) Exit 0 EndSwitch WEnd ; Create and return a struct with the Control ID and the path for this control Func CreateLabelStruct(Const $iCtrlId, Const $sPath) Local $tReturn = DllStructCreate($sStructFormat) DllStructSetData($tReturn, 1, $iCtrlId) DllStructSetData($tReturn, 2, $sPath) Return $tReturn EndFunc ; Window Procedure Func NewWindowProc($hWnd, $iMsg, $wParam, $lParam, $uIdSubclass, $dwRefData) #forceref $hWnd, $iMsg, $wParam, $lParam, $uIdSubclass, $dwRefData Local $tData = DllStructCreate($sStructFormat, $dwRefData) ; If the subclass ID is the label Switch ($uIdSubclass) Case $idProcLabel ; Switch on the window message Switch ($iMsg) ; User left clicked Case $WM_LBUTTONUP ; If the file exists or it's a valid URL If (FileExists(DllStructGetData($tData, 2)) or _WinAPI_UrlIs(DllStructGetData($tData, 2))) Then ShellExecute(DllStructGetData($tData, 2)) ; User right clicked Case $WM_RBUTTONUP ; If the file exists or it's a valid URL If (FileExists(DllStructGetData($tData, 2)) or _WinAPI_UrlIs(DllStructGetData($tData, 2))) Then ClipPut(DllStructGetData($tData, 2)) ; User hovered over the label Case $WM_SETCURSOR ; If the file exists or it's a valid URL If (FileExists(DllStructGetData($tData, 2)) or _WinAPI_UrlIs(DllStructGetData($tData, 2))) Then GUICtrlSetCursor(DllStructGetData($tData, 1), 0) EndSwitch EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>NewWindowProc A lot more complex but essentially I created a struct using the control id and a path for that control (first two used local files, third uses google.com) and then use a pointer to that struct for the subclass. (This is retrieved in the $dwRefData in the NewWindowProc function. I use this to re-create the same struct to get the data for that label, without having to create a case for each label in the NewWindowProc function) A simpler method would be to have a switch based on the $hWnd (This will correspond to the $hLbl* values where I got the GUICtrlGetHandle). But storing everything I need in a struct that will never be used outside of the NewWindowProc function looks cleaner and requires less lines of code!
    1 point
  17. Simple solution is to change Case $StartButton while(1) Agility() WEnd to Case $StartButton Agility()
    1 point
  18. AnonymousX, A better solution is to set the correct style for the MsgBox like this: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) local $but = GUICtrlCreateButton("Hello", 150,150,85,25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox($MB_TOPMOST + $MB_TASKMODAL,"Message","Try hitting the hello button several times,without closing this window. Now close this window and see how script wasn't restricted it just was waiting and storing the instructions") WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit case $but MsgBox(0,"","Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example All is explained in the Modal MsgBox Styles tutorial in the Wiki. M23
    1 point
  19. nlta1992, Something like this perhaps? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Array to hold button ControlIDs Global $aButton[11] $hGUI = GUICreate("Test", 500, 500) ; A double loop to space out the buttons - but you could very easily have a single one instead For $i = 0 To 1 For $j = 1 To 5 $iIndex = ($i * 5) + $j ; Create button using a suitable algorithm to locate it $aButton[$iIndex] = GUICtrlCreateButton("Button " & $iIndex, 10 + (250 * $i), ($j * 50) - 30, 80, 30) Next Next GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case Else ; See if a button was pressed For $i = 1 To 10 If $iMsg = $aButton[$i] Then ; Do what is necessary MsgBox($MB_SYSTEMMODAL, "Pressed", "Button " & $i) ; No point in looking further ExitLoop EndIf Next EndSwitch WEnd M23
    1 point
  20. Simple, Easier to manage & update, Your data will be saved even if your database get corrupted... I have some positive feeling about not blobing... and, using Blobs in web apps is not a good idea, it will be too much for the server, instead use regular linking, TD
    1 point
  21. It was for you. Basically the user should be able to upload a profile image to the server and that stored in the database. What do you suggest? It needs to be linked to the user's account information, which too is stored in the database under the user table, basically it's a one to one ( 1..1 ) relationship.
    1 point
  22. UEZ

    PNG in GUI

    Try this then: ;coded by UEZ 2011 #include <guiconstantsex.au3> #include <gdiplus.au3> #Include <memory.au3> _GDIPlus_Startup() Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 Global $msg Global Const $hBmp = Load_BMP_From_Mem(InetRead("http://www.autoitscript.com/forum/public/style_images/autoit/logo.png"), True) ;to load an image from the net Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) Global Const $iWidth = _GDIPlus_ImageGetWidth($hBitmap) Global Const $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Global Const $hGUI = GUICreate("Display PNG Image in picture control", $iWidth, $iHeight) Global Const $idPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)) GUISetState() While True $msg = GUIGetMsg() Switch $msg Case $idPic MsgBox(0, "Information", "PNG image was clicked") Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndSwitch WEnd ;====================================================================================== ; Function Name: Load_BMP_From_Mem ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap ; ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+ ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created ; ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown() ; ; Requirement(s): GDIPlus.au3, Memory.au3 and _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format), ; Error: 0 ; Error codes: 1: $bImage is not a binary string ; 2: unable to create stream on HGlobal ; 3: unable to create bitmap from stream ; ; Author(s): UEZ ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and ; Yashied for _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Version: v0.97 Build 2012-04-10 Beta ;======================================================================================= Func Load_BMP_From_Mem($bImage, $hHBITMAP = False) If Not IsBinary($bImage) Then Return SetError(1, 0, 0) Local $aResult Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary Local Const $len = BinaryLen($memBitmap) ;get length of image Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002) Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents If @error Then Return SetError(2, 0, 0) Local Const $hStream = $aResult[3] $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface If @error Then Return SetError(3, 0, 0) Local Const $hBitmap = $aResult[2] Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _ "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak $tMem = 0 $tVARIANT = 0 If $hHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>Load_BMP_From_Mem Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0 $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0) If (@error) Or ($Ret[0]) Then Return 0 $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) $pBits = DllStructGetData($tData, 'Scan0') If Not $pBits Then Return 0 $tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword') DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 2, $Ret[2]) DllStructSetData($tBIHDR, 3, $Ret[3]) DllStructSetData($tBIHDR, 4, 1) DllStructSetData($tBIHDR, 5, 32) DllStructSetData($tBIHDR, 6, 0) $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0) If (Not @error) And ($hResult[0]) Then DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0')) $hResult = $hResult[0] Else $hResult = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Return $hResult EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap Br, UEZ
    1 point
  23. Write an e-book entitled "How to make money online using Auto It V3". Then, sell a million copies.
    1 point
  24. I think my sig has a link to a google search engine that searches this site... (it's called "Advanced" Forum Search Engine) Looking for help: (do in order) 1) Think of a way yourself 2) Search the HelpFile 3) Search the forum 4) Ask a question on the forum #)
    1 point
×
×
  • Create New...