Jump to content

Sidley

Active Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by Sidley

  1. My understanding is that changing the global variable within a function only changes the value for the scope of that function, if you need to change the value within the program as a whole you need to use the ByRef keyword. Passing it by reference will alter the variable outside the function: #AutoIt3Wrapper_run_debug_mode=Y ; use this to debug in console window <--- LOOK Global $p = 999 MsgBox(0, "DEBUG", "MAIN - $p = '" & $p & "'") __One($p) Exit Func __One(ByRef $p) ;Global $p ;this seems to make no difference - comment it out to see - how does one affect the Global in a function? MsgBox(0, "DEBUG", "Entering Func __One() - $p = '" & $p & "'") For $p = 1 to 3 MsgBox(0, "DEBUG", "IN Func __One() - $p = '" & $p & "'") __Two() Next EndFunc Func __Two() MsgBox(0, "DEBUG", "Entering __Two() $p = '" & $p & "'") EndFunc
  2. I couldn't leave it alone 😀 There was a bug that caused different offsets to change the overall size of the image, this fixes that. #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $main = GUICreate(" ", 300, 300, -1, -1) GUICtrlCreatePic("", 15, 15, 256, 256) CreateBG(-1, 250, 0XFFFF9000) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) ;Main Process Loop ====================================================================================== While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ;== Graphic Functions ====================================== Func CreateBG($control, $gw, $color) _GDIPlus_Startup() Local $ghandle = _GDIPlus_GraphicsCreateFromHWND($main) Local $hImage = _GDIPlus_BitmapCreateFromGraphics($gw, $gw, $ghandle) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) Local $hBrush = _GDIPlus_BrushCreateSolid($color) Local $hBrush2 = _GDIPlus_BrushCreateSolid(0xFF000000) Local $hPath = _GDIPlus_PathCreate() Local $nBorderSize = 100 $gw -= $nBorderSize; ;Offset to allow for scaling Local $nOffset = $nBorderSize/2 _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 5) ;Path used instead of Graphic _GDIPlus_PathAddEllipse($hPath, 0+$nOffset, ($gw/8)+$nOffset, ($gw/4), ($gw*0.75)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, 0+$nOffset, ($gw*0.75), ($gw/4)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw/4))+$nOffset, ($gw/8)+$nOffset, ($gw/4), ($gw*0.75)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, ($gw-($gw/4))+$nOffset, ($gw*0.75), ($gw/4)) _GDIPlus_PathAddEllipse($hPath, ($gw/18)+$nOffset, ($gw/18)+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw*0.43))+$nOffset, ($gw/18)+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw*0.43))+$nOffset, ($gw-($gw*0.43))+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw/18)+$nOffset, ($gw-($gw*0.43))+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, ($gw/8)+$nOffset, ($gw*.75), ($gw*.75)) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_PathSetFillMode($hPath, 1) ;Set fill mode to union Local $hPath2 = _GDIPlus_PathClone($hPath) ;Clone the first path Local $hPen_Widen = _GDIPlus_PenCreate(0, $nBorderSize) _GDIPlus_PenSetLineJoin($hPen_Widen, $GDIP_PENSETLINEJOIN_ROUND) _GDIPlus_PathWiden($hPath2, $hPen_Widen) ;Widen second path _GDIPlus_GraphicsFillPath($hGraphic, $hPath2, $hBrush2) ; IMPORTANT Fill second path to graphic first _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Then first path on top $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($control, $STM_SETIMAGE, $IMAGE_BITMAP, $hbitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Endfunc
  3. Give this a go. #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $main = GUICreate(" ", 300, 300, -1, -1) GUICtrlCreatePic("", 15, 15, 256, 256) CreateBG(-1, 250, 0XFFFF9000) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) ;Main Process Loop ====================================================================================== While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ;== Graphic Functions ====================================== Func CreateBG($control, $gw, $color) _GDIPlus_Startup() Local $ghandle = _GDIPlus_GraphicsCreateFromHWND($main) Local $hImage = _GDIPlus_BitmapCreateFromGraphics($gw, $gw, $ghandle) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) Local $hBrush = _GDIPlus_BrushCreateSolid($color) Local $hBrush2 = _GDIPlus_BrushCreateSolid(0xFFFF0000) Local $hPath = _GDIPlus_PathCreate() Local $nOffset = 4 $gw -= $nOffset*2 ;Offset to allow for scaling _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 5) ;Path used instead of Graphic _GDIPlus_PathAddEllipse($hPath, 0+$nOffset, ($gw/8)+$nOffset, ($gw/4), ($gw*0.75)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, 0+$nOffset, ($gw*0.75), ($gw/4)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw/4))+$nOffset, ($gw/8)+$nOffset, ($gw/4), ($gw*0.75)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, ($gw-($gw/4))+$nOffset, ($gw*0.75), ($gw/4)) _GDIPlus_PathAddEllipse($hPath, ($gw/18)+$nOffset, ($gw/18)+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw*0.43))+$nOffset, ($gw/18)+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw-($gw*0.43))+$nOffset, ($gw-($gw*0.43))+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw/18)+$nOffset, ($gw-($gw*0.43))+$nOffset, ($gw*0.375), ($gw*0.375)) _GDIPlus_PathAddEllipse($hPath, ($gw/8)+$nOffset, ($gw/8)+$nOffset, ($gw*.75), ($gw*.75)) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_PathSetFillMode($hPath, 1) ;Set fill mode to union Local $hPath2 = _GDIPlus_PathClone($hPath) ;Clone the first path Local $hPen_Widen = _GDIPlus_PenCreate(0, $nOffset) _GDIPlus_PenSetLineJoin($hPen_Widen, $GDIP_PENSETLINEJOIN_ROUND) _GDIPlus_PathWiden($hPath2, $hPen_Widen) ;Widen second path _GDIPlus_GraphicsFillPath($hGraphic, $hPath2, $hBrush2) ; IMPORTANT Fill second path to graphic first _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Then first path on top $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($control, $STM_SETIMAGE, $IMAGE_BITMAP, $hbitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Endfunc
  4. There's probably people on here who can pretty this up no end, but this should do you #include <AutoItConstants.au3> #include <Misc.au3> Local $aMousePos Local $i While Not _IsPressed('1B') ;Do until ESC key is pressed If _IsPressed('01') Then ;If left mouse button is clicked $aMousePos = MouseGetPos() ;Returns an array [0]=X position, [1]=Y position For $i=0 To 4 ;Loop from 0 to 4 $aMousePos[0] += 50 ;Each time add 50 pixels to the X position MouseMove($aMousePos[0], $aMousePos[1]) ;Move the mouse to (New X position, original Y position) ConsoleWrite($aMousePos[0] + @CRLF) ;For debugging purposes, remove if you want MouseClick($MOUSE_CLICK_LEFT) ;Click the left mouse button Next EndIf WEnd
  5. With the script running on the desktop, all files between the given positions would highlight (Yes, I have way too many files on my desktop).
  6. It works as in it shift-clicks, moves, shift-clicks, moves, ad nauseum. No idea what the end goal is, but seems to function as reading through the script would suggest it does. I used the term 'work' loosely, perhaps 'function' would be a better description.
  7. The script seems to work for me, but as Nine said, it's difficult to know if it's doing what you want it to do without you telling us what you want it to do.
  8. That seems to be correct, lloks like black is used as the mask colour for the blur/transparency so the closer the item colour gets to black the more transparent it is. White works well but obviously over a dark background. I've had a play about with the settings but I can't see any way of changing the mask colour.
  9. See below. No idea if you can set the background colour to make it readable. #include <GUIConstants.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> If _WinAPI_DwmIsCompositionEnabled() Then $iHasDWM=1 Local $iHeight=300 Local $iWidth=300 $hGUI = GUICreate("Windows 10 Blur", $iWidth, $iHeight,-1,-1) Local $idButton1 = GUICtrlCreateButton("test", 10,10, 75, 25) ;Assign button to id variable Local $idInput1 = GUICtrlCreateInput("test", 10,40, 75, 25) GUISetBkColor(0x000000) GUISetState() If $iHasDWM Then Local $hRgn = _WinAPI_CreateRoundRectRgn(0,0,$iWidth+1,$iHeight+1,50,50) Local $hFormRgn=_WinAPI_CreateRectRgnIndirect(_WinAPI_GetClientRect($hGUI)) Local $hRgnTest=_WinAPI_CreateNullRgn() _WinAPI_CombineRgn($hRgnTest,$hRgn,$hFormRgn,$RGN_XOR) _WinAPI_DwmEnableBlurBehindWindow($hGUI,1,1,$hRgnTest) _WinAPI_DwmEnableBlurBehindWindow10($hGUI) EndIf Local $sText = "" While 1 Local $idMsg = GUIGetMsg() ;Assign GUIGetMsg() result to variable Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idButton1 ;If GUI Msg received = button id $sText = GUICtrlRead($idInput1) MsgBox($MB_SYSTEMMODAL, "", "Text is: " & $sText) ;Action here EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_DwmEnableBlurBehindWindow10 ; Description ...: Enables Aero-like blurred background in Windows 10. ; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow10($hWnd[, $iMode = $ACCENT_ENABLE_BLURBEHIND]) ; Parameters ....: $hWnd - Window handle. ; $bEnable - [optional] Enable or disable the blur effect. ; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information. ; Author ........: scintilla4evr ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://vhanla.codigobit.info/2015/07/enable-windows-10-aero-glass-aka-blur.html and http://undoc.airesoft.co.uk/user32.dll/SetWindowCompositionAttribute.php ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_DwmEnableBlurBehindWindow10($hWnd, $bEnable = True) Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId") Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size") $tAccentPolicy.AccentState = $bEnable ? 3 : 0 $tAttrData.Attribute = 19 ; WCA_ACCENT_POLICY $tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy) $tAttrData.Size = DllStructGetSize($tAccentPolicy) Local $aResult = DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "ptr", DllStructGetPtr($tAttrData)) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc
  10. I don't think '&&' is an AutoIt operator, try using 'And' instead. '&' is a string concatenator, not a logical operator. https://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm
  11. ImageSearch2015 seems to fix this issue.
  12. The first one seems to work for me without errors. Edit: Not if I take out the _ArrayDisplay($aPrograms[0]) line though.
  13. You might want to change the name of the global variable as well 😉
  14. At the moment, the line only draws once, when you resize the GUI the line will have to be redrawn. I'm sure there's a way to do this on a GUI resize event, but for the moment it's probably easier to just constantly redraw the line in the do..while loop starting on line 28. And as @Nine said using a back buffer should always be used with GDI plus graphics, especially when you start adding more and more complex images. It basically assembles all the graphics in the background before presenting the completed image to the screen. #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ;create a Graphics object from a window handle $hGUI = GUICreate("_GDIPlus_CustomLineCapCreate Example", 400,300,200,200, BitOR($WS_SIZEBOX ,$WS_MAXIMIZEBOX, $WS_MINIMIZEBOX ) ) GUISetBkColor(0x303030 , $hGUI) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(400, 300, $hGraphic) ;Create bitmap object Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) ;Create backbuffer $hPen = _GDIPlus_PenCreate(0xFFFF0000, 5) ; $hBrush = _GDIPlus_BrushCreateSolid(0xFFE0A0FF) ;color format AARRGGBB (hex) ;_GDIPlus_GraphicsDrawEllipse($hGraphic, 130, 100, 140, 70, $hPen ) ;_GDIPlus_GraphicsFillEllipse($hGraphic, 130, 100, 140, 70, $hBrush ) ;_GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen) GUISetOnEvent($GUI_EVENT_CLOSE, "End") Do _GDIPlus_GraphicsClear($backbuffer, 0xFF000000 + 0x303030) ;Fill the GUI with background colour (Overwrite the old line) _GDIPlus_GraphicsDrawLine($backbuffer, 10, 150, 390, 150, $hPen) ;Redraw the line to the back buffer _GDIPlus_GraphicsDrawImageRect($hGraphic, $bitmap, 0, 0, 400, 300);Draw the backbuffer to the screen Until Not Sleep(100) Func End() _GDIPlus_GraphicsDispose($backbuffer) ;Dispose of back buffer _GDIPlus_PenDispose ( $hPen ) ;_GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndFunc
  15. Those UBounds should read UBound($Variable) - 1, and not UBound($Variable-1), sorry about that. Don't know if it'll make a difference.
  16. Basic comparison logic would be as follows (untested), but as @water said, there are better and more efficient ways of doing it. For $i = 0 To UBound($smallArray - 1) For $j = 0 To UBound($bigArray - 1) If $smallArray[$i] = $bigArray[$j] Then FileCopy("Path\To\Source\" & $smallArray[$i], "Path\To\Destination\Filename.file", $FC_NOOVERWRITE) Else ConsoleWrite("No match found for " & $smallArray[$i] & @CRLF) EndIf Next Next
  17. Your matrix is rotating around the bottom right corner, set the matrix to rotate around the centre (half the image width, half the image height, line 42). You will also need to offset the drawn graphic by that much to compensate (line 66). Test label on line 63. You've also got a memory leak, but that's for you to track #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hAttribute_Alpha Global $tColorMatrix Global $g_back Global $g_Needle Global $g_hImage_Background Global $g_hImage_Needle Global $g_hGfx_Background Global $g_hGfx_needle Global $hMatrix GUISetState() $g_hGUI = GUICreate("Test", 356, 356, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW)) _GDIPlus_Startup() $Needle = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\needle.png") $Background = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\back.png") Func _CreateGraphic() $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate() $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, 0) ;0 = opaque, -1 = transparent _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, DllStructGetPtr($tColorMatrix)) $g_back = _GDIPlus_ImageGetDimension($Background) $g_Needle = _GDIPlus_ImageGetDimension($Needle) $g_hImage_Background = _GDIPlus_BitmapCreateFromScan0($g_back[0], $g_back[1]) ; Creeaza imaginea dupa dimensiunile pozei incarcate mai sus $g_hImage_Needle = _GDIPlus_BitmapCreateFromScan0($g_Needle[0], $g_Needle[1]) ; Adaugat $g_hGfx_Background = _GDIPlus_ImageGetGraphicsContext($g_hImage_Background) $g_hGfx_needle = _GDIPlus_ImageGetGraphicsContext($g_hImage_Needle) ; Adaugat _GDIPlus_GraphicsDrawImageRectRect($g_hGfx_Background, $Background, 0, 0, $g_back[0], $g_back[1], 0, 0, $g_back[0], $g_back[1], $hAttribute_Alpha) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $g_Needle[0]/2, $g_Needle[1]/2) EndFunc ; Loop until user exits $Rotation = 0 ;Do While Not GUIGetMsg() = $GUI_EVENT_CLOSE If $Rotation=365 Then $Rotation=0 EndIf __Rotate($Rotation) $Rotation += 5; ConsoleWrite($Rotation & @CRLF) Sleep(1000) WEnd Func __Rotate($i) _CreateGraphic() _GDIPlus_GraphicsClear($g_hGfx_needle, 0xFF000000) _GDIPlus_GraphicsDrawImageRectRect($g_hGfx_Background, $Background, 0, 0, $g_back[0], $g_back[1], 0, 0, $g_back[0], $g_back[1], $hAttribute_Alpha) $g_hGfx_Background = _GDIPlus_ImageGetGraphicsContext($g_hImage_Background) _GDIPlus_GraphicsDrawString($g_hGfx_Background, "Test", $g_back[0]/2, 30) _GDIPlus_MatrixRotate($hMatrix, $i) _GDIPlus_GraphicsSetTransform($g_hGfx_Background, $hMatrix) _GDIPlus_GraphicsDrawImageRect($g_hGfx_Background, $Needle, -$g_Needle[0]/2, -$g_Needle[1]/2, $g_Needle[0], $g_Needle[1]) SetBitmap($g_hGUI, $g_hImage_Background, 255) GUISetState() EndFunc IF GUIGetMsg=$GUI_EVENT_CLOSE Then _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_ImageAttributesDispose($hAttribute_Alpha) _GDIPlus_ImageDispose($Needle) _GDIPlus_ImageDispose($g_hImage_Background) _GDIPlus_ImageDispose($Background) _GDIPlus_GraphicsDispose($g_hGfx_Background) _GDIPlus_Shutdown() EndIf Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap
  18. The needle is copied to the background each time, you will also need to clear the background as well as the needle and redraw each time you rotate. Try this: #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hAttribute_Alpha Global $tColorMatrix Global $g_back Global $g_Needle Global $g_hImage_Background Global $g_hImage_Needle Global $g_hGfx_Background Global $g_hGfx_needle Global $hMatrix GUISetState() $g_hGUI = GUICreate("Test", 356, 356, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW)) _GDIPlus_Startup() $Needle = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\needle.png") $Background = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\back.png") Func _CreateGraphic() $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate() $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, 0) ;0 = opaque, -1 = transparent _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, DllStructGetPtr($tColorMatrix)) $g_back = _GDIPlus_ImageGetDimension($Background) $g_Needle = _GDIPlus_ImageGetDimension($Needle) $g_hImage_Background = _GDIPlus_BitmapCreateFromScan0($g_back[0], $g_back[1]) ; Creeaza imaginea dupa dimensiunile pozei incarcate mai sus $g_hImage_Needle = _GDIPlus_BitmapCreateFromScan0($g_Needle[0], $g_Needle[1]) ; Adaugat $g_hImage_Needle = _GDIPlus_ImageResize($g_hImage_Needle, 10, 10) $g_hGfx_Background = _GDIPlus_ImageGetGraphicsContext($g_hImage_Background) $g_hGfx_needle = _GDIPlus_ImageGetGraphicsContext($g_hImage_Needle) ; Adaugat _GDIPlus_GraphicsDrawImageRectRect($g_hGfx_Background, $Background, 0, 0, $g_back[0], $g_back[1], 0, 0, $g_back[0], $g_back[1], $hAttribute_Alpha) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $g_Needle[0], $g_Needle[1]) EndFunc $Rotation = 0 ; Loop until user exits While Not GUIGetMsg() = $GUI_EVENT_CLOSE If $Rotation=360 Then $Rotation=0 EndIf $Rotation += 5; __Rotate($Rotation) ConsoleWrite($Rotation & @CRLF) WEnd Func __Rotate($i) _CreateGraphic() _GDIPlus_GraphicsClear($g_hGfx_needle, 0xFF000000) _GDIPlus_GraphicsDrawImageRectRect($g_hGfx_Background, $Background, 0, 0, $g_back[0], $g_back[1], 0, 0, $g_back[0], $g_back[1], $hAttribute_Alpha) $g_hGfx_Background = _GDIPlus_ImageGetGraphicsContext($g_hImage_Background) _GDIPlus_MatrixRotate($hMatrix, $i) _GDIPlus_GraphicsSetTransform($g_hGfx_Background, $hMatrix) _GDIPlus_GraphicsDrawImageRect($g_hGfx_Background, $Needle, -$g_Needle[0], -$g_Needle[1], $g_Needle[0], $g_Needle[1]) SetBitmap($g_hGUI, $g_hImage_Background, 255) GUISetState() EndFunc IF GUIGetMsg=$GUI_EVENT_CLOSE Then _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_ImageAttributesDispose($hAttribute_Alpha) _GDIPlus_ImageDispose($Needle) _GDIPlus_ImageDispose($g_hImage_Background) _GDIPlus_ImageDispose($Background) _GDIPlus_GraphicsDispose($g_hGfx_Background) _GDIPlus_Shutdown() EndIf Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap
  19. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <Word.au3> GUICreate("Test") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $gLangRadBtns = GUICtrlCreateGroup("Language", 30, 10, 100, 70) Local $idChckLngNL = GUICtrlCreateRadio("Nederlands", 35, 25, 90, 25) Local $idChckLngFR = GUICtrlCreateRadio("Francais", 35, 45, 90, 25) Local $gLangRadBtns = GUICtrlCreateGroup("DB", 155, 10, 100, 70) Local $idChckLive = GUICtrlCreateRadio("Live DB", 160, 25, 90, 25) Local $idChckQry = GUICtrlCreateRadio("Query DB", 160, 45, 90, 25) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ;~ If (GuiCtrlRead($idChckLngNL, $GUI_CHECKED)) = 1 Then ;~ GUICtrlSetState($idChckLngFR, $GUI_CHECKED) ;~ GUICtrlSetState($idChckLngNL, $GUI_UNCHECKED) ;~ ElseIf (GuiCtrlRead($idChckLngNL)) = 0 Then ;~ GUICtrlSetState($idChckLngFR, $GUI_UNCHECKED) ;~ GUICtrlSetState($idChckLngNL, $GUI_CHECKED) ;~ Else ;~ GUICtrlSetState($idChckLngNL, $GUI_UNCHECKED) ;~ EndIf WEnd Anything wrong with using radio buttons and groups? Alternatively, with checkboxes (I find radio buttons/groups easier): #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <Word.au3> GUICreate("Test") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $gLangRadBtns = GUICtrlCreateGroup("Language", 30, 10, 100, 70) Local $idChckLngNL = GUICtrlCreateCheckbox("Nederlands", 35, 25, 90, 25) Local $idChckLngFR = GUICtrlCreateCheckbox("Francais", 35, 45, 90, 25) Local $gLangRadBtns = GUICtrlCreateGroup("DB", 155, 10, 100, 70) Local $idChckLive = GUICtrlCreateRadio("Live DB", 160, 25, 90, 25) Local $idChckQry = GUICtrlCreateRadio("Query DB", 160, 45, 90, 25) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idChckLngNL ;Received change state message from NL Checkbox If GUICtrlRead($idChckLngNL) = $GUI_CHECKED Then ;If check message GUICtrlSetState($idChckLngNL, $GUI_CHECKED) ;Check NL box GUICtrlSetState($idChckLngFR, $GUI_UNCHECKED) ;AND Uncheck FR box Else ;Any other message received from NL box (e.g. Uncheck) GUICtrlSetState($idChckLngNL, $GUI_UNCHECKED) ;Uncheck the NL box, no need to change FR box state EndIf Case $idChckLngFR If GUICtrlRead($idChckLngFR) = $GUI_CHECKED Then ; N.B. The BitAND isn't really necessary for this program so far. GUICtrlSetState($idChckLngFR, $GUI_CHECKED) GUICtrlSetState($idChckLngNL, $GUI_UNCHECKED) Else GUICtrlSetState($idChckLngFR, $GUI_UNCHECKED) EndIf EndSwitch WEnd
  20. Not entirely sure what you're looking to achieve here, but if it's just to present a coloured string then check out the _GDIPlus_GraphicsDrawStringEx function.
  21. A switch statement maybe? While 1 local $ReturnValue = Expression() Switch $ReturnValue Case 1 Statement1() Case 2 Statement2() Case 3 Statement3(); Case Else Exit EndSwitch WEnd
  22. Try this: Run(@ComSpec & " /c " & '"C:\Program Files\Rainmeter\Rainmeter.exe" !DeactivateConfig "' & $fileFolder &'" "'& $fileINI &'"') Not sure how the spaces in "Minimalist Weather Standalone" will affect it though, try renaming the folder/ini file with no white spaces.
  23. You could try some basic debugging, both DirCopy and RunWait return values (So does DirRemove for that matter), these might give you some indication as to where it's failing: Func InstallOffice2016() Local $copyResult = False Local $runResult = False $copyResult = DirCopy ( "\\server\share\folder\folder", "C:\temp_file\office2016", 1) If Not $copyResult Then ConsoleWrite("Error copying file") EndIf $runResult = RunWait ( "C:\temp_file\office2016\setupapp.exe" ) ConsoleWrite("The result of running installer: " & $runResult) DirRemove ( "c:\temp_file\office2016", 1 ) EndFunc
  24. You're not doing anything with the $go variable, try this (and please use a code block in future posts): HotKeySet ( "{DOWN}","_start" ) HotKeySet ( "{UP}","_pause" ) HotKeySet ( "{END}","_exit" ) Global $go = 0 While(1) If($go) Then MouseClick("left",912,271,1,1) Sleep(100) MouseClick("left",912,718,1,1) $go=0 Else Sleep(1) EndIf WEnd Func _start() $go = 1 EndFunc Func _pause() $go = 0 EndFunc Func _exit() Exit EndFunc
  25. There's several ways to do this, you could compile the script to an executable and run that, you could add the AutoIt3.exe to the PATH variables so that the command line can run it from anywhere. If you want to just run a file without these two, this works: string pathToAutoIt; string pathToScript; pathToAutoIt = @"C:\Program Files (x86)\AutoIt3\AutoIt3.exe"; pathToScript = @"\path\to\script.au3"; Process externalProcess = new Process(); externalProcess.StartInfo.FileName = pathToAutoIt; externalProcess.StartInfo.Arguments = pathToScript; externalProcess.Start(); externalProcess.WaitForExit(); externalProcess.Dispose();
×
×
  • Create New...