Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/06/2012 in all areas

  1. AdmiralAlkex

    SDL UDF

    Ladies, gentlemens, nerds or whatever you are, I present to you, my SDL UDF! Q. So what is this then? A. It is a "wrapper" for the SDL.dll and some "help libraries" to make it easier to use in AutoIt. Q. WTF is SDL? A. As their webpage says: "Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer." Q. Can it really do all that? A. No. I have implemented many functions, but not all. I will update it on my own discretion. Q. So what does WORK? A. See the table below. Q. So how do I use it? A1. Read README.TXT in the archive. A2. There is a few examples in the download, study them. A3. Find any example or documentation for another language and translate it (shouldn't be to hard). Q. So where's the download? A. Next post.
    1 point
  2. To turn control theming back on DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hWnd, "ptr", 0, "ptr", 0)
    1 point
  3. UEZ

    Custom Slider Help

    Indeed I mixed up the topics. Nice examples rover! I searched for Yashied's code but didn't find it and decided to hack something with built-in graphic creator using GDI+. ;coded by UEZ build 2013-09-03 beta #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UPX_Parameters=--best --lzma #include <SliderConstants.au3> ;~ #include <WindowsConstants.au3>;~~~ #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Opt("MouseCoordMode", 0) Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() Global $hGUI = GUICreate("New Slider beta by UEZ 2012-2013", 580, 280) Global $iW = 300, $iH = 16 Global $aSlider1 = GUICtrlCreateHSlider(100, 50, $iW, $iH, 0xFF4080F0) Global $idLabel = GUICtrlCreateLabel("Volume", 10, 46, 70, 30) GUICtrlSetFont(-1, 16) Global $idInput1 = GUICtrlCreateInput($aSlider1[7], 420, 46, 42, 24, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlSetFont(-1, 12) Global $iSliderPos = 50 Global $aSlider2 = GUICtrlCreateHSlider(120, 100, $iW + 30, 30, 0xFF205020, @ScriptDir & "\button_smiley.png", "", $iSliderPos) Global $idInput2 = GUICtrlCreateInput($aSlider2[7], 10, 100, 42, 24) GUICtrlSetFont(-1, 12) Global $iSlider = GUICtrlCreateSlider(6, 150, $iW + 156, 45, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_NOTHUMB, $TBS_NOTHUMB)) GUICtrlSetLimit(-1, 200, 0) GUICtrlSetState(-1, $GUI_DISABLE) Global $idButton = GUICtrlCreateButton("OK", 56, 99, 40, 26) Global $aSlider3 = GUICtrlCreateHSlider(20, 180, $iW + 130, 50, 0, @ScriptDir & "\star.png", @ScriptDir & "\Texture.jpg", $iSliderPos) Global $aSlider4 = GUICtrlCreateVSlider(520, 20, 24, 240, 0xFF505050) ;~ Global $aSlider4 = GUICtrlCreateVSlider(520, 20, 24, 240, 0, "", @ScriptDir & "\TextureRotated.jpg") GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlSetOnEvent($aSlider1[0], "CheckSliderMove") GUICtrlSetOnEvent($aSlider2[0], "CheckSliderMove") GUICtrlSetOnEvent($aSlider3[0], "CheckSliderMove") GUICtrlSetOnEvent($aSlider4[0], "CheckSliderMove") GUICtrlSetOnEvent($idButton, "UpdateSlider") Do Until Not Sleep(3000) Func UpdateSlider() SetSliderPosHMan($aSlider2, GUICtrlRead($idInput2)) EndFunc ;==>UpdateSlider Func _Exit() _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit Func CheckSliderMove() Local $aRes = GUIGetCursorInfo($hGUI), $aPosW, $aPosH Switch $aRes[4] Case $aSlider1[0] While $aRes[2] * Sleep(20) $aRes = GUIGetCursorInfo($hGUI) SetSliderPosH($aSlider1, $aRes[0]) GUICtrlSetData($idInput1, $aSlider1[7]) $aPosW = WinGetPos($hGUI) ToolTip("Value: " & $aSlider1[7], $aPosW[0] + $aRes[0], $aPosW[1] + $aRes[1] + 50) WEnd ToolTip("") Case $aSlider2[0] While $aRes[2] * Sleep(20) $aRes = GUIGetCursorInfo($hGUI) SetSliderPosH($aSlider2, $aRes[0]) GUICtrlSetData($idInput2, $aSlider2[7]) WEnd Case $aSlider3[0] While $aRes[2] * Sleep(20) $aRes = GUIGetCursorInfo($hGUI) SetSliderPosH($aSlider3, $aRes[0]) $aPosW = WinGetPos($hGUI) ToolTip("Value: " & $aSlider3[7], $aPosW[0] + $aRes[0], $aPosW[1] + $aRes[1] + 50) WEnd ToolTip("") Case $aSlider4[0] While $aRes[2] * Sleep(20) $aRes = GUIGetCursorInfo($hGUI) SetSliderPosV($aSlider4, $aRes[1]) $aPosH = WinGetPos($hGUI) ToolTip("Value: " & $aSlider4[7], $aPosH[0] + $aRes[0], $aPosH[1] + $aRes[1] + 50) WEnd ToolTip("") EndSwitch EndFunc ;==>CheckSliderMove Func SetSliderPosHMan(ByRef $aSlider, $iPos) Local $aPos, $aPosW $iNewPos = 1 + Int($aSlider[1] + $iPos * $aSlider[5] + $aSlider[3]) GUICtrlSetPos($aSlider[0], Max($aSlider[1], Min($iNewPos - $aSlider[3], $aSlider[4])), $aSlider[2]) $aPos = ControlGetPos($hGUI, "", $aSlider[0]) $aPosW = WinGetPos($hGUI) $aSlider[7] = $iPos ;Int(($aPos[0] + $aSlider[3] - $aSlider[6]) / $aSlider[5]) EndFunc ;==>SetSliderPosHMan Func SetSliderPosH(ByRef $aSlider, $iPos) Local $aPos, $aPosW GUICtrlSetPos($aSlider[0], Max($aSlider[1], Min($iPos - $aSlider[3], $aSlider[4])), $aSlider[2]) $aPos = ControlGetPos($hGUI, "", $aSlider[0]) $aPosW = WinGetPos($hGUI) $aSlider[7] = Int(($aPos[0] + $aSlider[3] - $aSlider[6]) / $aSlider[5]) EndFunc ;==>SetSliderPosH Func SetSliderPosV(ByRef $aSlider, $iPos) Local $aPos, $aPosH GUICtrlSetPos($aSlider[0], $aSlider[2], Max($aSlider[1], Min($iPos - $aSlider[3], $aSlider[4]))) $aPos = ControlGetPos($hGUI, "", $aSlider[0]) $aPosH = WinGetPos($hGUI) $aSlider[7] = Int(($aPos[1] + $aSlider[3] - $aSlider[6]) / $aSlider[5]) EndFunc ;==>SetSliderPosV Func GUICtrlCreateHSlider($iX, $iY, $iW, $iH, $iColor, $sFileThumb = "", $sFileBg = "", $iValThumb = 0, $iColorThumb = 0xD0A00000, $iColorThumb_Center = 0xFFFFA0A0, $iValMin = 0, $iValMax = 100, $fSize = 0.025, $fScale = 1.5) Local $hHBitmap_Thumb, $hHBitmap_Bg Local $idPic_Bg = GUICtrlCreatePic("", $iX, $iY, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) If $sFileBg <> "" And FileExists($sFileBg) Then $hHBitmap_Bg = _GDIPlus_CreateHBitmapFromFile($sFileBg, $iW, $iH) Else $hHBitmap_Bg = _GDIPlus_CreateRoundRectImage($iW, $iH, $iColor, $fSize) EndIf _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Bg, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_Bg)) _WinAPI_DeleteObject($hHBitmap_Bg) Local $iH_Thumb = $iH * $fScale Local $fRatio = $iW / Abs($iValMax - $iValMin) Local $idPic_Thumb = GUICtrlCreatePic("", $iX - $iH_Thumb / 2 + $iValThumb * $fRatio, $iY - ($iH_Thumb - $iH) / 2, $iH_Thumb, $iH_Thumb) If $sFileThumb <> "" And FileExists($sFileThumb) Then $hHBitmap_Thumb = _GDIPlus_CreateHBitmapFromFile($sFileThumb, $iH_Thumb, $iH_Thumb) Else $hHBitmap_Thumb = _GDIPlus_CreateEllipseThumb($iH_Thumb, $iColorThumb, $iColorThumb_Center) EndIf _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Thumb, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_Thumb)) _WinAPI_DeleteObject($hHBitmap_Thumb) Local $aSlider[8] = [ $idPic_Thumb, _ ;0 control id $iX - $iH_Thumb / 2, _ ;1 min x position thumb $iY - ($iH_Thumb - $iH) / 2, _ ;2 center position thumb height $iH_Thumb / 2, _ ;3 center thumb height $iX + $iW - $iH_Thumb / 2, _ ;4 end x position $fRatio, _ ;5 ratio $iX, _ ;6 start x position $iValThumb] ;7 thumb size ratio Return $aSlider EndFunc ;==>GUICtrlCreateHSlider Func GUICtrlCreateVSlider($iX, $iY, $iW, $iH, $iColor, $sFileThumb = "", $sFileBg = "", $iValThumb = 0, $iColorThumb = 0xD0005000, $iColorThumb_Center = 0xFF80E080, $iValMin = 0, $iValMax = 100, $fSize = 0.025, $fScale = 1.5) Local $hHBitmap_Thumb, $hHBitmap_Bg Local $idPic_Bg = GUICtrlCreatePic("", $iX, $iY, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) If $sFileBg <> "" And FileExists($sFileBg) Then $hHBitmap_Bg = _GDIPlus_CreateHBitmapFromFile($sFileBg, $iW, $iH) Else $hHBitmap_Bg = _GDIPlus_CreateRoundRectImage($iH, $iW, $iColor, $fSize, True, True) EndIf _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Bg, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_Bg)) _WinAPI_DeleteObject($hHBitmap_Bg) Local $iW_Thumb = $iW * $fScale Local $fRatio = $iH / Abs($iValMax - $iValMin) Local $idPic_Thumb = GUICtrlCreatePic("", $iX + ($iW - $iW_Thumb) / 2 + $iValThumb * $fRatio, $iY - ($iW_Thumb - $iH) / 2, $iW_Thumb, $iW_Thumb) If $sFileThumb <> "" And FileExists($sFileThumb) Then $hHBitmap_Thumb = _GDIPlus_CreateHBitmapFromFile($sFileThumb, $iW_Thumb, $iW_Thumb) Else $hHBitmap_Thumb = _GDIPlus_CreateEllipseThumb($iW_Thumb, $iColorThumb, $iColorThumb_Center) EndIf _WinAPI_DeleteObject(GUICtrlSendMsg($idPic_Thumb, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_Thumb)) _WinAPI_DeleteObject($hHBitmap_Thumb) Local $aSlider[8] = [ $idPic_Thumb, _ ;0 control id $iY - $iW_Thumb / 2, _ ;1 min y position thumb $iX - ($iW_Thumb - $iW) / 2, _ ;2 center position thumb width $iW_Thumb / 2, _ ;3 center thumb height $iY + $iH - $iW_Thumb / 2, _ ;4 end Y position $fRatio, _ ;5 ratio $iY, _ ;6 start Y position $iValThumb] ;7 thumb size ratio Return $aSlider EndFunc ;==>GUICtrlCreateVSlider Func _GDIPlus_CreateRoundRectImage($iW, $iH, $iColor = 0xFF4080F0, $fSize = 0.025, $hHBitmap = True, $iRotate = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", 0, "int*", 0) Local $hPath_Bg = $aResult[2] $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", 0, "int*", 0) Local $hPath_Fg = $aResult[2] $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) Local $hBitmap = $aResult[6] Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) Local $iColor_Bg = 0xFF000000 + 0x10000 * Max(BitShift(BitAND($iColor, 0x00FF0000) / 3, 16), 0x10) + 0x100 * Max(BitShift(BitAND($iColor, 0x0000FF00) / 3, 8), 0x10) + Max(BitAND($iColor, 0x000000FF / 3), 0x10) Local $hBrush = _GDIPlus_BrushCreateSolid($iColor_Bg) Local $dW = Int($iW * $fSize) DllCall($ghGDIPDll, "int", "GdipAddPathArc", "handle", $hPath_Bg, "float", 0, "float", 0, "float", $dW, "float", $iH, "float", 90, "float", 180) ;left arc DllCall($ghGDIPDll, "int", "GdipAddPathArc", "handle", $hPath_Bg, "float", $iW - $dW - 1, "float", 0, "float", $dW, "float", $iH, "float", -90, "float", 180) ;right arc DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "handle", $hPath_Bg) DllCall($ghGDIPDll, "int", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush, "handle", $hPath_Bg) $iH *= 0.89 Local $iColor2 = 0xFF000000 + 0x10000 * Min(BitShift(BitAND($iColor, 0x00FF0000), 16) * 3, 0xFF) + 0x100 * Min(BitShift(BitAND($iColor, 0x0000FF00), 8) * 3, 0xFF) + Min(BitAND($iColor, 0x000000FF) * 3, 0xFF) Local $tRectF = _GDIPlus_RectFCreate(0, 0, $iW, $iH) $aResult = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", DllStructGetPtr($tRectF), "int", $iColor2, "int", $iColor, "int", 1, "int", 0, "int*", 0) Local $hBrush_Gradient = $aResult[6] DllCall($ghGDIPDll, "int", "GdipAddPathArc", "handle", $hPath_Fg, "float", 1, "float", 0, "float", $dW * 0.8, "float", $iH, "float", 90, "float", 180) DllCall($ghGDIPDll, "int", "GdipAddPathArc", "handle", $hPath_Fg, "float", $iW - $dW - $dW / 5, "float", 0, "float", $dW * 0.8, "float", $iH, "float", -90, "float", 180) DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "handle", $hPath_Fg) $aResult = DllCall($ghGDIPDll, "int", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush_Gradient, "handle", $hPath_Fg) DllCall($ghGDIPDll, "int", "GdipDeletePath", "handle", $hPath_Bg) DllCall($ghGDIPDll, "int", "GdipDeletePath", "handle", $hPath_Fg) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush_Gradient) Switch $iRotate Case 1 DllCall($ghGDIPDll, "uint", "GdipImageRotateFlip", "handle", $hBitmap, "int", 1) Case 2 DllCall($ghGDIPDll, "uint", "GdipImageRotateFlip", "handle", $hBitmap, "int", 3) EndSwitch If $hHBitmap Then Local $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>_GDIPlus_CreateRoundRectImage Func _GDIPlus_CreateEllipseThumb($iSize, $iColor = 0xD0A00000, $iColor_Center = 0xFFFFA0A0, $hHBitmap = True, $sFile = "") Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", 0, "int*", 0) Local $hPath = $aResult[2] DllCall($ghGDIPDll, "int", "GdipAddPathEllipse", "handle", $hPath, "float", 0, "float", 0, "float", $iSize, "float", $iSize) $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePathGradientFromPath", "handle", $hPath, "int*", 0) Local $hBrush_Gradient = $aResult[2] Local $fCenter = $iSize / 2 Local $tPointF = DllStructCreate("float;float") DllStructSetData($tPointF, 1, $fCenter * 0.6) DllStructSetData($tPointF, 2, $fCenter * 0.4) $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterPoint", "handle", $hBrush_Gradient, "ptr", DllStructGetPtr($tPointF)) $tARGB = DllStructCreate("int") DllStructSetData($tARGB, 1, $iColor, 1) DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "handle", $hBrush_Gradient, "int", DllStructGetPtr($tARGB), "int*", 1) DllCall($ghGDIPDll, "int", "GdipSetLineGammaCorrection", "handle", $hBrush_Gradient, "int", True) DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterColor", "handle", $hBrush_Gradient, "int", $iColor_Center) $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromScan0", "int", $iSize, "int", $iSize, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) Local $hBitmap = $aResult[6] Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) DllCall($ghGDIPDll, "int", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush_Gradient, "handle", $hPath) DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "handle", $hPath) DllCall($ghGDIPDll, "int", "GdipDeletePath", "handle", $hPath) Local $hPen = _GDIPlus_PenCreate(0xD0080808) _GDIPlus_GraphicsDrawEllipse($hCtxt, 0, 0, $iSize - 1, $iSize - 1, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BrushDispose($hBrush_Gradient) If $hHBitmap Then Local $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>_GDIPlus_CreateEllipseThumb Func _GDIPlus_CreateHBitmapFromFile($sFile, $iW, $iH) Local $hBmp = _GDIPlus_BitmapCreateFromFile($sFile) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) Local $hBitmap = $aResult[6] Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) DllCall($ghGDIPDll, "int", "GdipSetInterpolationMode", "handle", $hCtxt, "int", 7) _GDIPlus_GraphicsDrawImageRect($hCtxt, $hBmp, 0, 0, $iW, $iH) _GDIPlus_BitmapDispose($hBmp) _GDIPlus_GraphicsDispose($hCtxt) Local $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndFunc ;==>_GDIPlus_CreateHBitmapFromFile Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported) Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0 $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0) If (@error) Or ($aRet[0]) Then Return 0 $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) $pBits = DllStructGetData($tData, 'Scan0') If Not $pBits Then Return 0 $tBIHDR = DllStructCreate('dword bV5Size;long bV5Width;long bV5Height;ushort bV5Planes;ushort bV5BitCount;dword bV5Compression;dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved;') DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 'bV5Width', $aRet[2]) DllStructSetData($tBIHDR, 'bV5Height', $aRet[3]) DllStructSetData($tBIHDR, 'bV5Planes', 1) DllStructSetData($tBIHDR, 'bV5BitCount', 32) DllStructSetData($tBIHDR, 'bV5Compression', 3) ; $BI_BITFIELDS = 3 DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride')) DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000) DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000) DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00) DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF) DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2 DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA $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', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0')) $hResult = $hResult[0] Else $hResult = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Return $hResult EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap Func Min($a, $b) If $a < $b Then Return $a Return $b EndFunc ;==>Min Func Max($a, $b) If $a > $b Then Return $a Return $b EndFunc ;==>Max It is beta and probably buggy! All needed files in the attachment -> New Slider.7z (73 download previously) Br, UEZ
    1 point
  4. rover

    Custom Slider Help

    Trackbars (Slider) can be custom skinned by Customdrawing or Ownerdrawing. I've used a skinning dll in the past to theme a slider in a script, otherwise I haven't the need to bother working out the details of customdrawing a slider. Yashied posted an example of painting the background image behind a slider that used customdrawing. At the time, I did a few tests theming the slider, then left it. Here is the updated code modified from Yashied's post with hard coded metrics, no image alpha transparency support and without image state code (hot/focused/disabled). Version with background image has high cpu usage when trackbar moved (NM_CUSTOMDRAW message) and some optimization is needed. Alternately use a layered gui for transparency. Or use UEZ's custom trackbar posted in your other thread just as I was logging in to post this. Solid colour Background ;coded by rover 2k12 - modified from customdrawn slider background code by Yashied #include <Constants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global Const $tagNMCUSTOMDRAW = $tagNMHDR & ';dword DrawStage;handle hDC;long Rect[4];dword_ptr ItemSpec;uint ItemState;lparam ItemlParam' Global Const $STM_GETIMAGE = 0x0173 Global $iBuffer, $hBitmap1, $hBitmap2, $bmWidth1, $bmHeight1, $bmWidth2, $bmHeight2, $cSldr1, $cSldr2, $hSlider1, $hSlider2 _Main() Func _Main() Local $iLoad = BitOR($LR_LOADFROMFILE, $LR_CREATEDIBSECTION, $LR_LOADTRANSPARENT), $Msg $hBitmap1 = _WinAPI_LoadImage(0, @ScriptDir & '\B.bmp', $IMAGE_BITMAP, 0, 0, $iLoad); LoadImage API only works with BMP files or BMP resources $hBitmap2 = _WinAPI_LoadImage(0, @ScriptDir & '\A.bmp', $IMAGE_BITMAP, 0, 0, $iLoad) _GetBitmapSize($hBitmap1, $bmWidth1, $bmHeight1) _GetBitmapSize($hBitmap2, $bmWidth2, $bmHeight2) GUICreate('Custom Skin Slider', 300, 150) GUISetBkColor(0x494949) $cSldr1 = GUICtrlCreateDummy() $cSldr2 = GUICtrlCreateDummy() Local $cEdit1 = GUICtrlCreateInput("0", 10, 26, 42, 24, BitOR($ES_CENTER, $ES_READONLY)) ;does not have the flicker of a rapidly updated GUICtrlCreateLabel() (Static control) GUICtrlSetFont(-1, 12, 800, 1, "Arial") GUICtrlSetColor(-1, 0x00EEEE) GUICtrlSetBkColor(-1, 0x494949) Local $cEdit2 = GUICtrlCreateInput("0", 10, $bmHeight1 + 42, 42, 24, BitOR($ES_CENTER, $ES_READONLY));does not have the flicker of a rapidly updated GUICtrlCreateLabel() (Static control) GUICtrlSetFont(-1, 12, 800, 1, "Arial") GUICtrlSetColor(-1, 0xFFFF00) GUICtrlSetBkColor(-1, 0x363636) GUICtrlCreateSlider(60, 20, $bmWidth2 + $bmHeight1, $bmHeight1 + 6, BitOR($TBS_NOTICKS, $TBS_FIXEDLENGTH, $WS_TABSTOP)) $hSlider1 = GUICtrlGetHandle(-1) GUICtrlSetCursor(-1, 0) _SendMessage($hSlider1, $TBM_SETTHUMBLENGTH, ($bmWidth1 * 2) - 1, 0) ;-1 pixel to compensate for thumb not covering channel at right end of trackbar GUICtrlSetBkColor(-1, 0x494949) GUICtrlCreateSlider(60, $bmHeight1 + 36, $bmWidth2 + $bmHeight1, $bmHeight1 + 6, BitOR($TBS_NOTICKS, $TBS_FIXEDLENGTH, $WS_TABSTOP)) $hSlider2 = GUICtrlGetHandle(-1) GUICtrlSetCursor(-1, 0) _SendMessage($hSlider2, $TBM_SETTHUMBLENGTH, ($bmWidth1 * 2) - 1, 0) ;-1 pixel to compensate for thumb not covering channel at right end of trackbar GUICtrlSetBkColor(-1, 0x494949) GUIRegisterMsg($WM_HSCROLL, "_WM_HVSCROLL") ;GUIRegisterMsg($WM_VSCROLL, "_WM_HVSCROLL") GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) Exit Case $cSldr1 GUICtrlSetData($cEdit1, GUICtrlRead($cSldr1)) Case $cSldr2 GUICtrlSetData($cEdit2, GUICtrlRead($cSldr2)) EndSwitch WEnd EndFunc Func _WM_HVSCROLL($hWnd, $Msg, $wParam, $lParam) Switch $lParam Case $hSlider1, $hSlider2 Local $iCtrlID = _WinAPI_GetDlgCtrlID($lParam) Local $iPos = GUICtrlRead($iCtrlID) If $iBuffer <> $iPos Then ; buffer read slider value to prevent unnecessary updating at start/end of slider range. $iBuffer = $iPos ;ConsoleWrite(' Slider = ' & $iPos & @CRLF) Switch $lParam Case $hSlider1 GUICtrlSendToDummy($cSldr1, $iPos) Case $hSlider2 GUICtrlSendToDummy($cSldr2, $iPos) EndSwitch EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_HVSCROLL Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom') Local $Code = DllStructGetData($tNMHDR, 'Code') Local $IDFrom = DllStructGetData($tNMHDR, 'IDFrom') Switch $hWndFrom Case $hSlider1, $hSlider2 Switch $Code Case $NM_CUSTOMDRAW Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage') Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec') Local $hDC, $hMemDC, $hPrev Switch $DrawStage Case $CDDS_PREPAINT DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS)) ; Remove focus Rectangle Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT Local $nLeft = DllStructGetData($tNMCD, 'Rect', 1) Local $nTop = DllStructGetData($tNMCD, 'Rect', 2) Local $nRight = DllStructGetData($tNMCD, 'Rect', 3) Local $nBottom = DllStructGetData($tNMCD, 'Rect', 4) Local $nWidth = $nRight - $nLeft Local $nHeight = $nBottom - $nTop $hDC = DllStructGetData($tNMCD, 'hDC') Switch $ItemSpec Case $TBCD_TICS Return $CDRF_SKIPDEFAULT ; draw custom ticks from bitmap or remove tics ;Return $CDRF_DODEFAULT ; draw tics from current theme Case $TBCD_CHANNEL $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap2) _WinAPI_BitBlt($hDC, $nLeft, $nTop - 16, $nWidth, $bmHeight2, $hMemDC, 0, 0, $MERGECOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw channel with bitmap or remove channel ;Return $CDRF_DODEFAULT ;draw channel from current theme Case $TBCD_THUMB If ($nWidth - $bmWidth1) > 0 Then $nLeft += (($nWidth - $bmWidth1) / 2) $nWidth = $bmWidth1 EndIf If ($nHeight - $bmHeight1) > 0 Then $nTop += ($nHeight - $bmHeight1) / 2 $nHeight = $bmHeight1 EndIf $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap1) _WinAPI_BitBlt($hDC, $nLeft, $nTop - 10, $nWidth, $nHeight, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw thumb with bitmap ;Return $CDRF_DODEFAULT ;draw thumb from current theme EndSwitch EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _GetBitmapSize($hBitmap, ByRef $X, ByRef $Y) Local $iRet = _WinAPI_GetObject($hBitmap, 0, 0) Local $tBitmap = DllStructCreate("int bmType;int bmWidth;int bmHeight;" & _ "int bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;long_ptr bmBits") If DllStructGetSize($tBitmap) <> $iRet Then Return SetError(1, 0, -1) $iRet = _WinAPI_GetObject($hBitmap, $iRet, DllStructGetPtr($tBitmap)) $X = DllStructGetData($tBitmap, "bmWidth") $Y = DllStructGetData($tBitmap, "bmHeight") EndFunc ;==>_GetBitmapSize Image Background (High cpu when trackbar moved) ;coded by rover 2k12 - modified from customdrawn slider background code by Yashied #include <Constants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global Const $tagNMCUSTOMDRAW = $tagNMHDR & ';dword DrawStage;handle hDC;long Rect[4];dword_ptr ItemSpec;uint ItemState;lparam ItemlParam' Global Const $STM_GETIMAGE = 0x0173 Global $hTemp = 0, $hPic, $iBuffer, $hBitmap1, $hBitmap2, $bmWidth1, $bmHeight1, $bmWidth2, $bmHeight2, $cSldr1, $cSldr2, $hSlider1, $hSlider2 _Main() Func _Main() Local $iLoad = BitOR($LR_LOADFROMFILE, $LR_CREATEDIBSECTION, $LR_LOADTRANSPARENT), $Msg $hBitmap1 = _WinAPI_LoadImage(0, @ScriptDir & '\B.bmp', $IMAGE_BITMAP, 0, 0, $iLoad); LoadImage API only works with BMP files or BMP resources $hBitmap2 = _WinAPI_LoadImage(0, @ScriptDir & '\A.bmp', $IMAGE_BITMAP, 0, 0, $iLoad) _GetBitmapSize($hBitmap1, $bmWidth1, $bmHeight1) _GetBitmapSize($hBitmap2, $bmWidth2, $bmHeight2) GUICreate('Custom Skin Slider', 300, 150) GUISetBkColor(0x494949) Local $Wow64 = "", $Msg If @AutoItX64 Then $Wow64 = "\Wow6432Node" Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\msoobe.jpg" GUICtrlCreatePic($sPath, 0, 0, 413, 161) GUICtrlSetState(-1, $GUI_DISABLE) $hPic = GUICtrlGetHandle(-1) $cSldr1 = GUICtrlCreateDummy() $cSldr2 = GUICtrlCreateDummy() Local $cEdit1 = GUICtrlCreateInput("0", 10, 26, 42, 24, BitOR($ES_CENTER, $ES_READONLY)) ;does not have the flicker of a rapidly updated GUICtrlCreateLabel() (Static control) GUICtrlSetFont(-1, 12, 800, 1, "Arial") GUICtrlSetColor(-1, 0x00EEEE) GUICtrlSetBkColor(-1, 0x494949) Local $cEdit2 = GUICtrlCreateInput("0", 10, $bmHeight1 + 42, 42, 24, BitOR($ES_CENTER, $ES_READONLY));does not have the flicker of a rapidly updated GUICtrlCreateLabel() (Static control) GUICtrlSetFont(-1, 12, 800, 1, "Arial") GUICtrlSetColor(-1, 0xFFFF00) GUICtrlSetBkColor(-1, 0x363636) GUICtrlCreateSlider(60, 20, $bmWidth2 + $bmHeight1, $bmHeight1 + 6, BitOR($TBS_NOTICKS, $TBS_FIXEDLENGTH, $WS_TABSTOP)) $hSlider1 = GUICtrlGetHandle(-1) GUICtrlSetCursor(-1, 0) _SendMessage($hSlider1, $TBM_SETTHUMBLENGTH, ($bmWidth1 * 2) - 1, 0) ;-1 pixel to compensate for thumb not covering channel at right end of trackbar GUICtrlSetBkColor(-1, 0x494949) GUICtrlCreateSlider(60, $bmHeight1 + 36, $bmWidth2 + $bmHeight1, $bmHeight1 + 6, BitOR($TBS_NOTICKS, $TBS_FIXEDLENGTH, $WS_TABSTOP)) $hSlider2 = GUICtrlGetHandle(-1) GUICtrlSetCursor(-1, 0) _SendMessage($hSlider2, $TBM_SETTHUMBLENGTH, ($bmWidth1 * 2) - 1, 0) ;-1 pixel to compensate for thumb not covering channel at right end of trackbar GUICtrlSetBkColor(-1, 0x494949) GUIRegisterMsg($WM_HSCROLL, "_WM_HVSCROLL") ;GUIRegisterMsg($WM_VSCROLL, "_WM_HVSCROLL") GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) Exit Case $cSldr1 GUICtrlSetData($cEdit1, GUICtrlRead($cSldr1)) Case $cSldr2 GUICtrlSetData($cEdit2, GUICtrlRead($cSldr2)) EndSwitch WEnd EndFunc Func _WM_HVSCROLL($hWnd, $Msg, $wParam, $lParam) Switch $lParam Case $hSlider1, $hSlider2 Local $iCtrlID = _WinAPI_GetDlgCtrlID($lParam) Local $iPos = GUICtrlRead($iCtrlID) If $iBuffer <> $iPos Then ; buffer read slider value to prevent unnecessary updating at start/end of slider range. $iBuffer = $iPos ;ConsoleWrite(' Slider = ' & $iPos & @CRLF) Switch $lParam Case $hSlider1 GUICtrlSendToDummy($cSldr1, $iPos) Case $hSlider2 GUICtrlSendToDummy($cSldr2, $iPos) EndSwitch EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_HVSCROLL Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom') Local $Code = DllStructGetData($tNMHDR, 'Code') Local $IDFrom = DllStructGetData($tNMHDR, 'IDFrom') Switch $hWndFrom Case $hSlider1, $hSlider2 Switch $Code Case $NM_CUSTOMDRAW Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage') Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec') Local $hDC = DllStructGetData($tNMCD, 'hDC') Local $hMemDC, $hBitmap, $hPrev, $aPos Switch $DrawStage Case $CDDS_PREPAINT, $CDDS_POSTPAINT $aPos = ControlGetPos($hWndFrom, '', '') Switch $DrawStage Case $CDDS_PREPAINT $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0], $aPos[1], $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS)) ; Remove focus Rectangle Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT) Case $CDDS_POSTPAINT $hMemDC = _WinAPI_CreateCompatibleDC($hDC) If Not $hTemp Then $hTemp = _WinAPI_CreateCompatibleBitmap($hDC, $aPos[2], $aPos[3]) $hPrev = _WinAPI_SelectObject($hMemDC, $hTemp) _WinAPI_BitBlt($hMemDC, 0, 0, $aPos[2], $aPos[3], $hDC, 0, 0, $MERGECOPY) Else $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hTemp) _WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $hMemDC, 0, 0, $SRCCOPY) EndIf _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_DODEFAULT EndSwitch Case $CDDS_ITEMPREPAINT If $hTemp Then _WinAPI_DeleteObject($hTemp) $hTemp = 0 EndIf Local $nLeft = DllStructGetData($tNMCD, 'Rect', 1) Local $nTop = DllStructGetData($tNMCD, 'Rect', 2) Local $nRight = DllStructGetData($tNMCD, 'Rect', 3) Local $nBottom = DllStructGetData($tNMCD, 'Rect', 4) Local $nWidth = $nRight - $nLeft Local $nHeight = $nBottom - $nTop Switch $ItemSpec Case $TBCD_TICS Return $CDRF_SKIPDEFAULT ; draw custom ticks from bitmap or remove tics ;Return $CDRF_DODEFAULT ; draw tics from current theme Case $TBCD_CHANNEL $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap2) _WinAPI_BitBlt($hDC, $nLeft, $nTop - 16, $nWidth, $bmHeight2, $hMemDC, 0, 0, $MERGECOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw channel with bitmap or remove channel ;Return $CDRF_DODEFAULT ;draw channel from current theme Case $TBCD_THUMB If ($nWidth - $bmWidth1) > 0 Then $nLeft += (($nWidth - $bmWidth1) / 2) $nWidth = $bmWidth1 EndIf If ($nHeight - $bmHeight1) > 0 Then $nTop += ($nHeight - $bmHeight1) / 2 $nHeight = $bmHeight1 EndIf $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap1) _WinAPI_BitBlt($hDC, $nLeft, $nTop - 10, $nWidth, $nHeight, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw thumb with bitmap ;Return $CDRF_DODEFAULT ;draw thumb from current theme EndSwitch EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _GetBitmapSize($hBitmap, ByRef $X, ByRef $Y) Local $iRet = _WinAPI_GetObject($hBitmap, 0, 0) Local $tBitmap = DllStructCreate("int bmType;int bmWidth;int bmHeight;" & _ "int bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;long_ptr bmBits") If DllStructGetSize($tBitmap) <> $iRet Then Return SetError(1, 0, -1) $iRet = _WinAPI_GetObject($hBitmap, $iRet, DllStructGetPtr($tBitmap)) $X = DllStructGetData($tBitmap, "bmWidth") $Y = DllStructGetData($tBitmap, "bmHeight") EndFunc ;==>_GetBitmapSize
    1 point
  5. UEZ

    Custom Slider

    Moved to Br, UEZ
    1 point
  6. here's my take on it. ; *** Start added by AutoIt3Wrapper *** #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; *** End added by AutoIt3Wrapper *** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #AutoIt3Wrapper_Add_Constants=n Global $msg, $mainMenu, $wButton, $mainMenu1, $Welcome, $Intro Intro1() mainMenu1() startHere1() intro1() mainMenu1() startHere1() Func intro1() $Intro = GUICreate("Welcome", 472, 309, 192, 124) $Label1 = GUICtrlCreateLabel("Welcome to the TruTops Programming Guide.", 45, 8, 400, 34, $SS_CENTER) GUICtrlSetFont(-1, 20, 800, 2, "AriaScriptSSK") $Label2 = GUICtrlCreateLabel("This guide was created to help the user in programming TruTops Mark.", 67, 56, 337, 17, $SS_CENTER) $Label3 = GUICtrlCreateLabel("We will go through all of the steps of each programming option in the TruTops Mark Program itself.", 3, 72, 465, 17, $SS_CENTER) $Label4 = GUICtrlCreateLabel("First, If you noticed, the door to the machine has already opened.", 80, 88, 310, 17, $SS_CENTER) $Label5 = GUICtrlCreateLabel("Before we begin, please clear off anything that may be in the way of the table movement.", 24, 104, 422, 17, $SS_CENTER) $Label6 = GUICtrlCreateLabel("Also, clear off the table with the acception of the A-Axis and the guide blocks that are in place.", 11, 120, 448, 17, $SS_CENTER) $Label7 = GUICtrlCreateLabel("Once that is done, Please proceed and click OK", 119, 136, 232, 17, $SS_CENTER) $Button1 = GUICtrlCreateButton("Continue", 104, 216, 75, 25) $Button2 = GUICtrlCreateButton("Exit", 296, 216, 75, 25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button2 Exit Case $msg = $Button1 GUISetState(@SW_HIDE, $Intro) mainMenu1() GUISetState(@SW_SHOW, $Intro) Case $msg = $Button1 EndSelect WEnd EndFunc ;==>intro1 Func mainMenu1() $mainMenu = GUICreate("Main Menu", 320, 282, 193, 125, -1, -1, $Welcome) $Label1 = GUICtrlCreateLabel("Please select a starting point below.", 73, 16, 173, 17) $Label2 = GUICtrlCreateLabel("Each button will open a more in depth set of options.", 34, 48, 251, 17) $startHere = GUICtrlCreateButton("Start Here", 122, 88, 75, 25) $axisCommands = GUICtrlCreateButton("Axis Commands", 114, 120, 91, 25) $markCommands = GUICtrlCreateButton("Mark Commands", 110, 152, 99, 25) $systemCommands = GUICtrlCreateButton("System Commands", 110, 184, 99, 25) $exit = GUICtrlCreateButton("Exit", 122, 216, 75, 25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $exit GUIDelete() Return Case $msg = $startHere GUISetState(@SW_HIDE,$mainMenu) startHere1() GUISetState(@SW_SHOW, $mainMenu) EndSelect WEnd EndFunc ;==>mainMenu1 Func startHere1() $pgStartHere = GUICreate("Start Here", 566, 525, 192, 124) $Edit1 = GUICtrlCreateEdit("", 32, 24, 489, 441, $ES_CENTER, $ES_READONLY) GUICtrlSetData(-1, StringFormat("This is Text"), $ES_READONLY) $_mainMenu = GUICtrlCreateButton("Main Menu", 120, 480, 75, 25) $exit = GUICtrlCreateButton("Exit", 360, 480, 75, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $exit Exit Case $msg = $_mainMenu GUIDelete() Return EndSelect WEnd EndFunc ;==>startHere1
    1 point
  7. If you want it to loop for the target program every time, and launch the new program if neither the target program or the new program doesn't exist, you can use the following: Global $sTargetProcess = "notepad.exe" Global $sNewProcess = "iexplore.exe" Global $sNewProgPath = @ProgramFilesDir & "Internet Exploreriexplore.exe" AdlibRegister("_Launcher", 100) ; Fire _Launcher() every 100 milliseconds While 1 Sleep(100) WEnd Func _Launcher() If Not ProcessExists($sTargetProcess) And Not ProcessExists($sNewProcess) Then Run($sNewProgPath) EndIf EndFunc
    1 point
  8. Sorry about all that.. Well, I'm glad you worked it out in the end ! And let's just pretend like I did all that on purpose so you'd learn it yourself, instead of me just being incompetent atm..
    1 point
×
×
  • Create New...