Sign in to follow this  
Followers 0
Klovis

Laggy Script

3 posts in this topic

Yeah so when I move the scroll the script seems choppy can someone fix this for me, I'm clueless.

Thanks for your time!

-Klovis

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>

Opt("MustDeclareVars", 1)

Global Const $AC_SRC_ALPHA = 1
Global $fVisible = True
Global $fVisible2 = True
Global $fVisible3 = True
Global $fVisible4 = True
Global $hGUI1, $hGUI2, $hGUI3, $hGUI4, $hGUI5, $iLabel1, $iLabel2, $iSlider, $hImage, $hImage2, $hImage3, $hImage4

$hGUI1 = GUICreate("Control", 144, 39, 192, 114, -1, $WS_EX_TOPMOST)
$iSlider = GUICtrlCreateSlider(0, 0, 70, 37)
GUICtrlSetLimit($iSlider, 100, 0)
GUICtrlSetData($iSlider, 0)
$iLabel2 = GUICtrlCreateLabel("Slider:", 72, 0, 33, 17)
$iLabel1 = GUICtrlCreateLabel("100%", 112, 16, 30, 17)
GUISetState(@SW_SHOW)

$hGUI2 = GUICreate("Gauge", 200, 171, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
GUISetState(@SW_HIDE)

$hGUI3 = GUICreate("First", 1280, 720, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
GUISetState(@SW_HIDE)

$hGUI4 = GUICreate("Second", 1280, 720, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
GUISetState(@SW_HIDE)

$hGUI5 = GUICreate("Third", 1280, 720, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
GUISetState(@SW_HIDE)

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\gs.png")
SetBitMap($hGUI2, $hImage, 255)
GUISetState(@SW_SHOW)

$hImage2 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\first.png")
SetBitMap2($hGUI3, $hImage2, 255)
GUISetState(@SW_HIDE)

$hImage3 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\second.png")
SetBitMap3($hGUI4, $hImage3, 255)
GUISetState(@SW_HIDE)

$hImage4 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\third.png")
SetBitMap4($hGUI5, $hImage4, 255)
GUISetState(@SW_HIDE)

GUIRegisterMsg($WM_HSCROLL  , "WM_HSCROLL"  )
do
until GUIGetMsg() =$GUI_EVENT_CLOSE

_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

Func WM_HSCROLL($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam, $ilParam
    SetBitMap($hGUI2, $hImage, GUICtrlRead($iSlider))
    SetBitMap2($hGUI3, $hImage2, GUICtrlRead($iSlider))
    SetBitMap3($hGUI4, $hImage3, GUICtrlRead($iSlider))
    SetBitMap4($hGUI5, $hImage4, GUICtrlRead($iSlider))
    GUICtrlSetData($iLabel1, GUICtrlRead($iSlider))
    If GUICtrlRead($iSlider) > 20 And GUICtrlRead($iSlider) < 50 Then
        If $fVisible Then
            GUISetState(@SW_SHOW, $hGUI3)
            $fVisible = False
        EndIf
    Else
        If Not $fVisible Then
            GUISetState(@SW_HIDE, $hGUI3)
            $fVisible = True
        EndIf
    EndIf
    If GUICtrlRead($iSlider) > 50 And GUICtrlRead($iSlider) < 80 Then
        If $fVisible2 Then
            GUISetState(@SW_SHOW, $hGUI4)
            $fVisible2 = False
        EndIf
    Else
        If Not $fVisible2 Then
            GUISetState(@SW_HIDE, $hGUI4)
            $fVisible2 = True
        EndIf
    EndIf
    If GUICtrlRead($iSlider) > 80 Then
        If $fVisible3 Then
            GUISetState(@SW_SHOW, $hGUI5)
            $fVisible3 = False
        EndIf
    Else
        If Not $fVisible3 Then
            GUISetState(@SW_HIDE, $hGUI5)
            $fVisible3 = True
        EndIf
    EndIf
    If GUICtrlRead($iSlider) > 40 And GUICtrlRead($iSlider) Then
        If $fVisible4 Then
            GUISetState(@SW_SHOW, $hGUI2)
            $fVisible4 = False
        EndIf
    Else
        If Not $fVisible4 Then
            GUISetState(@SW_HIDE, $hGUI2)
            $fVisible4 = True
        EndIf
    EndIf
EndFunc

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", $AC_SRC_ALPHA)
  _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

Func SetBitmap2($hGUI, $hImage2, $iOpacity)
  Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

  $hScrDC  = _WinAPI_GetDC(0)
  $hMemDC  = _WinAPI_CreateCompatibleDC($hScrDC)
  $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage2)
  $hOld    = _WinAPI_SelectObject($hMemDC, $hBitmap)
  $tSize   = DllStructCreate($tagSIZE)
  $pSize   = DllStructGetPtr($tSize  )
  DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage2))
  DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage2))
  $tSource = DllStructCreate($tagPOINT)
  $pSource = DllStructGetPtr($tSource)
  $tBlend  = DllStructCreate($tagBLENDFUNCTION)
  $pBlend  = DllStructGetPtr($tBlend)
  DllStructSetData($tBlend, "Alpha" , $iOpacity    )
  DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
  _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

Func SetBitmap3($hGUI, $hImage3, $iOpacity)
  Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

  $hScrDC  = _WinAPI_GetDC(0)
  $hMemDC  = _WinAPI_CreateCompatibleDC($hScrDC)
  $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage3)
  $hOld    = _WinAPI_SelectObject($hMemDC, $hBitmap)
  $tSize   = DllStructCreate($tagSIZE)
  $pSize   = DllStructGetPtr($tSize  )
  DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage3))
  DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage3))
  $tSource = DllStructCreate($tagPOINT)
  $pSource = DllStructGetPtr($tSource)
  $tBlend  = DllStructCreate($tagBLENDFUNCTION)
  $pBlend  = DllStructGetPtr($tBlend)
  DllStructSetData($tBlend, "Alpha" , $iOpacity    )
  DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
  _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

Func SetBitmap4($hGUI, $hImage4, $iOpacity)
  Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

  $hScrDC  = _WinAPI_GetDC(0)
  $hMemDC  = _WinAPI_CreateCompatibleDC($hScrDC)
  $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage4)
  $hOld    = _WinAPI_SelectObject($hMemDC, $hBitmap)
  $tSize   = DllStructCreate($tagSIZE)
  $pSize   = DllStructGetPtr($tSize  )
  DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage4))
  DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage4))
  $tSource = DllStructCreate($tagPOINT)
  $pSource = DllStructGetPtr($tSource)
  $tBlend  = DllStructCreate($tagBLENDFUNCTION)
  $pBlend  = DllStructGetPtr($tBlend)
  DllStructSetData($tBlend, "Alpha" , $iOpacity    )
  DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
  _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

post-65393-0-89747200-1309378795_thumb.p

post-65393-0-21849100-1309378806_thumb.p

post-65393-0-28474700-1309378817_thumb.p

post-65393-0-29333800-1309378827_thumb.p

Share this post


Link to post
Share on other sites



You dont need to rewrite the same function with different name every time you use it... anyway i m trying to do something different with the same result.

Share this post


Link to post
Share on other sites

You dont need to rewrite the same function with different name every time you use it... anyway i m trying to do something different with the same result.

Thanks Man!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0