Leaderboard
Popular Content
Showing content with the highest reputation on 04/21/2018 in all areas
-
TeraCopy Timer - A program of mine, front end really, that I have been working on (on & off) for some time, but not shared here before, that I recall. Third party program TeraCopy is required. Many of you will be familiar with TeraCopy, and it has been discussed here at AF on several occasions, in various sub forums, including Chat. BE ADVISED - I still use an older version of TeraCopy (v2.27), a goody but an oldy, so have only tested my program with that. It may work with the newer v3.xx, or may be easily adjusted to do so, but I have not yet gone that route. Likewise, I only use it with Win 7 and Win XP, but I don't imagine there should be any issues with newer Windows. Add to that, my program being devised and created in AutoIt v3.3.0.0. So what is TeraCopy Timer and why might you need it? -------------------------------------------------------------------------------------- Those familiar with TeraCopy use, know you can run multiple copy or move jobs either simultaneously or concurrently (one immediately after another has finished). With the free version at least, you have no control over precise order or timing, and no way to deal (without manual interaction) with the pesky Thumbs.db files in Win XP. TeraCopy Timer allows you to do all those things, and in a batch fashion. -------------------------------------------------------------------------------------- Some screenshots and brief explanation Main Window Minimalist Window This new WAIT feature is the simplest and best way to use the program generally (in my view) ... but check out the following, as it is not always the case. Advanced Delay Window WARNING - It should go without saying, that you take all the usual precautions. For instance, don't use move with the only copy you have of precious files. BACKUP BACKUP BACKUP! Don't hold me liable for anything, except for being a nice guy who likes to share. TeraCopy Timer v3.5.zip (MAJOR UPDATE - see detail at Post #39) Enjoy! OLDER DOWNLOADS P.S. I am not affiliated in any way with those who created and provide the excellent third party program - TeraCopy.1 point
-
Need Help with Web Automation
PleaseHelpMEIWillLoveyou reacted to Subz for a topic
There are number of functions it all depends upon the code of the website, for example does it have a name or id attribute _IEGetObjById _IEGetObjByName Otherwise use _IETagNameGetCollection To get all tags then check if the innertext equals xyz or className = xyz, there are a number of options, you can search for MSDN IE DOM and you can any of those object modules within Autoit.1 point -
Trigger file's context menu
Earthshine reacted to therks for a topic
Just popping in to say that's exactly what I was looking for, @Subz. Never would have imagined it would entail building/managing the menu itself though.1 point -
FF.au3 (v0.6.0.1b-15) [End of life]
ConnorMcLeod reacted to Danp2 for a topic
Done. Thanks for the suggestion. The WebDriver UDF is definitely an alternative to this one. Check it out and post any questions to this thread in the GH&S section.1 point -
Function with both HotKey and Program calls
Earthshine reacted to Melba23 for a topic
Hi all, For reasons that are too complicated to explain in a short post I wanted to create a function which could be called by a HotKey (which ignores any parameters) and also called programmatically from within the script with various parameters. After much experimentation I came up with the following syntax and logic: Global $bFlag_1 = False, $bFlag_2 = False HotKeySet("^r", "_Test") HotKeySet("{ESC}", "_Exit") ; Default param so no action taken _Test() ; Use param to set Flag_1 to True _Test(1) ; And back to False _Test(0) ; Now play with the HotKey to change Flag_2 While 1 Sleep(10) WEnd Func _Test($vParam = 9999) #forceref $vParam ; Prevents Au3Check warning Eval("vParam") If Not @error Then ; Fired programatically so use parameter to set/clear Flag_1 Switch Eval("vParam") Case 9999 ; Do nothing Case 0 $bFlag_1 = False Case 1 $bFlag_1 = True EndSwitch Else ; Not fired programatically so parameter ignored and set/clear Flag_2 $bFlag_2 = Not $bFlag_2 EndIf ConsoleWrite($bFlag_1 & " - " & $bFlag_2 & @CRLF) EndFunc Func _Exit() Exit EndFunc Does anyone have a better way of doing this? M231 point -
Function with both HotKey and Program calls
Earthshine reacted to Jos for a topic
No sure it is simpler but a little different approach: Func _Test($vParam = 9999) #forceref $vParam ; Prevents Au3Check warning If Not @NumParams Then If Eval("vParam") <> 9999 Then ; Not fired programatically so parameter ignored and set/clear Flag_2 $bFlag_2 = Not $bFlag_2 EndIf Else ; Fired programatically so use parameter to set/clear Flag_1 $bFlag_1 = ($vParam <> 0) EndIf ConsoleWrite($bFlag_1 & " - " & $bFlag_2 & " @NumParams=" & @NumParams & @CRLF) EndFunc ;==>_Test Jos1 point -
try this... Local $sFile = @ScriptDir & "\Dir With Space\Test file with apostrophe' character.txt" Local $objWMI = ObjGet('winmgmts:root\cimv2') Local $objItem = $objWMI.Get('Win32_LogicalFileSecuritySetting.Path="' & StringReplace($sFile, '\', '\\') & '"') Local $objSD, $nResult = $objItem.GetSecurityDescriptor($objSD) ; If $nResult = 0 Then MsgBox(0, '', 'Owner: ' & $objSD.Owner.Domain & '\' & $objSD.Owner.Name) Else MsgBox(0, '', "Couldn't retrieve security descriptor.") EndIf1 point
-
RTFC, Any explanation that refers to IKEA furniture cannot, by definition, be considered "simple"! M231 point
-
Try this: ;coded by UEZ #include <GDIPlus.au3> _GDIPlus_Startup() $sIn = StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\msoobe.jpg") ;this will not work when script is compiled $sOut = @ScriptDir & "\Watermarked.jpg" FileDelete($sOut) $r = _GDIPlus_WatermarkImage($sIn, $sOut, "Watermarked by UEZ", 50, 50, 2, "Arial", 64, 0, 100) _GDIPlus_Shutdown() If $r Then ShellExecute($sOut) Exit ;====================================================================================== ; Function Name: _GDIPlus_WatermarkImage ; Description: adds a text to an image ; ; Parameters: $sBitmapFile: image file to load ; $sSave: filename for saved image -> if no extension (jpg, bmp, png, gif, tif) is given the default is png image format ; $sText: text string to draw onto the image ; $iX: x position of the text on the image ; $iY: y position of the text on the image ; ;Optional: $iPos: possition text to one of 9 possitions on the image. If set $iX and $iY will be ignored! ; 0: turned off ; 1: upper left, 2: upper mid, 3: upper right ; 4: mid left, 5: center, 6: mid right ; 7: buttom left, 8: buttom mid, 9: buttom right ; $sFontName: font name to use, default is Arial ; $iFontSize: size of the font, default is 16 ; $fAngle: angle of the text -> 0° - 359° ; $iAdjY: adjust y position of the text when $iPos is selected ; $iAdjX: adjust x position of the text when $iPos is selected ; $iFontColor: color of the text ; $fAlpha: alpha channel of the text -> 0.0 (transparent) - 1.0 (opaque) ; $iJPGQuality: JPG save quality -> 0 (worst) - 100 (best) ; ; Requirement(s): GDIPlus.au3 ; Return Value(s): Success: 1 or the handle of the bitmap (don't forget to dispose it when done!) ; Error: ; Error codes: 1: image file to load not found ; 2: unable to create bitmap from loaded image ; 3: unable to save watermarked image ; ; Remark: don't forget to start _GDIPlus_Startup() / _GDIPlus_Shutdown() ; ; Author(s): UEZ ; Version: v1.00 Build 2012-10-31 Beta ;======================================================================================= Func _GDIPlus_WatermarkImage($sBitmapFile, $sSave, $sText, $iX, $iY, $iPos = 0, $sFontName = "Arial", $iFontSize = 16, $fAngle = 0, $iAdjY = 0, $iAdjX = 0, $iFontColor = 0xFFFFFF, $fAlpha = 0.04, $iJPGQuality = 90, $bLineBreak = True) If Not FileExists($sBitmapFile) Then Return SetError(1, 0, 0) Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sBitmapFile) If Not $hBitmap Then Return SetError(2, 0, 0) If $fAlpha < 0 Then $fAlpha = 0 If $fAlpha > 1 Then $fAlpha = 1 Local $iW = _GDIPlus_ImageGetWidth($hBitmap) , $iH = _GDIPlus_ImageGetHeight($hBitmap) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hBrush = _GDIPlus_BrushCreateSolid(BitShift(Int($fAlpha * 0xFF), -24) + $iFontColor) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFontName) Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, 0) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) Local $aMeasure = _GDIPlus_GraphicsMeasureString($hCtxt, $sText, $hFont, $tLayout, $hFormat) Local $iWTxt = Ceiling(DllStructGetData($aMeasure[0], "width") ) Local $iHTxt = Ceiling(DllStructGetData($aMeasure[0], "height")) If Not $fAngle Then _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt, "int", 4) If $bLineBreak And $iWTxt > $iW Then DllStructSetData($tLayout, "width", $iW) DllStructSetData($tLayout, "height", 0) $aMeasure = _GDIPlus_GraphicsMeasureString($hCtxt, $sText, $hFont, $tLayout, $hFormat) $iWTxt = Ceiling(DllStructGetData($aMeasure[0], "width") ) $iHTxt = Ceiling(DllStructGetData($aMeasure[0], "height")) EndIf If Not Int($iPos) Or Int($iPos) > 9 Then DllStructSetData($tLayout, "x", $iX) DllStructSetData($tLayout, "y", $iY) _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush) Else DllStructSetData($tLayout, "x", $iAdjX) DllStructSetData($tLayout, "width", $iW) Switch $iPos Case 1 To 3 DllStructSetData($tLayout, "y", $iAdjY) _GDIPlus_StringFormatSetAlign($hFormat, $iPos - 1) Case 4 To 6 DllStructSetData($tLayout, "y", ($iH - $iHTxt) / 2 + $iAdjY) _GDIPlus_StringFormatSetAlign($hFormat, $iPos - 4) Case 7 To 9 DllStructSetData($tLayout, "y", $iH - $iHTxt + $iAdjY) _GDIPlus_StringFormatSetAlign($hFormat, $iPos - 7) EndSwitch _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush) EndIf Else Local $iQ $fAngle = Mod($fAngle, 360) $iW = Int(DllStructGetData($aMeasure[0], "width") * 2) $iH = Int(DllStructGetData($aMeasure[0], "height") * 2) If $iW > $iH Then $iQ = $iW Else $iQ = $iH EndIf Local $hBitmap_Rot = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iQ, "int", $iQ, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap_Rot = $hBitmap_Rot[6] Local $hCtxt_Rot = _GDIPlus_ImageGetGraphicsContext($hBitmap_Rot) _GDIPlus_GraphicsSetSmoothingMode($hCtxt_Rot, 2) DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt_Rot, "int", 4) Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $iQ / 2, $iQ / 2) _GDIPlus_MatrixRotate($hMatrix, $fAngle, False) _GDIPlus_MatrixTranslate($hMatrix, -$iQ / 2, -$iQ / 2) _GDIPlus_GraphicsSetTransform($hCtxt_Rot, $hMatrix) DllStructSetData($tLayout, "x", $iQ / 2) DllStructSetData($tLayout, "y", $iQ / 2) _GDIPlus_GraphicsDrawStringEx($hCtxt_Rot, $sText, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsDrawImageRect($hCtxt, $hBitmap_Rot, $iX - $iQ / 2, $iY - $iQ / 2, $iQ, $iQ) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_GraphicsDispose($hCtxt_Rot) _GDIPlus_BitmapDispose($hBitmap_Rot) EndIf _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hCtxt) $tLayout = 0 If $sSave <> "" Then Local $bRes If StringRight($sSave, 4) = ".jpg" Then Local Const $sCLSID = _GDIPlus_EncodersGetCLSID("JPG") Local $tParams = _GDIPlus_ParamInit(1) Local $tData = DllStructCreate("int Quality") If $iJPGQuality < 0 Then $iJPGQuality = 0 If $iJPGQuality > 100 Then $iJPGQuality = 100 DllStructSetData($tData, "Quality", $iJPGQuality) Local $pData = DllStructGetPtr($tData) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Local Const $pParams = DllStructGetPtr($tParams) $bRes = _GDIPlus_ImageSaveToFileEx($hBitmap, $sSave, $sCLSID, $pParams) $tData = 0 $tParams = 0 Else StringRegExp($sSave, ".*.(gif|png|bmp|tif)", 1) If @error Then If StringRight($sSave, 1) = "." Then $sSave &= "png" Else $sSave &= ".png" EndIf EndIf $bRes = _GDIPlus_ImageSaveToFile($hBitmap, $sSave) EndIf _GDIPlus_BitmapDispose($hBitmap) If Not $bRes Then Return SetError(3, 0, 0) Return 1 EndIf Return $hBitmap EndFunc Edit1: forgot 2 lines which are added now Edit2: added some more features Edit3: the backslashes were gone - added again Br, UEZ1 point
-
GDIPLUS Draw on a Control
Xandy reacted to AdmiralAlkex for a topic
Sure, just do the usual (with the handle from GUICtrlGetHandle). Quick example: #Include <GDIPlus.au3> _GDIPlus_Startup() GUICreate("test", 640, 480) GUISetState() GUICtrlCreateLabel("", 100, 100, 200, 100) $Handle = GUICtrlGetHandle(-1) $graphics = _GDIPlus_GraphicsCreateFromHWND($Handle) _GDIPlus_GraphicsDrawString($graphics, "hello from Label", 5, 5) Do Until GUIGetMsg() = -3 ;$GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Doesn't really matter I would say, but the last one sounds complex. Just use whatever you are most comfortable with. Me myself, I probably wouldn't use GDI+ at all, but that's me. Edit: 2 more sentences.1 point -
Was waiting for chicken to cook, so I combined them for you: #RequireAdmin If DisplayChangeRes(1920, 1080, 32, 60) = 0 Then MsgBox(0, "Error", "Invalid resolution selected") Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ) If CheckDisplay($WIDTH, $HEIGHT, $BPP, $FREQ) = 0 Then Return 0 EndIf $DM_PELSWIDTH = 0x00080000 $DM_PELSHEIGHT = 0x00100000 $DM_BITSPERPEL = 0x00040000 $DM_DISPLAYFREQUENCY = 0x00400000 $CDS_TEST = 0x00000002 $CDS_UPDATEREGISTRY = 0x00000001 $DISP_CHANGE_RESTART = 1 $DISP_CHANGE_SUCCESSFUL = 0 $HWND_BROADCAST = 0xffff $WM_DISPLAYCHANGE = 0x007E $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]") $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE)) If @error Then $B = 0 Else $B = $B[0] EndIf If $B <> 0 Then DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5) DllStructSetData($DEVMODE, 4, $WIDTH, 2) DllStructSetData($DEVMODE, 4, $HEIGHT, 3) DllStructSetData($DEVMODE, 4, $BPP, 1) DllStructSetData($DEVMODE, 4, $FREQ, 5) $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) If @error Then $B = -1 Else $B = $B[0] EndIf Select Case $B = $DISP_CHANGE_RESTART $DEVMODE = "" Return 2 Case $B = $DISP_CHANGE_SUCCESSFUL DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH) $DEVMODE = "" Return 1 Case Else $DEVMODE = "" Return $B EndSelect EndIf Return 1 EndFunc ;==>DisplayChangeRes Func CheckDisplay($w, $h, $bit, $f) $flag = 0 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") $colItems = $objWMIService.ExecQuery("SELECT * FROM CIM_VideoControllerResolution", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $w = $objItem.HorizontalResolution And $h = $objItem.VerticalResolution And 2^$bit = $objItem.NumberOfColors And $f = $objItem.RefreshRate Then $flag = 1 Next EndIf Return $flag EndFunc ;==>CheckDisplay1 point