Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/12/2018 in all areas

  1. @leomoon Whenever you are dealing with WMI classes, the AutoIt Script-O-Matic tool is invaluable Not only does it give you a nice GUI for browsing through the different classes, it shows you example AutoIt code for interacting with that class:
    2 points
  2. This is what i use #include <Inet.au3> #include <Misc.au3> #include <Timers.au3> #include <WinAPI.au3> #include <Marquee.au3> #include <Constants.au3> #include <WinAPIFiles.au3> #include <FileConstants.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <WinAPIsysinfoConstants.au3> #include <WinAPISys.au3> #include <WinAPIMisc.au3> #include <APISysConstants.au3> $GWArea = GetWorkArea() $hChildWin = GUICreate("window", @DesktopWidth, $GWArea[0] , -1, -1, $WS_POPUP) GUISetState(@SW_SHOW, $hChildWin) Sleep(3000) Exit Func GetWorkArea() Local $tWorkArea = DllStructCreate($tagRECT) _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, $tWorkArea) Local $aReturn = [DllStructGetData($tWorkArea, 'Bottom') - DllStructGetData($tWorkArea, 'Top')] Return $aReturn EndFunc ;==>GetWorkArea Nevermind the includes, it's just a copy paste i do to make sure it doesnt complain.
    2 points
  3. _WinAPI_GetMonitorInfo returns an array, isn't the $array[1] what you're looking for ?
    2 points
  4. careca

    MirrorDir

    Version 1.5.5

    815 downloads

    This is a folder backup tool, after i got tired of using tools made by others, that had either lack of functionality, or were overly complex, i decided to make my own, and this is it. MirrorDir mirrors dirs as the name says, simply select source and destination hit scan, review in the list if that's what you want it to do and press start copy. As this is a mirror sync tool, this means files that exist in destination but dont exist in source are marked for deletion. Other tools have other modes like the incrementing copy which does not delete anything, but i made this for me, only if there is a request i may think about adding features just for fun. Whats more? There's a save/load of profile and the profile is what contains the list of source and destination folders, these are kept in prefs.ini in folder MDir in local appdata. There are context menu's that allow for the removal of items from the profile list, either just for the list (in case you dont want to sync a specific folder, just this time) or delete from the list and the .ini . Best regards.
    1 point
  5. Taskms4

    Launch.IT - App Launcher

    Description: Launch.IT is a simple & moddable/hackable Windows App-Launcher (like MacOS' Spotlight) Features: A lot of customizations (background-pics, colors, position, etc...) can be made via the ".ini" file You can add aliases in the ".ini" file to launch apps/files and browse url/folders Make use of its 5 functionalities: App launcher (and files/url/path browser), Windows search (find results from your files and folder), Windows Run, DOS commands execution (command prompt), and Google Search It has some embeeded commands like '::help' to display Launch.IT help window Use hotkeys like {Shift}+{Esc} to switch between minimized and default/maximized GUI or {Esc} to exit program. Screenshots: Download: Launch.IT.zip Launch.IT in brief: Originally, the aim of this tool was to implement an alternative to Apple's Spotlight (provided along with MacOS) in my Professional Win7 PC for more convenience (and by laziness XD). Now, I'm using this tool (which I have completely customized to add further functionalities like Calculator, Remote-Desktop, SSH, etc...) every day at work on a Win10 PC. And believe it or not, this makes me saving an incredible amount of time. Like me, do not hesitate to rework the code to add functionalities and modify Launch.IT behaviour. I hope you'll like it
    1 point
  6. I want to help you but i don't even understand what you expect to happen. Anyway, check these changes ;============================================================================= #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon= #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=By: #AutoIt3Wrapper_Res_Description= #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Icon_Add= #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;============================================================================= #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiSlider.au3> ;============================================================================= Opt("TrayAutoPause", 1) Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled Global $Paused = 1, $Form1, $aButtonStartStop, $hSlider, $hSlider_Handle, $hLabel, $iLastSlider, $aReadSlider, $hWin, $hWndTT ;============================================================================= $Form1 = GUICreate("Form1", 259, 118) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize") GUISetOnEvent($GUI_EVENT_RESTORE, "Restore") $aButtonStartStop = GUICtrlCreateButton("Start", 16, 80, 75, 25) GUICtrlSetOnEvent($aButtonStartStop, '_pause') $hSlider = GUICtrlCreateSlider(8, 24, 238, 37, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 20000, 1) GUICtrlSetData(-1, 5) $hSlider_Handle = GUICtrlGetHandle(-1) $hLabel = GUICtrlCreateLabel("", 117, 64, 34, 20) GUISetState(@SW_SHOW) $hWndTT = _GUICtrlSlider_GetToolTips($hSlider) _GUICtrlSlider_SetToolTips($hSlider, $hWndTT) $iLastSlider = 0 GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider") ;============================================================================= While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aReadSlider = GUICtrlRead($hSlider) If ProcessExists('notepad.exe') Then ConsoleWrite('Notepad is running! - ' & @MSEC & @CRLF) If $Paused = 0 Then If WinWait("[CLASS:Notepad]", "", 2) Then $hWin = WinGetHandle("[CLASS:Notepad]") WinActivate($hWin) ControlClick($hWin, "", "Edit1") Send("asdf") EndIf EndIf Else ConsoleWrite('Notepad is NOT running! - ' & @MSEC & @CRLF) ;ExitLoop EndIf Sleep(100) WEnd ;============================================================================= Func _pause() If $Paused = 1 Then $Paused = 0 GUICtrlSetData($aButtonStartStop, 'Pause') Else $Paused = 1 GUICtrlSetData($aButtonStartStop, 'Continue') EndIf EndFunc ;==>_pause ;============================================================================= Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam If $lParam = $hSlider_Handle Then GUICtrlSetData($hLabel, GUICtrlRead($hSlider)) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_H_Slider ;============================================================================= #Region ;Window ;============================================================================= Func Minimize() WinSetState('', '', @SW_MINIMIZE) EndFunc ;==>Minimize ;============================================================================= Func Restore() WinSetState('', '', @SW_RESTORE) EndFunc ;==>Restore ;============================================================================= Func Quit() Exit EndFunc ;==>Quit ;============================================================================= #EndRegion ;Window ;=============================================================================
    1 point
  7. looks like what Dannyfirex posted was really close to what I had. I looked at the WinAPIProc.au3 and APIProcConstants.au3 and it's off by just a little. it looks like using these 3 items will do the same as what I was using. Global Const $ES_CONTINUOUS = 0x80000000 Global Const $ES_DISPLAY_REQUIRED = 0x00000002 Global Const $ES_SYSTEM_REQUIRED = 0x00000001 So do a BitOR on these 3 and it will be the 0x80000003 #include <WinAPIProc.au3> _WinAPI_SetThreadExecutionState(BitOR($ES_CONTINUOUS, $ES_DISPLAY_REQUIRED, $ES_SYSTEM_REQUIRED)) I'll just keep using my direct DLL calls though since I know what they are.
    1 point
  8. Yeah it is usualy the correct way to do things here And if you encounter an issue or dont understand somthing come back here post code then we try to help Btw you probably have already this question answered 150 000 time But np. Cya
    1 point
  9. You're using _WinHttpSimpleSendRequest, which is for HTTP. You'll need to switch to _WinHttpSimpleSendSSLRequest or examine the following simplified example that works -- #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, "https://api.genderize.io") Local $sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", "?name=peter") ConsoleWrite( StringLeft($sReturned, 1100) & "...") ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
    1 point
  10. Ok watch this: WinGetState ;This one is optional for you and this script ControlClick ; Not optional AdlibRegister ; Optional but best for you Sleep ; Optional
    1 point
  11. It has been a while since I was into this subject. I think that you are correct. I temporarily abandoned this project because of that, and because my code or the UDFs were causing a failure elsewhere in my script: something that worked until I got into changing properties. It seemed that memory was being overwritten. My script is several thousand lines, and I did not find a way of reproducing the problem in a short script. All I can say is that something is wrong somewhere. I was new to structs at the time, so spent a lot of time trying to discover whether I was misusing them.
    1 point
  12. Well since you just want a controlclick it will be easy for you. You need to do that after a keystroke or after a delay ? Give me the logic you want and i ll give you all needed command so you will have to read without search
    1 point
  13. Ok please read this : and come back to me in this thread : you got the solution and some explanation at the bottom of the thread
    1 point
  14. No need to remove it, simply use your own thread from this point forward...
    1 point
  15. Hey, Thanks for the feedback, it's a feature I wanted to add to but honestly I did not had the time to do it (yet?).. EDIT: For the example you provided, your alternative is to use the command ::c ipconfig all , for other cases you will probably need to modify the source code (at least for the moment)
    1 point
  16. @leomoon An example of how to use WMI Object in AutoIt could be found here
    1 point
  17. @Fractured as a rule we do not deleted threads. We have all had that experience where we post a question and then 2 minutes later figure it out ourselves. If you post a detailed explanation of what you did to resolve the issue, it may help someone down the road looking at the same problem.
    1 point
  18. Currently AutoIt has: _WinAPI_GetWorkArea() But .... @mikell I was working a little with your example, as following: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Monitor_GetWorkArea ; Description ...: ; Syntax ........: _Monitor_GetWorkArea() ; Parameters ....: $iDPI - [optional] an integer value. Default is -1. ; Return values .: Array ; Author ........: mikell ; Modified ......: mLipok ; Remarks .......: HowTO: WinMove($hGui, "", $aWorkAera[0], $aWorkAera[1], $aWorkAera[4], $aWorkAera[5]) ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/165766-gui-position-minus-taskbar-height/#entry1210698 ; Link ..........: https://docs.microsoft.com/pl-pl/windows/desktop/api/winuser/nf-winuser-systemparametersinfofordpi ; Link ..........: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa ; Example .......: No ; =============================================================================================================================== Func _Monitor_GetWorkArea($iDPI = -1) Local $tStartRect = DllStructCreate("int[4]") Local $pStartRect = DllStructGetPtr($tStartRect) If $iDPI = -1 Then DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_Monitor_GetWorkArea, "int", 0, "ptr", $pStartRect, "int", 0) Else DllCall("user32.dll", "int", "SystemParametersInfoForDpi", "int", $SPI_Monitor_GetWorkArea, "int", 0, "ptr", $pStartRect, "int", 0, "int", $iDPI) EndIf Local $aArea[6] $aArea[0] = DllStructGetData($tStartRect, 1, 1) $aArea[1] = DllStructGetData($tStartRect, 1, 2) $aArea[2] = DllStructGetData($tStartRect, 1, 3) $aArea[3] = DllStructGetData($tStartRect, 1, 4) $aArea[4] = $aArea[2] - $aArea[0] $aArea[5] = $aArea[3] - $aArea[1] Return $aArea EndFunc ;==>_Monitor_GetWorkArea I just add support for DPI but not tested yet, and reading here: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa I was wondering how to combine GetMonitorInfo with GetWorkArea ? I'm trying to combine it all together with: Do you have idea how to combine GetMonitorInfo with GetWorkArea ?
    1 point
  19. Welcome to the forum! As a note to both new and current members and as mentioned above, please read the FAQs on the AutoIt Wiki before posting. This will save you time, as the answers to many common questions are out there. Most importantly for new forum members, please see the section on Why isn't my thread getting any replies? Forum members are here, volunteering their time to help you with your questions, and we will always do our best to assist. Below are just a few of the items we need from you in order to provide the best help, please see the FAQ section for more: First, foremost and always, know and follow the forum rules: Every member of this forum is expected to know and adhere to the forum rules. The rules are based on common sense and should not be daunting for anyone to follow. Doing so will ensure you receive assistance and will prevent any necessary sanctions by the Moderation team. We would much rather help you with your scripts than have to attend to the unpleasant business of suspending or banning accounts. Add a meaningful title to your thread: "HELP!!" tells no one anything, and will often delay your receiving assistance. Include a detailed description of what you are trying to do, what you have tried on your own, and what problem/error you are experiencing: "Doesn't work" or "AutoIt's broke" doesn't cut it. Forum members are also here to help you write and improve your own scripts; this is not a forum where you put in an order and someone writes the code for you. Always Post Code: Even if the code is not doing what you want it to, posting the code you are working from rather than asking forum members to guess is always going to result in more rapid assistance. If you cannot post the code for business reasons, create a script that reproduces the issue you are seeing.
    1 point
  20. More details are needed for us to help. Please show the relevant information from the Scite console window. Also, it would likely be beneficial if you posted a reproducer script that we can actually run to observe the issue.
    1 point
  21. It is what I've tried. _WD_Option('Port', $sPort) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"' & ' --port=' & $sPort & ' adb-port=' & $sPort) The Chromedriver start well (see picture) But I received an error on createsession
    1 point
  22. @SecreTel Don't have any experience with TS, but depending on the webdriver involved, you should be able to start a unique instance for each user where each instance uses a different port number. What have you tried? Post your code and describe any issues you encounter.
    1 point
  23. Running Webriver UDF on Terminal Server Do you have any suggestion, because it is not possible to use the same port for all user, or maybe startup in service mode ? Someone has an experience with that ? Thanks
    1 point
  24. @mLipok I found this -- https://support.google.com/youtube/answer/7060842?hl=en
    1 point
  25. LudwigIt, Welcome to the AutoIt forums. A simple way to do what you want is to use a dummy control: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Button", 10, 10, 80, 30) $cDummy = GUICtrlCreateDummy() GUISetState(@SW_SHOW) ; Set a timestamp $iTimer = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton, $cDummy ; Both events fire this code MsgBox($MB_SYSTEMMODAL, "Hi", "Button pressed") EndSwitch ; Check timestamp valid and if delay over 5 secs If $iTimer <> -1 And TimerDiff($iTimer) > 5000 Then ; Fire dummy event GUICtrlSendToDummy($cDummy) ; Invalidate timestamp - try commenting this line and see what happens!!!!!! $iTimer = -1 EndIf WEnd If you want to get a bit more complex you can differentiate between the button and the timer: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Button", 10, 10, 80, 30) $cDummy = GUICtrlCreateDummy() GUISetState(@SW_SHOW) ; Set a timestamp $iTimer = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton, $cDummy ; Both events fire this code ; But message changes depending on the event detected If GUICtrlRead($cDummy) = 9999 Then $sMsg = "Timer fired" ; Clear the dummy data - try commenting this line and see what happens!!!!!! GUICtrlSetData($cDummy, 0) Else $sMsg = "Button pressed" EndIf MsgBox($MB_SYSTEMMODAL, "Hi", $sMsg) EndSwitch ; Check timestamp valid and if delay over 5 secs If $iTimer <> -1 And TimerDiff($iTimer) > 5000 Then ; Fire dummy event GUICtrlSendToDummy($cDummy, 9999) ; Invalidate timestamp - try commenting this line and see what happens!!!!!! $iTimer = -1 EndIf WEnd Please ask if you have any questions. M23 P.S. When you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see in my posts above. Thanks in advance for your cooperation.
    1 point
  26. What I did so far: #include <GDIPlus.au3> #include <Array.au3> #include <WinAPIDiag.au3> ;--------- should be moved to GDIPlusConstants.au3 Global Const $GDIP_PROPERTYTAGTYPEBYTE = 1, $GDIP_PROPERTYTAGTYPEASCII = 2, $GDIP_PROPERTYTAGTYPESHORT = 3, _ $GDIP_PROPERTYTAGTYPELONG = 4, $GDIP_PROPERTYTAGTYPERATIONAL = 5, $GDIP_PROPERTYTAGTYPEUNDEFINED = 7, _ $GDIP_PROPERTYTAGTYPESLONG = 9, $GDIP_PROPERTYTAGTYPESRATIONAL = 10 ;------------------------------------------------- Global $aPropID Example() Func Example() Local $sImagefile = FileOpenDialog("Select a JPG image file", "", "JPG Image (*.jpg;*.jpeg)") If @error Then Exit _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sImagefile) $aPropID = _GDIPlus_ImageGetPropertyIdList($hImage) Local $a2PropertyItems = _GDIPlus_ImageGetAllPropertyItems($hImage) DisplayPropertyItems($a2PropertyItems) Local $hImageClone = _GDIPlus_ImageClone($hImage) ; copy image without property items Local $a1[4] For $i = 0 To UBound($a2PropertyItems, 1) - 1 ; set all property items For $j = 0 To 3 $a1[$j] = $a2PropertyItems[$i][$j] Next _GDIPlus_ImageSetPropertyItem($hImageClone, $a1) Next ; update a property item Local $a1value = ['Your name'] Local $a1 = [0x13B, 20, 2, $a1value] ; Artist _GDIPlus_ImageSetPropertyItem($hImageClone, $a1) ; add a property item Local $a1value = [2000] Local $a1 = [0xa002, -1, 4, $a1value] ; ExifWidth _GDIPlus_ImageSetPropertyItem($hImageClone, $a1) Local $a1value = [0xFFFE01] Local $a1 = [0x927C, 3, 7, $a1value] ; MakerNote _GDIPlus_ImageSetPropertyItem($hImageClone, $a1) $a2PropertyItems = _GDIPlus_ImageGetAllPropertyItems($hImageClone) DisplayPropertyItems($a2PropertyItems) $a1 = _GDIPlus_ImageGetPropertyItemEx($hImageClone, 0x927c) ;https://msdn.microsoft.com/en-us/library/ms534417.aspx Local $a2[1][4] For $i = 0 To 3 $a2[0][$i] = $a1[$i] Next DisplayPropertyItems($a2) _GDIPlus_Shutdown() EndFunc ;==>Example Func DisplayPropertyItems($a2PropertyItems) ; Collapse values arrays so _ArrayDisplay can display them Local $a2 = $a2PropertyItems, $iPos ReDim $a2[UBound($a2PropertyItems)][5] For $i = 0 To UBound($a2, 1) - 1 $a2[$i][0] = '0x' & Hex($a2PropertyItems[$i][0], 4) $a2[$i][3] = '' For $j = 0 To UBound($a2PropertyItems[$i][3]) - 1 $a2[$i][3] &= ($a2PropertyItems[$i][3])[$j] & '|' Next $a2[$i][3] = StringTrimRight($a2[$i][3], 1) $iPos = _ArraySearch($aPropID, $a2[$i][0]) If $iPos > -1 Then $a2[$i][4] = $aPropID[$iPos][1] Next _ArrayDisplay($a2, "Image Property Items", Default, 0, Default, "Identifier|Size|Type|Value|Description") EndFunc ;==>DisplayPropertyItems ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_ImageGetAllPropertyItems ; Description ...: Gets all property item (piece of meta data) from an Image object ; Syntax ........: _GDIPlus_ImageGetAllPropertyItems($hImage) ; Parameters ....: $hImage - Pointer to an image object ; Return values .: Success: Array in which each row contains these columns: ; [0] - identifier ; [1] - size, in bytes, of the value array ; [2] - type of value(s) in the value array ; [3] - value array ; Failure: Sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*). ; Author ........: c.haslam ; Modified ......: ; Remarks .......: types: unsigned byte = 1, ASCII string = 2, unsigned short = 3, unsigned long = 4, ; unsinged rational = 5, signed byte = 6, undefined = 7, signed long = 9, ; signed rational = 10 ; Related .......: _GDIPlus_ImageGetPropertyItemEx, _GDIPlus_ImageGetPropertyIdList, _GDIPlus_ImageSetPropertyItem ; Link ..........: https://msdn.microsoft.com/en-us/library/windows/desktop/ms535390(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534493(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534414(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/ms534416.aspx#_gdiplus_constant_propertytaggpsver ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_ImageGetAllPropertyItems($hImage) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetPropertySize", "handle", $hImage, "uint*", 0, "uint*", 0) If @error Then Return SetError(@error + 10, @extended, -1) If $aResult[0] Then Return SetError(20, $aResult[0], -1) Local $iTotalBufferSize = $aResult[2] Local $iNumProperties = $aResult[3] Local $tBuffer = DllStructCreate("byte[" & $iTotalBufferSize & "]") Local $pBuffer = DllStructGetPtr($tBuffer) $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetAllPropertyItems", "handle", $hImage, _ "uint", $iTotalBufferSize, "uint", $iNumProperties, "ptr", $pBuffer) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aPropertyItems[$iNumProperties][4] Local $a1 Local $tPropertyItem = DllStructCreate("int id; int length; short type; ptr value;") For $iI = 0 To $iNumProperties - 1 $a1 = __GDIPlus_ImageGetPropertyItemValues($pBuffer) For $j = 0 To 3 $aPropertyItems[$iI][$j] = $a1[$j] Next $pBuffer += DllStructGetSize($tPropertyItem) Next Return $aPropertyItems EndFunc ;==>_GDIPlus_ImageGetAllPropertyItems ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_ImageGetPropertyItemEx ; Description ...: Gets a specified property item (piece of meta data) from an Image object ; Syntax ........: _GDIPlus_ImageGetPropertyItemEx($hImage, $iPropID) ; Parameters ....: $hImage - Pointer to an image object ; $iPropID - Identifier of the property item to be retrieved ; Return values .: Success: Array containing the values of the property item ; [0] - identifier ; [1] - size, in bytes, of the value array ; [2] - type of value(s) in the value array ; [3] - value array ; Failure: Sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*). ; Author ........: Eukalyptus ; Modified ......: c.haslam ; Remarks .......: types: unsigned byte = 1, ASCII string = 2, unsigned short = 3, unsigned long = 4, ; unsinged rational = 5, signed byte = 6, undefined = 7, signed long = 9, ; signed rational = 10 ; Related .......: _GDIPlus_ImageGetPropertyIdList, _GDIPlus_ImageSetPropertyItem ; Link ..........: https://msdn.microsoft.com/en-us/library/windows/desktop/ms535390(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534493(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534414(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/ms534416.aspx#_gdiplus_constant_propertytaggpsver ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_ImageGetPropertyItemEx($hImage, $iPropID) Local $iSize = __GDIPlus_ImageGetPropertyItemSize($hImage, $iPropID) If @error Then Return SetError(@error + 10, @extended, False) Local $tBuffer = DllStructCreate("byte[" & $iSize & "];") Local $pBuffer = DllStructGetPtr($tBuffer) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItem", "handle", $hImage, "uint", _ $iPropID, "uint", $iSize, "struct*", $tBuffer) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return __GDIPlus_ImageGetPropertyItemValues($pBuffer) EndFunc ;==>_GDIPlus_ImageGetPropertyItemEx ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __GDIPlus_ImageGetPropertyItemValues($pBuffer) ; Description ...: Converts a project item from structured to equivalent nested arrays ; Syntax ........: __GDIPlus_ImageGetPropertyItemValues($pBuffer) ; Parameters ....: $bBuffer - Pointer to start of Property Item sructure ; Return values .: [0] - identifier ; [1] - size, in bytes, of the value array ; [2] - type of value(s) in the value array ; [3] - value array ; Author ........: c.haslam ; Modified ......: UEZ ; Remarks .......: types: unsigned byte = 1, ASCII string = 2, unsigned short = 3, unsigned long = 4, ; unsigned rational = 5, signed byte = 6, undefined = 7, signed long = 9, ; signed rational = 10 ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __GDIPlus_ImageGetPropertyItemValues($pBuffer) Local $tPropertyItem = DllStructCreate("int id; int length; short type; ptr value;", $pBuffer) Local $iBytes = DllStructGetData($tPropertyItem, "length") Local $pValue = DllStructGetData($tPropertyItem, "value") Local $aRet[4] Local $type = DllStructGetData($tPropertyItem, 'type') Local $tValues, $iValues Switch $type Case $GDIP_PROPERTYTAGTYPEASCII ;ASCII String $iValues = 1 $tValues = DllStructCreate("char[" & $iBytes & "];", $pValue) Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort $iValues = Int($iBytes / 2) $tValues = DllStructCreate("ushort[" & $iValues & "];", $pValue) Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL ;Array of UInt / Fraction $iValues = Int($iBytes / 4) $tValues = DllStructCreate("uint[" & $iValues & "];", $pValue) Case $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of Int / Fraction $iValues = Int($iBytes / 4) $tValues = DllStructCreate("int[" & $iValues & "];", $pValue) Case Else ;Array of Bytes $iValues = 1 $tValues = DllStructCreate("byte[" & $iBytes & "];", $pValue) EndSwitch $aRet[0] = DllStructGetData($tPropertyItem, 'id') $aRet[1] = $iBytes $aRet[2] = $type Local $a1values[$iValues] If $type = $GDIP_PROPERTYTAGTYPEASCII Or $type = $GDIP_PROPERTYTAGTYPEUNDEFINED Then ; ASCII string or undefined $a1values[0] = DllStructGetData($tValues, 1) Else For $i = 0 To $iValues - 1 $a1values[$i] = DllStructGetData($tValues, 1, $i + 1) Next EndIf $aRet[3] = $a1values Return $aRet EndFunc ;==>__GDIPlus_ImageGetPropertyItemValues ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_ImageSetPropertyItem ; Description ...: Sets a specified property item (piece of meta data) for an Image object ; Syntax ........: _GDIPlus_ImageGetPropertyItemEx($hImage, $a1PropertyItem) ; Parameters ....: $hImage - Pointer to an image object ; $a1PropertyItem - Array containing the values of the property item ; [0] - identifier ; [1] - size,of the value array ; positive: in bytes ; negative: for numeric types: in number of values ; [2] - type of value(s) in the value array ; [3] - value array ; Return values .: Success: True and @error = 0 ; Failure: sets the @error flag to non-zero ; + >0: DllCall failed. @extended contains GPSTATUS error code ($GPID_ERR*). ; + -1: size cannot be negative for ASCII string and undefined types ; Author ........: Eukalyptus ; Modified ......: c.haslam, UEZ ; Remarks .......: If size parameter is negative, calculates size in bytes from type. ; Convenient when setting a few property items ; + ; types: unsigned byte = 1, ASCII string = 2, unsigned short = 3, unsigned long = 4, ; unsinged rational = 5, undefined = 7, signed long = 9, signed rational = 10 ; Related .......: _GDIPlus_ImageGetPropertyIdList, _GDIPlus_ImageGetPropertyItemEx ; Link ..........: https://msdn.microsoft.com/en-us/library/windows/desktop/ms535390(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534493(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534414(v=vs.85).aspx ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_ImageSetPropertyItem($hImage, $a1PropertyItem) Local $iId = $a1PropertyItem[0] Local $iLength = $a1PropertyItem[1] Local $iType = $a1PropertyItem[2] Local $a1values = $a1PropertyItem[3] Local $iBytes, $iqValues If $iLength > 0 Then ; useful when copying all property items $iBytes = $iLength Switch $iType Case $GDIP_PROPERTYTAGTYPEASCII ;ASCII String $iqValues = 1 Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort $iqValues = Int($iLength / 2) Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL, $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of UInt / Fraction $iqValues = Int($iLength / 4) Case Else ; Array of Bytes, undefined $iqValues = 1 EndSwitch ElseIf $iLength < 0 Then ; convenient when setting a few property items Switch $iType Case $GDIP_PROPERTYTAGTYPEASCII, $GDIP_PROPERTYTAGTYPEUNDEFINED ;ASCII String, undefined Return SetError(-1) Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort $iBytes = -$iLength * 2 Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL, $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of UInt / Fraction $iBytes = -$iLength * 4 Case Else ;Array of Bytes $iqValues = 1 $iBytes = -$iLength EndSwitch $iqValues = -$iLength EndIf Local $tPropItem = DllStructCreate("int id; int length; short type; ptr pValue;") DllStructSetData($tPropItem, 'id', $iId) DllStructSetData($tPropItem, 'length', $iBytes) DllStructSetData($tPropItem, 'type', $iType) Local $tValues Switch $iType Case $GDIP_PROPERTYTAGTYPEASCII ;ASCII String $tValues = DllStructCreate("char[" & $iBytes & "];") Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort $tValues = DllStructCreate("ushort[" & $iqValues & "];") Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL ;Array of UInt / Fraction $tValues = DllStructCreate("uint[" & $iqValues & "];") Case $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of Int / Fraction $tValues = DllStructCreate("int[" & $iqValues & "];") Case Else ;Array of Bytes $tValues = DllStructCreate("byte[" & $iBytes & "];") EndSwitch If $iType = $GDIP_PROPERTYTAGTYPEASCII Or $iType = $GDIP_PROPERTYTAGTYPEUNDEFINED Then ; ASCII string or undefined DllStructSetData($tValues, 1, $a1values[0]) Else For $i = 0 To $iqValues - 1 DllStructSetData($tValues, 1, $a1values[$i], $i + 1) Next EndIf DllStructSetData($tPropItem, 'pValue', DllStructGetPtr($tValues)) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipSetPropertyItem", "handle", $hImage, "struct*", $tPropItem) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return True EndFunc ;==>_GDIPlus_ImageSetPropertyItem Any suggestion?
    1 point
×
×
  • Create New...