Jump to content

Recommended Posts

Posted (edited)

In this example it's a representation of H2O. You can drag atoms to rearange, add another(s), change colours etc.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

;written by taietel

Opt("GUIOnEventMode", 1)

_Atom(@DesktopWidth/2, @DesktopHeight/2,60,0x777777,0xeeeeee,"Hydrogen")
_Atom(@DesktopWidth/2+50, @DesktopHeight/2,100,-1,-1,"Oxygen")
_Atom(@DesktopWidth/2+50, @DesktopHeight/2+40,60,0x777777,0xeeeeee,"Hydrogen")

While 1
    Sleep(10)
WEnd

Func _Atom($iLeft, $iTop, $iDMax=20, $iStartColour=0x550000, $iEndColour=0xff0000,$sTip="Name")
    If $iDMax=-1 Then $iDMax=20
    If $iStartColour=-1 Then $iStartColour=0x550000
    If $iEndColour=-1 Then $iEndColour=0xff0000
    If $sTip=-1 Then $sTip="Name"

    Local $Ri, $Rf, $Rs, $Gi, $Gf, $Gs, $Bi, $Bf, $Bs, $m = $iDMax*4/5, $Graphic
    Local $hGUI
    $hGUI = GUICreate($sTip, $iDMax, $iDMax, $iLeft-$iDMax/2, $iTop-$iDMax/2, $WS_POPUP, $WS_EX_LAYERED+$WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetBkColor(0xabcdef)

    $Ri = Mod($iStartColour,256)
    $Gi = BitAND($iStartColour/256,255)
    $Bi = BitAND($iStartColour/65536,255)

    $Rf = Mod($iEndColour,256)
    $Gf = BitAND($iEndColour/256,255)
    $Bf = BitAND($iEndColour/65536,255)

    $Rs = Abs($Ri - $Rf)/$m
    $Gs = Abs($Gi - $Gf)/$m
    $Bs = Abs($Bi - $Bf)/$m

    If $Rf < $Ri Then $Rs = -$Rs
    If $Gf < $Gi Then $Gs = -$Gs
    If $Bf < $Bi Then $Bs = -$Bs

    $Graphic = GUICtrlCreateGraphic(0, 0, $iDMax, $iDMax)
    GUICtrlSetState($Graphic,$GUI_DISABLE)
    For $i=0 To $m Step 0.1
        $Rf = $Ri + $Rs * $i
        $Gf = $Gi + $Gs * $i
        $Bf = $Bi + $Bs * $i

        GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, "0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2), "0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2))
        GUICtrlSetGraphic($Graphic, $GUI_GR_ELLIPSE, $i/2, $i/2, $iDMax-$i, $iDMax-$i)
    Next
    GUICtrlCreatePic("", 0, 0, $iDMax, $iDMax, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetTip(-1,$sTip)
    _WinAPI_SetLayeredWindowAttributes($hGUI,0xabcdef)
    GUISetState(@SW_SHOW)
EndFunc

Func _Exit()
    Exit
EndFunc

taietel

[EDIT] More examples below

Edited by taietel
Posted (edited)

A nice Example of using _WinAPI_SetLayeredWindowAttributes() and GUICtrlCreateGraphic() :)

Edit: At first I thought it was representation of Mickey Mouse!

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_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: 22/04/2018

Posted (edited)

Another example: n-Decane ( CH3-(CH2)8-CH3 ):

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

;written by taietel

Opt("GUIOnEventMode", 1)
#cs
;Example: Water
_Atom(@DesktopWidth/2-50, @DesktopHeight/2,60,0x777777,0xeeeeee,"Hydrogen")
_Atom(@DesktopWidth/2, @DesktopHeight/2-20,100,-1,-1,"Oxygen")
_Atom(@DesktopWidth/2+50, @DesktopHeight/2,60,0x777777,0xeeeeee,"Hydrogen")
#ce

;Example: n-Decane
_Atom(@DesktopWidth/2-180, @DesktopHeight/2,30,0x777777,0xeeeeee,"Hydrogen")
For $i=1 To 10
    _Atom(@DesktopWidth/2-190+40*$i, @DesktopHeight/2+40*(-1)^$i,30,0x777777,0xeeeeee,"Hydrogen")
    _Atom(@DesktopWidth/2-200+40*$i, @DesktopHeight/2+15*(-1)^$i,60,0x111111,0xdedede,"Carbon")
    _Atom(@DesktopWidth/2-210+40*$i, @DesktopHeight/2+40*(-1)^$i,30,0x777777,0xeeeeee,"Hydrogen")
Next
_Atom(@DesktopWidth/2-210+440, @DesktopHeight/2-5,30,0x777777,0xeeeeee,"Hydrogen")


#cs

;Example: Ethanol
_Atom(@DesktopWidth/2-180, @DesktopHeight/2,30,0x777777,0xeeeeee,"Hydrogen")
For $i=1 To 2
    _Atom(@DesktopWidth/2-190+40*$i, @DesktopHeight/2+40*(-1)^$i,30,0x777777,0xeeeeee,"Hydrogen")
    _Atom(@DesktopWidth/2-200+40*$i, @DesktopHeight/2+15*(-1)^$i,60,0x111111,0xdedede,"Carbon")
    _Atom(@DesktopWidth/2-210+40*$i, @DesktopHeight/2+40*(-1)^$i,30,0x777777,0xeeeeee,"Hydrogen")
Next
_Atom(@DesktopWidth/2-200+120, @DesktopHeight/2+10,40,-1,-1,"Oxygen")
_Atom(@DesktopWidth/2-200+140, @DesktopHeight/2+20,30,0x777777,0xeeeeee,"Hydrogen")
#ce

While 1
    Sleep(10)
WEnd

Func _Atom($iLeft, $iTop, $iDMax=20, $iStartColour=0x550000, $iEndColour=0xff0000,$sTip="Name")
    If $iDMax=-1 Then $iDMax=20
    If $iStartColour=-1 Then $iStartColour=0x550000
    If $iEndColour=-1 Then $iEndColour=0xff0000
    If $sTip=-1 Then $sTip="Name"

    Local $Ri, $Rf, $Rs, $Gi, $Gf, $Gs, $Bi, $Bf, $Bs, $m = $iDMax*4/5, $Graphic
    Local $hGUI
    $hGUI = GUICreate($sTip, $iDMax, $iDMax, $iLeft-$iDMax/2, $iTop-$iDMax/2, $WS_POPUP, $WS_EX_LAYERED+$WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetBkColor(0xabcdef)

    $Ri = Mod($iStartColour,256)
    $Gi = BitAND($iStartColour/256,255)
    $Bi = BitAND($iStartColour/65536,255)

    $Rf = Mod($iEndColour,256)
    $Gf = BitAND($iEndColour/256,255)
    $Bf = BitAND($iEndColour/65536,255)

    $Rs = Abs($Ri - $Rf)/$m
    $Gs = Abs($Gi - $Gf)/$m
    $Bs = Abs($Bi - $Bf)/$m

    If $Rf < $Ri Then $Rs = -$Rs
    If $Gf < $Gi Then $Gs = -$Gs
    If $Bf < $Bi Then $Bs = -$Bs

    $Graphic = GUICtrlCreateGraphic(0, 0, $iDMax, $iDMax)
    GUICtrlSetState($Graphic,$GUI_DISABLE)
    For $i=0 To $m Step 0.1
        $Rf = $Ri + $Rs * $i
        $Gf = $Gi + $Gs * $i
        $Bf = $Bi + $Bs * $i

        GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, "0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2), "0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2))
        GUICtrlSetGraphic($Graphic, $GUI_GR_ELLIPSE, $i/2, $i/2, $iDMax-$i, $iDMax-$i)
    Next
    GUICtrlCreatePic("", 0, 0, $iDMax, $iDMax, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetTip(-1,$sTip)
    _WinAPI_SetLayeredWindowAttributes($hGUI,0xabcdef)
    GUISetState(@SW_SHOW)
EndFunc

Func _Exit()
    Exit
EndFunc

[edit] added Ethanol (CH3CH2OH)

Edited by taietel
Posted (edited)

No Andreik, this.

I don't know why it shows like this... I'm on XP/32 and had no problem. Looks like _WinAPI_SetLayeredWindowAttributes is involved.Posted Image

[EDIT] If I move

GUICtrlCreatePic("", 0, 0, $iDMax, $iDMax, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetTip(-1,$sTip)

just below

_WinAPI_SetLayeredWindowAttributes($hGUI,0xabcdef)

the result is your picture, but I didn't made this change in my script

Edited by taietel
Posted

I just tested on Windows 7 x64 without any problems!

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_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: 22/04/2018

Posted

Another example, with movement. This uses 3 GUI's :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

;written by taietel

Opt("GUIOnEventMode", 1)

_Atom(515, 515,100,0x111111,0xdede00,"N1")
_Atom(515+70*Cos(0), 500+70*Sin(0),30,0x220000,0xee0000,"E1")
_Atom(515-70*Cos(0), 500+70*Sin(0),30,0x220000,0xee0000,"E2")
Sleep(1000)
For $i=0 To 10 Step 0.0005
    $hWnd0=WinGetHandle("N1")
    $hWnd1=WinGetHandle("E1")
    $hWnd2=WinGetHandle("E2")
    WinMove($hWnd1,"",500+$i*20+70*Cos($i), 500+70*Sin($i))
    WinMove($hWnd2,"",500+$i*20-70*Cos($i), 500+70*Sin($i))
    WinMove($hWnd0,"",515-50+$i*20, 515-50)
Next

While 1
    Sleep(10)
WEnd

Func _Atom($iLeft, $iTop, $iDMax=20, $iStartColour=0x550000, $iEndColour=0xff0000,$sTip="Name")
    If $iDMax=-1 Then $iDMax=20
    If $iStartColour=-1 Then $iStartColour=0x550000
    If $iEndColour=-1 Then $iEndColour=0xff0000
    If $sTip=-1 Then $sTip="Name"

    Local $Ri, $Rf, $Rs, $Gi, $Gf, $Gs, $Bi, $Bf, $Bs, $m = $iDMax*5/6, $Graphic, $hGUI
    $hGUI = GUICreate($sTip, $iDMax, $iDMax, $iLeft-$iDMax/2, $iTop-$iDMax/2, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetBkColor(0xabcdef)

    $Ri = Mod($iStartColour,256)
    $Gi = BitAND($iStartColour/256,255)
    $Bi = BitAND($iStartColour/65536,255)

    $Rf = Mod($iEndColour,256)
    $Gf = BitAND($iEndColour/256,255)
    $Bf = BitAND($iEndColour/65536,255)

    $Rs = Abs($Ri - $Rf)/$m
    $Gs = Abs($Gi - $Gf)/$m
    $Bs = Abs($Bi - $Bf)/$m

    If $Rf < $Ri Then $Rs = -$Rs
    If $Gf < $Gi Then $Gs = -$Gs
    If $Bf < $Bi Then $Bs = -$Bs

    $Graphic = GUICtrlCreateGraphic(0, 0, $iDMax, $iDMax)
    ;GUICtrlSetState($Graphic,$GUI_DISABLE)
    For $i=0 To $m Step 0.1
        $Rf = $Ri + $Rs * $i
        $Gf = $Gi + $Gs * $i
        $Bf = $Bi + $Bs * $i
        GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, "0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2), "0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2))
        GUICtrlSetGraphic($Graphic, $GUI_GR_ELLIPSE, $i/2, $i/2, $iDMax-$i, $iDMax-$i)
    Next
    GUICtrlSetState($Graphic,$GUI_DISABLE)
    GUICtrlCreatePic("", 0, 0, $iDMax, $iDMax, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetTip(-1,$sTip)
    _WinAPI_SetLayeredWindowAttributes($hGUI,0xabcdef)
    GUISetState(@SW_SHOW)
EndFunc

Func _Exit()
    Exit
EndFunc
Posted

Haha, that's pretty sweet. Reminds me of a puzzle game I was contemplating writing.

I was going to graphically display the structure of different materials and the object would be to re-arrange the molecules in those materials to turn the item into gold. (like the mideval quest to turn lead into gold)

So much to do, so little time.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...