Sign in to follow this  
Followers 0
Maffe811

Array issue and gui centering

15 posts in this topic

So i have this little slide show thing going on.

I made it by accident! :huh2:

Anyways, im having trouble figuring out the ammount of elements in the array and centering it correctly.

First, i just need something that counts how many elements there are in the array! ;)

Secondly, i dont want the gui centered on screen, cause the image is attatched with its upper left corner to the gui.

And i can't get it right...

If anyone has a quick suggestion i would love to hear, but only a couple lines.

I dont wanna have something that takes 7 lines and a udf... :alien:

There is probably a simple way, i just dont know what to do!!!

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Array.au3>

Opt("MustDeclareVars", 1)

;Constant variables
Global Const $AC_SRC_ALPHA      = 1

;Variables
Global $hGUI1, $hGUI2, $Array, $var

;Creates a gui to hold the image. This gui is never showed.
$hGUI2 = GUICreate("Test", @DesktopWidth, @DesktopHeight,-1,-1, -1, $WS_EX_LAYERED, $hGUI1)

; Load layered image
_GDIPlus_Startup()


$var = FileOpenDialog("", @DesktopDir, "Images (*.jpg;*.png)", 1 + 4 )
$Array = StringSplit($var, "|")

;Run function to put it on the screen
GUISetState()
For $i = 2 to 99 Step 1
    GUISetState()
ConsoleWrite("Fade in image: " & $i & @CRLF)
    For $o = 0 to 255 step 10
    SetBitMap($hGUI2, _GDIPlus_ImageLoadFromFile(@DesktopDir & "\" & $Array[$i] ), $o)
    Sleep (1)
    Next
ConsoleWrite("Sleep" & @CRLF)
Sleep (1500)
ConsoleWrite("Fade out image: " & $i & @CRLF)
    For $o = 255 to 0 step -10
    SetBitMap($hGUI2, _GDIPlus_ImageLoadFromFile(@DesktopDir & "\" & $Array[$i] ), $o)
    Sleep (1)
    Next
ConsoleWrite("Next image" & @CRLF)
Sleep (200)
Next

Exit

; Loop until user exits
do
until GUIGetMsg() =$GUI_EVENT_CLOSE

; ===============================================================================================================================
; SetBitMap
; ===============================================================================================================================
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

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites



There is Ubound to find the size of a array, but also, when you use StringSplit, the first element of the array contains the number of elements in the array.

As for the rest of your script, I didn't take a look at that yet :huh2:

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

So this worked then? >> :huh2:

Anyways, im having trouble figuring out the ammount of elements in the array and centering it correctly.

StringSplit() Return Index 0 with the number of Items.

#include <Array.au3>

Global $aArray = StringSplit("TEXT|TEXT|TEXT|TEXT|TEXT|TEXT", "|")
_ArrayDisplay($aArray)

Secondly, i dont want the gui centered on screen, cause the image is attatched with its upper left corner to the gui.

Where do you want it? And why is the Height & Width the same as the Desktop Height & Width?

Edit: smartee, just saw you answered. Also Maffe811 when you understand Arrays have a look at to learn about using arrays effectively.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

So this worked then? >> :huh2:

I dont know how, but i missed the two last answers, but i searched the forum and found something that works, that looks like your post.

StringSplit() Return Index 0 with the number of Items.

Okay, ill try this.

Where do you want it?

I want the image centered, and not the gui.

Also restrict the image to maximum 75% of screen size, but thats not important.

And why is the Height & Width the same as the Desktop Height & Width?

I was just testing to see what happened if i did it. Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Edit: Study these Example >> As wakillon did a pretty good job with those Functions. Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I fixed the code.

The array contains file names + the directory, thats why its the -1 at $ArrayCount

$var = FileOpenDialog("", @DesktopDir, "Images (*.jpg;*.png)", 1 + 4 )
$Array = StringSplit($var, "|")
$ArrayCount = $Array[0] - 1
ConsoleWrite("There are " & $ArrayCount & " elements in the array." & @CRLF)

;Run function to put it on the screen
GUISetState()
For $i = 2 to $ArrayCount Step 1
    GUISetState()
ConsoleWrite("Fade in image: " & $i & @CRLF)
    For $o = 0 to 255 step 10
    SetBitMap($hGUI2, _GDIPlus_ImageLoadFromFile(@DesktopDir & "\" & $Array[$i] ), $o)
    Sleep (1)
    Next
ConsoleWrite("Sleep" & @CRLF)
Sleep (1500)
ConsoleWrite("Fade out image: " & $i & @CRLF)
    For $o = 255 to 0 step -10
    SetBitMap($hGUI2, _GDIPlus_ImageLoadFromFile(@DesktopDir & "\" & $Array[$i] ), $o)
    Sleep (1)
    Next
ConsoleWrite("Next image" & @CRLF)
Sleep (200)
Next

Exit

Edit:

Will check! :huh2:


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Here is a tidied Version ;) and you can drag the GUI.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

_Main()

Func _Main()
    Local $aArray, $hGUI, $hImage, $sFile

    $hGUI = GUICreate("", 64, 64, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
    GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
    GUISetState(@SW_SHOW, $hGUI)

    $sFile = FileOpenDialog("", @DesktopDir, "Images (*.jpg;*.png)", 1 + 4)
    $aArray = StringSplit($sFile, "|")
    If @error Then
        Exit
    EndIf

    _GDIPlus_Startup()

    For $A = 2 To $aArray[0] - 1
        $hImage = _GDIPlus_ImageLoadFromFile($aArray[1] & "\" & $aArray[$A])
        For $B = 0 To 255 Step 10
            _SetBitmap($hGUI, $hImage, $B)
            Sleep(100)
        Next

        Sleep(100)

        For $B = 255 To 0 Step -10
            _SetBitmap($hGUI, $hImage, $B)
            Sleep(100)
        Next
    Next
    _GDIPlus_Shutdown()
EndFunc   ;==>_Main

Func _SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hBitmap, $hGetDC, $hMemDC, $hPreviousImage, $pBlend, $pSize, $pSource, $tBlend, $tSize, $tSource

    $hGetDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hGetDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hPreviousImage = _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, $hGetDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hGetDC)
    _WinAPI_SelectObject($hMemDC, $hPreviousImage)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_SetBitmap

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam, $ilParam
    Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Edit: Just saw you worked it out! But at least with this Version you can see how I structure code :huh2:

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Ill check it tomorrow

Edit: Study these Example >> As wakillon did a pretty good job with those Functions.

page__st__20__gopid__902307#entry902307

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

I got this working... atleast i think so!

The png file i had made was crap... it was even worse than the bmp :huh2:

So i have to remake it.

When im done with that, ill add it and then hopefully it will work!


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

I got this working... atleast i think so!

Didn't my Example work correctly? And whats the problem with your Script? :huh2:

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Didn't my Example work correctly? And whats the problem with your Script? :huh2:

I thought i fixed it, but since the quality of the splash i had was so bad i couldnt really see it.

Now i have a new splas and it works perfectly.

Your script worked, with the exception of this line:

$hGUI = GUICreate("", 64, 64, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))

Wich only showed 64 pixels by 64 pixels of the image.

But i have a new problem.

I want to have the splash scale after screen size, but i want to restrict it from going over 1000 pixels, since everything over will look low quality and bad.

So i though i could write

If $ScreenSizeHeight <= 1000 then $ScreenSizeHeight = 1000

Or something like that.

But then i need the heigth and width as variables... and as im writing i realise i dont... ;)

Anyhow i want to know why my script doesnt work!

There are to lines with obvious comments after it.

Why does one work, while the other doesnt, when all that is done is putting it in a variable ?

Edit:

Right click and save in script dir > [LINK]

Splash image

#include-once
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Math.au3>

Local $_Gui, $_Guititle='Splash'
Local $_Image1, $_Width, $_Height, $_Ratio, $_LastWidth, $_LastHeight, $i = 1
Local $WinMoveHeight = (@DesktopHeight - ($_Height/2 ) )/2
Local $WinMoveWidth = (@DesktopWidth - $_Width )/2

AdlibRegister ( '_ReduceMemory', 5000 )

HotKeySet("{F3}", "_SplashOff")


_SplashOn (@ScriptDir & "\bettergroovesharksplash.png" )

;~ Exit
Func _SplashOff()
    $i = 0
    _ImageDispose ( $_Image1 )
EndFunc

while $i = 1
    sleep (40)
WEnd

Func _SplashOn( $_PngPath )
    If Not $_Image1 Then _ImageInit ( '', $_PngPath )
    If Not $_Gui Then $_Gui = GUICreate ( $_Guititle, $_Width , $_Height, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $_Width = @DesktopWidth/4
    WinMove ( $_Gui, "", ( @DesktopWidth - $_Width )/2, (@DesktopHeight - ($_Height/2 ) )/2, $_Width, $_Width/$_Ratio );<========================= DOES WORK!!!
;   WinMove ( $_Gui, "",$WinMoveWidth, $WinMoveHeight, $_Width, $_Width/$_Ratio ) ;<========================= DOES NOT WORK!!!
    GUISetState ( @SW_SHOW )
    $_Image1 = _ImageResize ( $_PngPath, $_Width, $_Width/$_Ratio )
    _SetBitMap ( $_Gui, $_Image1, 255, $_Width, $_Width/$_Ratio )
    _WinGetPos ( )
EndFunc ;==> _SplashCome ( )



Func _SetBitmap ( $hGUI, $hImage, $iOpacity, $n_width, $n_height )
    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", $n_width )
    DllStructSetData ( $tSize, "Y", $n_height )
    $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 ( )

Func _ImageResize ( $sInImage, $newW, $newH, $sOutImage="" )
    Local $oldImage, $GC, $newBmp, $newGC
    If $sOutImage = "" Then _GDIPlus_Startup ( )
    $oldImage = _GDIPlus_ImageLoadFromFile ( $sInImage )
    $GC = _GDIPlus_ImageGetGraphicsContext ( $oldImage )
    $newBmp = _GDIPlus_BitmapCreateFromGraphics ( $newW, $newH, $GC )
    $newGC = _GDIPlus_ImageGetGraphicsContext ( $newBmp )
    _GDIPlus_GraphicsDrawImageRect ( $newGC, $oldImage, 0, 0, $newW, $newH )
    _GDIPlus_GraphicsDispose ( $GC )
    _GDIPlus_GraphicsDispose ( $newGC )
    _GDIPlus_ImageDispose ( $oldImage )
    If $sOutImage = "" Then
        Return $newBmp
    Else
        _GDIPlus_ImageSaveToFile ( $newBmp, $sOutImage )
        _GDIPlus_BitmapDispose ( $newBmp )
        _GDIPlus_Shutdown ( )
        Return 1
    EndIf
EndFunc ;==> _ImageResize ( )

Func _ImageInit ( $_PngUrl2, $_PngPath2 )
    _GDIPlus_Startup ( )
    $_Image1 = _GDIPlus_ImageLoadFromFile ( $_PngPath2 )
    $_Width = _GDIPlus_ImageGetWidth ( $_Image1 )
    $_Height = _GDIPlus_ImageGetHeight ( $_Image1 )
    $_Ratio = Round ( $_Width / $_Height )
EndFunc ;==> _ImageInit ( )

Func _ImageDispose ( $_Image )
    GUIDelete ( WinGetHandle ( $_Guititle, '' ) )
    _GDIPlus_GraphicsDispose ( $_Image )
    _GDIPlus_Shutdown ( )
    $_Image1=0
    $_Gui=0
EndFunc ;==> _ImageDispose ( )

Func _WinGetPos ( )
    $_Pos = WinGetPos ( $_Gui )
    $_LastWidth = $_Pos[2]
    $_LastHeight = $_Pos[3]
EndFunc ;==> _WinGetPos ( )

Func _ReduceMemory ( )
    Local $_Handle = DllCall ( "kernel32.dll", "int", "OpenProcess", "int", 2035711, "int", False, "int", @AutoItPID )
    If Not @error Then Return DllCall ( "psapi.dll", "int", "EmptyWorkingSet", "long", $_Handle[0] )
EndFunc ;==> _ReduceMemory ( )
Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

Ah, the size was because of the image Example I was using. Sorry I should've pointed that out in the original post.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Yes, but i just changed that to 1000 and it worked.

But why does it work when the expression is present, but not when its present but represented by a variable ?


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

From what I can see $_Width & $_Height are blank in your Script. Or am I missing something? :huh2:

Perhaps use MsgBox to test what the values are. Also change the declaration to Global not Local, Local should be in Functions only.

Have a look at this >> http://www.autoitscript.com/autoit3/docs/intro/lang_variables.htm and add this to the top of the Script >> #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 to eradicate problems with variables that you might have.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Its declared localy, acuse later its going to be included in another script.

Here is what i got:

Func _SplashOn( $_PngPath )
    If Not $_Image1 Then _ImageInit ( '', $_PngPath )
    If Not $_Gui Then $_Gui = GUICreate ( $_Guititle, $_Width , $_Height, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $_Width = @DesktopWidth/4;Not sure it works without this, why... idk :P
    ConsoleWrite("Size of screen is: " & @DesktopWidth/4 & " pixels." & @CRLF) ;Size of screen.
    If @DesktopWidth/4 >= 1000 Then
        $_Width = 1000
    Else
        $_Width = @DesktopWidth/4
    EndIf
    ConsoleWrite("Size of $_Width is: " & $_Width & " pixels." & @CRLF);Size of $_width
    WinMove ( $_Gui, "", ( @DesktopWidth - $_Width )/2, (@DesktopHeight - ($_Height/2 ) )/2, $_Width, $_Width/$_Ratio )
    GUISetState ( @SW_SHOW )
    $_Image1 = _ImageResize ( $_PngPath, $_Width, $_Width/$_Ratio )
    _SetBitMap ( $_Gui, $_Image1, 255, $_Width, $_Width/$_Ratio )
    _WinGetPos ( )
EndFunc ;==> _SplashOn

Works like i want it to :huh2:


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

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