Jump to content

sandin

Active Members
  • Posts

    568
  • Joined

  • Last visited

About sandin

  • Birthday 04/20/1986

Profile Information

  • Location
    Serbia

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

sandin's Achievements

Universalist

Universalist (7/7)

8

Reputation

  1. update edit: just added gloss to the main image and 3D depth - see picture in 1st post.
  2. ok, fixed error. ...and yeh, it's for vista+
  3. I've done nothing new, no new functions and similar, I've just wrapped all the functions people on this forum created to make interesting menu items (All the credits for the existed functions are posted in the top of the script). I have image menu-item (like the one you see on new AutoCad), and glass menu (similar to the one on firefox). This is not UDF, don't have time to make it :/ if anyone is willing to make an UDF for this, I'm more than willing to help as much as I can (and as much my time allows me to). script is for vista+ OS (because of AERO environment) p.s. top left image was drawn with GDI+ #region parts that are not my work: ;JamesBrooks for Vista glass functions: http://www.autoitscript.com/forum/topic/...lass-four-functions/page__hl__ ;Authenticity and Yashied for glow txt on glass: http://www.autoitscript.com/forum/topic/...extex-to-get-glowing-text-on-a ;Malkey for GDI+ gradient: http://www.autoitscript.com/forum/topic/75792-a-gdiplus-gradient-line-brush/ #endregion #include <FontConstants.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> OnAutoItExitRegister( "_CleanUp" ) Global $IconSize = 48 Global $width = 300 Global $height = 350 Global $shine1 = 5 Global $shine2 = 5 Global $shine3 = 125 Global $menuFontSize = 16 Global $title = 'Some cool menu' Global $temp_image = @TempDir & '\my_seven_image.bmp' Global $Win_Back_Color = 0x636363;0xC5C5C5;454545 <--- color of lower dark grey line For $i = 1 to Int($IconSize/4.8) ;adding space in front of the title so that it doesn't overlap top left image $title = ' ' & $title Next #region values requires for text shine on glass area Global Const $DTT_TEXTCOLOR = 0x00000001 Global Const $DTT_GLOWSIZE = 0x00000800 Global Const $DTT_COMPOSITED = 0x00002000 If Not IsDeclared("tagDTTOPTS") Then Global Const $tagDTTOPTS = _ "uint Size;uint Flags;uint clrText;uint clrBorder;uint clrShadow;int TextShadowType;" & $tagPOINT & _ ";int BorderSize;int FontPropId;int ColorPropId;int StateId;int ApplyOverlay;int GlowSize;ptr DrawTextCallback;int lParam;" Global $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;") Global $sStruct = DllStructCreate("dword;int;ptr;int") Global $Area[4] = [0, 0, $IconSize-23, 0] #endregion Global $Form1 = GUICreate($title, $width, $height, -1, -1, -1, -1) Global $GlassArea = GUICtrlCreateLabel("", 0, 0, $width, $IconSize-23) ;area that will be filled with glass GUICtrlSetBkColor(-1, 0x000000) Global $DarkGreyArea = GUICtrlCreateGraphic(0, 0, $width, $height-45) ;work area (to add controls in) GUICtrlSetBkColor(-1, 0xC5C5C5) ;with light grey area Global $CloseButton = GUICtrlCreateButton("Close", $width-90, $height-35, 80, 25) Global $hTheme = _WinAPI_OpenThemeData($Form1, "globals") ;required function for label shine in glass area If (@OSVersion <> "WIN_VISTA") OR (@OSVersion <> "WIN_7") Then _Vista_ApplyGlassArea($Form1, $Area, $Win_Back_Color) ;applying glass area to main GUI (area where $GlassArea label is) GUISetState(@SW_SHOW, $Form1) ;creating child GUI with top left image-menu-control Global $iX = 0, $iY = 0, $iWidth = $IconSize, $iHeight = $IconSize Global $controlGui, $HoverImage, $Mask, $FileGUI, $FileMenu, $EditGUI, $EditMenu, $HelpGUI, $HelpMenu, $DownGUI, $DownMenu #region create fake GUIs with each holding a clickable control $ImageState = 1 _CreateFakeGUI($controlGui, 'ControlGUI', 48, 48, -1, -23, 1, $HoverImage) $FileState = 1 _CreateFakeGUI($FileGUI, 'FileGUI', 35, $menuFontSize*2-Round($menuFontSize/1.5), 52, 4, 2, $FileMenu) $EditState = 1 _CreateFakeGUI($EditGUI, 'EditGUI', 35, $menuFontSize*2-Round($menuFontSize/1.5), 92, 4, 2, $EditMenu) $HelpState = 1 _CreateFakeGUI($HelpGUI, 'HelpGUI', 45, $menuFontSize*2-Round($menuFontSize/1.5), 130, 4, 2, $HelpMenu) $DownState = 1 _CreateFakeGUI($DownGUI, 'DownGUI', 20, $menuFontSize*2-Round($menuFontSize/1.5), $width-18, 4, 2, $DownMenu) #endregion #region create context menus ;----------Image Menu------------------------ $ImageDummy = GUICtrlCreateDummy() $ImageContext = GUICtrlCreateContextMenu($ImageDummy) $ImMinimize = GUICtrlCreateMenuItem("Minimize", $ImageContext) $ImMaximize = GUICtrlCreateMenuItem("Maximize", $ImageContext) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateMenuItem("", $ImageContext) $imExit = GUICtrlCreateMenuItem("Exit", $ImageContext) ;----------File Menu------------------------ $FileDummy = GUICtrlCreateDummy() $FileContext = GUICtrlCreateContextMenu($FileDummy) $FileNew = GUICtrlCreateMenu("New", $FileContext) $FileNewProject = GUICtrlCreateMenuItem("Project", $FileNew) $FileNewFile = GUICtrlCreateMenuItem("File", $FileNew) $FileOpen = GUICtrlCreateMenuItem("Open", $FileContext) $FileSave = GUICtrlCreateMenuItem("Save", $FileContext) $FileSaveAs = guictrlcreatemenuitem("Save As...", $FileContext) GUICtrlCreateMenuItem("", $FileContext) $FileExit = guictrlcreatemenuitem("Exit", $FileContext) ;----------Edit Menu------------------------ $EditDummy = GUICtrlCreateDummy() $EditContext = GUICtrlCreateContextMenu($EditDummy) $EditUndo = GUICtrlCreateMenuItem("Undo", $EditContext) $EditRedo = GUICtrlCreateMenuItem("Redo", $EditContext) GUICtrlCreateMenuItem("", $EditContext) $EditCut = GUICtrlCreateMenuItem("Cut", $EditContext) $EditCopy = GUICtrlCreateMenuItem("Copy", $EditContext) $EditPaste = GUICtrlCreateMenuItem("Paste", $EditContext) GUICtrlCreateMenuItem("", $EditContext) $EditPref = GUICtrlCreateMenuItem("Preferences", $EditContext) ;----------Help Menu------------------------ $HelpDummy = GUICtrlCreateDummy() $HelpContext = GUICtrlCreateContextMenu($HelpDummy) $HelpHelp = GUICtrlCreateMenuItem("Help", $HelpContext) GUICtrlCreateMenuItem("", $HelpContext) $HelpAbout = GUICtrlCreateMenuItem("About", $HelpContext) ;----------Down arrow Menu------------------------ $DownDummy = GUICtrlCreateDummy() $DownContext = GUICtrlCreateContextMenu($DownDummy) $DownTab = GUICtrlCreateMenuItem("Tab Groups", $DownContext) $DownTabOther = GUICtrlCreateMenuItem("Tabs from other computers", $DownContext) GUICtrlCreateMenuItem("", $DownContext) $DownTabExample = GUICtrlCreateMenuItem("Example tab", $DownContext) #endregion _Draw_menus() ;drawing all menu items Global $Mask = GUICreate('Mask', $iWidth-2, $iHeight-2, 0, -22, $WS_POPUP, $WS_EX_MDICHILD, $Form1) ;another child window for shade and gloss when moving mouse over image-menu or clicking it GUISetBkColor(0xFFFFFF, $Mask) WinSetTrans($Mask, '', 40) GUISetState(@SW_DISABLE, $Mask) ;still not shown, only disabled GUIRegisterMsg(0xF,"MY_PAINT") While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $HelpAbout MsgBox(48, 'About', 'Cool menus by... sandin' & @CRLF & @CRLF & '07.07.2011', -1, $Form1) Case $ImMinimize WinSetState($Form1, '', @SW_MINIMIZE) Case $GUI_EVENT_CLOSE, $imExit, $CloseButton, $FileExit Exit Case $GlassArea ;moving window when holding glass area that isn't menu dllcall("user32.dll","int","SendMessage","hWnd", $Form1,"int",0xA1,"int", 2,"int", 0) EndSwitch #region detection clicks and hovering above menu items If WinActive($Form1) then ;<-- here's one problem, I need this in order for window not to detect any clicks if you click on another window that is above this one ;but then you can't click on any control even if the window is aside your currently active window. _MenuBehavior($FileGUI, $FileMenu, $FileState, 'File', $FileContext) _MenuBehavior($EditGUI, $EditMenu, $EditState, 'Edit', $EditContext) _MenuBehavior($HelpGUI, $HelpMenu, $HelpState, 'Help', $HelpContext) _MenuBehavior($DownGUI, $DownMenu, $DownState, ChrW(9660), $DownContext) _MenuBehavior($controlGui, $HoverImage, $ImageState, '', $ImageContext) EndIf #endregion WEnd Func _MenuBehavior($WinHWND, $i_MenuItem, ByRef $i_MenuState, $i_Label, $i_ContextMenu);, $i_Shine1, $i_Shine2, $i_Shine3, $i_Color1, $i_Color2) Local $a = GUIGetCursorInfo($WinHWND) Switch $a[4] Case $i_MenuItem If $a[2] = 1 Then If $i_MenuState <> 3 Then $i_MenuState = 3 if ($FileState <> 1) AND ($FileMenu <> $i_MenuItem) then $FileState = 1 _Draw_Menu_ex($FileGUI, 'File', $menuFontSize, $shine3, 0x000000) EndIf if ($EditState <> 1) AND ($EditMenu <> $i_MenuItem) then ;making sure that disable all other menu clicked state (if there are any) $EditState = 1 _Draw_Menu_ex($EditGUI, 'Edit', $menuFontSize, $shine3, 0x000000) EndIf if ($HelpState <> 1) AND ($HelpMenu <> $i_MenuItem) Then $HelpState = 1 _Draw_Menu_ex($HelpGUI, 'Help', $menuFontSize, $shine3, 0x000000) EndIf if ($DownState <> 1) AND ($DownMenu <> $i_MenuItem) Then $DownState = 1 _Draw_Menu_ex($DownGUI, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine3, 0x555555) EndIf if ($ImageState <> 1) AND ($HoverImage <> $i_MenuItem) Then $ImageState = 1 GUISetState(@SW_HIDE, $Mask) EndIf If $i_MenuItem = $DownMenu then _Draw_Menu_ex($WinHWND, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine2+2, 0x000099) ElseIf $i_MenuItem = $HoverImage Then GUISetBkColor(0x000000, $Mask) GUISetState(@SW_SHOWNOACTIVATE, $Mask) Else _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine1, 0x000099) ;clicked File menu state, drawing average glow, and red color EndIf ShowMenu($WinHWND, $i_MenuItem, $i_ContextMenu) ;showing context menu for File EndIf Else If $i_MenuState <> 2 Then $i_MenuState = 2 If $i_MenuItem = $DownMenu Then _Draw_Menu_ex($WinHWND, '| ' & ChrW(9660) & ' |', $menuFontSize-Round(Sqrt($menuFontSize)), $shine2, 0x555555) ElseIf $i_MenuItem = $HoverImage Then GUISetBkColor(0xFFFFFF, $Mask) GUISetState(@SW_SHOWNOACTIVATE, $Mask) Else _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine2, 0x000000) ;high glow, black color EndIf EndIf EndIf Case Else If $i_MenuState <> 1 Then $i_MenuState = 1 If $i_MenuItem = $DownMenu Then _Draw_Menu_ex($WinHWND, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine3, 0x555555) ElseIf $i_MenuItem = $HoverImage Then GUISetState(@SW_HIDE, $Mask) Else _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine3, 0x000000) ;spread glow so there aren't any, black color EndIf EndIf EndSwitch EndFunc Func _CreateFakeGUI(ByRef $WinHWND, $WinTitle, $WinWIdth, $WinHeight, $Win_X, $Win_Y, $AddCtrl, ByRef $CtrlHWND);, $LabelSize = 35) $WinHWND = GUICreate($WinTitle, $WinWIdth, $WinHeight, $Win_X, $Win_Y, $WS_POPUP, $WS_EX_MDICHILD, $Form1) If $AddCtrl = 1 then $CtrlHWND = GUICtrlCreatePic('', 0, 0, $iWidth, $iHeight) ;control to put image later on ElseIf $AddCtrl = 2 Then $CtrlHWND = GUICtrlCreateLabel('', 0, 0, $WinWIdth, $menuFontSize*2-Round($menuFontSize/1.5)) ;clickable area GUICtrlSetBkColor(-1, 0x000000) If (@OSVersion <> "WIN_VISTA") OR (@OSVersion <> "WIN_7") Then _Vista_ApplyGlass($WinHWND, $Win_Back_Color) ;apply glass on entire child window EndIf GUISetState(@SW_DISABLE, $WinHWND) ;disabling window so that it doesn't take focus from parent when you click on it GUISetState(@SW_SHOWNOACTIVATE, $WinHWND) ;show and doesn't focus If $AddCtrl = 1 Then _Create_7Image() ;creating image with 7 number on it (like win7) GUICtrlSetImage($CtrlHWND, $temp_image) ;setting image into control we created earlier. ;Why did I use this method and not redrew image 7 in MY_PAINT? because it would be very slow, this method is faster. EndIf EndFunc Func ShowMenu($hWnd, $CtrlID, $nContextID) Local $timez = TimerInit() Local $arPos, $x, $y Local $hMenu = GUICtrlGetHandle($nContextID) $arPos = ControlGetPos($hWnd, "", $CtrlID) $x = $arPos[0] $y = $arPos[1] + $arPos[3] ClientToScreen($hWnd, $x, $y) TrackPopupMenu($hWnd, $hMenu, $x, $y) EndFunc ;==>ShowMenu Func ClientToScreen($hWnd, ByRef $x, ByRef $y) Local $stPoint = DllStructCreate("int;int") DllStructSetData($stPoint, 1, $x) DllStructSetData($stPoint, 2, $y) DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint)) $x = DllStructGetData($stPoint, 1) $y = DllStructGetData($stPoint, 2) $stPoint = 0 EndFunc ;==>ClientToScreen Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu #region glass functions for aero graphic environment (link at the top of the script) Func _Vista_ApplyGlass($hWnd, $bColor = 0x000000) GUISetBkColor($bColor) $Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct)) If @error Then Return 0 SetError(1) Else Return $Ret EndIf EndFunc ;==>_Vista_ApplyGlass Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000) If IsArray($Area) Then DllStructSetData($Struct, "cxLeftWidth", $Area[0]) DllStructSetData($Struct, "cxRightWidth", $Area[1]) DllStructSetData($Struct, "cyTopHeight", $Area[2]) DllStructSetData($Struct, "cyBottomHeight", $Area[3]) GUISetBkColor($bColor); Must be here! $Ret = DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct)) If @error Then Return 0 Else Return $Ret EndIf Else MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!") EndIf EndFunc ;==>_Vista_ApplyGlassArea #endregion Func _Draw_menus() _Draw_Menu_ex($FileGUI, 'File', $menuFontSize, $shine3, 0x000000) _Draw_Menu_ex($EditGUI, 'Edit', $menuFontSize, $shine3, 0x000000) _Draw_Menu_ex($HelpGUI, 'Help', $menuFontSize, $shine3, 0x000000) _Draw_Menu_ex($DownGUI, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine3, 0x555555) EndFunc Func _Draw_Menu_ex($WinHandle, $iCaption, $iSize, $iShine, $iColor) Local $hDC = _WinAPI_GetDC($WinHandle) Local $tClientRect = _WinAPI_GetClientRect($WinHandle) Local $sText = $iCaption Local $hFont = _WinAPI_CreateFont($iSize, $iSize/2-1, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'SegoeUI') _DrawGlowingText($hDC, $sText, $tClientRect, $iShine, $hFont, $iColor) _WinAPI_DeleteObject($hFont) _WinAPI_ReleaseDC($WinHandle, $hDC) EndFunc #region making label shine in glass area (Link at the top of the script) Func _DrawGlowingText($hDC, $sText, $tRc, $iGlowSize = 10, $hFont = 0, $iTextClr = -1) Local $hCDC Local $hBrush, $hOldBrush Local $tRcText Local $tBI, $tDTO Local $hDIBBmp, $hOldBmp Local $hOldFont Local $tST Local $iFlags = BitOR($DTT_GLOWSIZE, $DTT_COMPOSITED) $hCDC = _WinAPI_CreateCompatibleDC($hDC) $tBI = DllStructCreate($tagBITMAPINFO) DllStructSetData($tBI, "Size", DllStructGetSize($tBI)-4) DllStructSetData($tBI, "Width", DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left")) DllStructSetData($tBI, "Height", -(DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top"))) DllStructSetData($tBI, "Planes", 1) DllStructSetData($tBI, "BitCount", 32) DllStructSetData($tBI, "Compression", 0) ; BI_RGB $hDIBBmp = _WinAPI_CreateDIBSection($hDC, $tBI) $hOldBmp = _WinAPI_SelectObject($hCDC, $hDIBBmp) If $hFont Then $hOldFont = _WinAPI_SelectObject($hCDC, $hFont) $tDTO = DllStructCreate($tagDTTOPTS) DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO)) If $iTextClr <> -1 Then $iFlags = BitOR($iFlags, $DTT_TEXTCOLOR) DllStructSetData($tDTO, "clrText", $iTextClr) EndIf DllStructSetData($tDTO, "Flags", $iFlags) DllStructSetData($tDTO, "GlowSize", $iGlowSize) _WinAPI_DrawThemeTextEx($hTheme, $hCDC, 0, 0, $sText, _ BitOR($DT_SINGLELINE, $DT_CENTER, $DT_VCENTER, $DT_NOPREFIX), $tRc, $tDTO) _WinAPI_BitBlt($hDC, DllStructGetData($tRc, "Left"), DllStructGetData($tRc, "Top"), _ DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"), _ DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top"), $hCDC, 0, 0, 0xCC0020) ; SRCCOPY ;top+Sqrt($menuFontSize) _WinAPI_SelectObject($hCDC, $hOldBmp) If $hFont Then _WinAPI_SelectObject($hCDC, $hOldFont) _WinAPI_DeleteObject($hDIBBmp) _WinAPI_DeleteDC($hCDC) EndFunc Func _WinAPI_CreateDIBSection($hDC, Const ByRef $tBmpInfo, $iUsage = 0, $pBits = 0, $hSecond = 0, $iOffset = 0) Local $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBmpInfo), _ "uint", $iUsage, "ptr", $pBits, "hwnd", $hSecond, "uint", $iOffset) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] = 87 Then Return SetError(1, 1, 0); 87 = ERROR_INVALID_PARAMETER If $aResult[0] = 0 Then Return SetError(1, 2, 0) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_DrawThemeTextEx($hTheme, $hDC, $iPartId, $iStateId, $sText, $iFlags, ByRef $tRect, Const ByRef $tDTTOPTS) Local $aResult = DllCall("uxtheme.dll", "int", "DrawThemeTextEx", "ptr", $hTheme, "hwnd", $hDC, "int", $iPartId, "int", $iStateId, _ "wstr", $sText, "int", -1, "uint", $iFlags, "ptr", DllStructGetPtr($tRect), "ptr", DllStructGetPtr($tDTTOPTS)) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] <> 0 Then Return SetError(1, 0, 0) Return SetError(0, 0, $aResult[0] = 0) EndFunc Func _WinAPI_OpenThemeData($hWnd, $sClassList) Local $aResult = DllCall("uxtheme.dll", "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] = 0 Then Return SetError(1, 0, 0) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_CloseThemeData($hTheme) Local $aResult = DllCall("uxtheme.dll", "int", "CloseThemeData", "hwnd", $hTheme) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, 0, $aResult[0] = 0) EndFunc #endregion Func MY_PAINT($hWnd, $Msg, $wParam, $lParam) _Draw_menus() Return $GUI_RUNDEFMSG EndFunc Func _Create_7Image() ;drawn by myself xP _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($controlGui) Local $hbitmap = _GDIPlus_BitmapCreateFromGraphics($iwidth, $iheight, $hGraphic) Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($hbitmap) Local $LetterSize = 36 Local $Letter = '7' Local $hbrush = _GDIPlus_BrushCreateSolid(0xFF152a3d) Local $hbrushB = _GDIPlus_BrushCreateSolid(0xFF000000) Local $hbrush2 = _GDIPlus_BrushCreateSolid(0x3A152a3d) Local $hbrush3 = _GDIPlus_BrushCreateSolid(0x28FFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate () Local $hFamily = _GDIPlus_FontFamilyCreate ("Times New Roman") Local $hPen = _GDIPlus_PenCreate (0xFF454545) Local $hFont = _GDIPlus_FontCreate ($hFamily, $LetterSize, 1) Local $tLayout Local $tLayout2 #region malkey's gradient example ;creating gradient Local $aFact[4] = [0, 0.3, 0.6, 1.0] Local $aPosit[4] = [0.0, 0.3, 0.6, 1.0] Local $hBrushLin2 = gdiplus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFact, $aPosit, _ 0xFF5078fb, 0xFF91e9ff, 0x00000002, 1) _GDIPlus_GraphicsFillRect($backbuffer, $iX, $iY, $iWidth, $iHeight, $hBrushLin2) #endregion Local $StartNum = 1 ;creating little pixels to add texture for $j = 1 to 48 for $i = $StartNum to 48 step 3 _GDIPlus_GraphicsFillRect($backbuffer, $i-1, $j-1, 1, 1, $hbrush2) Next $StartNum += 1 If $StartNum > 3 then $StartNum = 1 Next Local $3D_Depth = 3 $tLayout2 = _GDIPlus_RectFCreate ($iX+7, $iY-1, $iWidth, $iHeight) _GDIPlus_GraphicsDrawStringEx ($backbuffer, $Letter, $hFont, $tLayout2, $hFormat, $hbrush2) ;creating shadow under character For $i = 1 to $3D_Depth $tLayout = _GDIPlus_RectFCreate ($iX+6-$i, $iY-$i-2, $iWidth-4, $iHeight+4) If $i = $3D_Depth then _GDIPlus_GraphicsDrawStringEx ($backbuffer, $Letter, $hFont, $tLayout, $hFormat, $hBrush) ;creating character Else _GDIPlus_GraphicsDrawStringEx ($backbuffer, $Letter, $hFont, $tLayout, $hFormat, $hBrushB) ;creating character depth EndIf Next Local $i_a = 48 ;ellipse points Local $i_b = 32 For $j = 1 to 48 For $i = 1 to 48 if $i >= Sqrt($i_a^2-$i_a^2*$j^2/$i_b^2) then _GDIPlus_GraphicsFillRect($backbuffer, 48-$i, 48-$j, 1, 1, $hbrush3) ;creating gloss with ellipse equation Next Next _GDIPlus_GraphicsDrawRect($backbuffer, $iX, $iY, $iWidth-1, $iHeight-1, $hPen) ;boxing entire image with dark grey line Local $GC = _GDIPlus_ImageGetGraphicsContext($hbitmap) Local $newBmp = _GDIPlus_BitmapCreateFromGraphics($iwidth, $iheight, $GC) Local $newGC = _GDIPlus_ImageGetGraphicsContext($newBmp) _GDIPlus_GraphicsDrawImageRect($newGC, $hbitmap, 0, 0, $iwidth, $iheight) _GDIPlus_ImageSaveToFile($newBmp, $temp_image) ;saving created image - it's easier to show image and leave it there, than redrawing this entire thing ;when GID+ gets disappeared _WinAPI_DeleteObject($hbitmap) ;disposing all the unneeded stuff _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_GraphicsDispose($GC) _GDIPlus_GraphicsDispose($newGC) _GDIPlus_BitmapDispose($newBmp) _GDIPlus_BrushDispose($hBrushLin2) _GDIPlus_BrushDispose($hbrush) _GDIPlus_BrushDispose($hbrushB) _GDIPlus_BrushDispose($hbrush2) _GDIPlus_BrushDispose($hbrush3) _GDIPlus_PenDispose ($hPen) _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($temp_image) _GDIPlus_Shutdown() EndFunc #region drawing gradient by Malkey (link at the top of the script) Func gdiplus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _ $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0) Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000 If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001 If $WrapMode = -1 Then $WrapMode = 1 $tRect = DllStructCreate("float X;float Y;float Width;float Height") $pRect = DllStructGetPtr($tRect) DllStructSetData($tRect, "X", $iX) DllStructSetData($tRect, "Y", $iY) DllStructSetData($tRect, "Width", $iWidth) DllStructSetData($tRect, "Height", $iHeight) ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _ "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0) If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0] If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0] $iCount = UBound($aPositions) $tFactors = DllStructCreate("float[" & $iCount & "]") $pFactors = DllStructGetPtr($tFactors) For $iI = 0 To $iCount - 1 DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1) Next $tPositions = DllStructCreate("float[" & $iCount & "]") $pPositions = DllStructGetPtr($tPositions) For $iI = 0 To $iCount - 1 DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1) Next $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _ "ptr", $pFactors, "ptr", $pPositions, "int", $iCount) Return $aRet[6] ; Handle of Line Brush EndFunc ;==>Gdiplus_CreateLineBrushFromRect #endregion Func _CleanUp() _WinAPI_CloseThemeData($hTheme) FileDelete($temp_image) EndFunc
  4. Long time ago I had WinFast TV card in my PC and I used to control my PC, and now I have decided to use my PC with remote control once again. I found this (or this, edit: recently I found another schematic, perhaps the easiest one to make, is here - it uses line in/microphone on your sound card to get infrared signals, so if you don't have COM port, you can still make, and use this, but you must change plugin on WinLIRC program itself from Serial to Audio) instruction on how to create COM (RS232) port infrared remote control receiver. I know that COM port is slowly dying, but there are COM TO USB adapters (if you still want to make your own remote control receiver). This script is connected to WinLIRC (software for receiving and recognizing signals from COM port, IRToy, Maxter, etc...), and performing different operations according to the winlirc remote key recognition. Such operations like: - Start program (with parameters, if program is started start new or focus already started one) - Control players (built in: winamp, media player classic, windows media player, bsplayer) - Send keyboard keys (strings, control keys, single key, or mobile typing style (2 - abc2, 3 - def3, etc...) - Mouse operations (clicks, double clicks, move, scroll) - Power state change (full screen menu with selection, shutdown, reset, log off, standby, hibernate) - send WM_COMMAND to any window (hook WM_COMMAND as well) - other (Master volume up, down, mute, Eject CD, Show time/date Some of the Screen Shots: Config Screen, Type mobile style, Change volume, Show time/date, Selectable power state P.S. Thanks to: - wraithdu for library (requires Microsoft VC++ 2008 SP1 Redistributable to be installed) - yashied for soundquery.au3 UDF found in his script - J. Thuemmler for dssubcls.dll library (used for hooking WM_COMMAND messages from other windows Download Links: Compiled (together with WinLIRC 0.8.7a) Source (without WinLIRC)
  5. I wasn't even looking at the cpu usage, yeah, sleep(10) in the main (while 1) loop should reduce the current cpu usage by 50%. @all: thank you
  6. Not much of an example, just wanted to wish happy holidays, so... Happy Holidays AutoIt scripters!!! Best of luck to all of you download link: Happy Holidays (wish I could upload it here, but it was bigger than my 600kb limit ) P.S. there's also compiled version
  7. O_o if $Score > $BestResult then $BestResult = $Score $show_result &= @CRLF & "AND You beat the highscore!" GUICtrlSetData($BestResult_Label, "Highscore: " & $Score & "/" & $Counter) IniWrite($Save_File, "Top score", "Score", $Score & "/" & $Counter) EndIf the code is very simple, how can it not work? O_o BOTs take fun from the games , if you wanna be the best, just use: ControlSetText("Bounce The SUN", "", "[CLASS:Static; INSTANCE:18]", "Highscore: 99999/99")
  8. It does? but the $WS_EX_COMPOSITED style should remove any window/controls flickering (at least it does on my PC, Windows XP SP3, totally flicker free) - similar to DoubleBuffered form style on C, Delphi, etc... Maybe there is a way to set DoubleBuffered style on the window, but I couldn't find it's value -.- and 0x2000000 ($WS_EX_COMPOSITED) worked for me...
  9. The Sun is gonna hit the ground, the Sun is gonna fall from the sky!!! ...unless YOU help the mankind save the world... for at least some time... Move the mouse bellow the bouncing Sun and bounce it back into the sky. Each bounce will give you 8 points, if the ball hits the wall or the top of the window instead of 8 points you get 8, 16, 24... points (8 * wall/top hits). For full gameplay environment download Music/Sound files from here: BouncingSun+Music/Sound effects The game doesn't use GDI, it was made with drawing and moving shapes/graphics. If you feel like, you can post your best results here in this topic. Enjoy Here's a TIP: keep the Sun bouncing in the area of clouds, don't let it go bellow the clouds area Screen Shot of the game: ...and source: edit: added dynamic background #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinApi.au3> #include <Sound.au3> Opt("MouseCoordMode", 2) Opt("TrayIconHide", 1) Global $Save_File = @ScriptDir & "\Data\DATA.ini" if NOT FileExists($Save_File) then _Create_ini() Global Const $WS_EX_COMPOSITED = 0x2000000 Global $PosX = 0, $PosY = 0, $VelX = 0, $VelY = 0 Global $Gravity Global $CurMusic = 1, $Music1, $Music2 Global $TheBallIsDown = True, $Score = 0, $Tap_Counter = 1 Global $BallWidth = Number(IniRead($Save_File, "Options", "BallSize", "56")) Global $SpringWidth = Number(IniRead($Save_File, "Options", "SpringSize", "76")) Global $Highscore_key = IniRead($Save_File, "Top score", "score", "0/0") Global $Score_Multip = Number(IniRead($Save_File, "Options", "Score multiplier", "8")) Global $BallBounceHeight = Number(IniRead($Save_File, "Options", "Bounce height", "22")) Global $XAccelerate = Number(IniRead($Save_File, "Options", "Acceleration X", "40")) Global $OverAllSpeed = Number(IniRead($Save_File, "Options", "GameSpeed", "16")) Global $dynamicBackground = Number(IniRead($Save_File, "Options", "dynamicBackground", "1")) Global $Counter = 0, $BestResult = Number(StringLeft($Highscore_key, StringInStr($Highscore_key, "/")-1)) Global $Grass_move_timer = Random(100, 800, 1), $Grass_Current = 1, $Grass_Timer, $Cloud_Timer, $Cloud_move_timer = Random(100, 300, 1) Dim $Cloud_movement[10] $Form1 = GUICreate("Bounce The SUN - Keep the Sun from falling from the sky - by sandin", 640, 480+40, -1, -1, -1, $WS_EX_COMPOSITED) GUISetBkColor(0xBFE3FE) $Clouds = _Create_Clouds() $TheSpring = _Create_Sphere(0, 0, $SpringWidth, 15, 0x00477D) $TheBall = _Create_Sphere(0, 0, $BallWidth, $BallWidth, 0xFFFF00) GUICtrlSetState($TheSpring, $GUI_HIDE) GUICtrlSetState($TheBall, $GUI_HIDE) $Start_Button = GUICtrlCreateButton("S&tart", 640/2-150/2, 430, 150, 35) GUICtrlSetFont(-1, 14, 800, 2, "Arial") $MusicButton = GUICtrlCreateButton("Stop Music", 5, 490, 80, 25) $Grass = _Draw_ground_and_grass() $Result_label = GUICtrlCreateLabel("Press Start to play the game", 0, 260, 640, 80, 0x01) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 26, 800, 2, "Arial") $Hits_Label = GUICtrlCreateLabel("Hits: 0", 100, 490, 160, 30) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 18, 800, 2, "Arial") GUICtrlSetColor(-1, 0xFFF2CB) $Score_Label = GUICtrlCreateLabel("Score: 0", 220, 490, 160, 30) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 18, 800, 2, "Arial") GUICtrlSetColor(-1, 0xFFF2CB) $BestResult_Label = GUICtrlCreateLabel("Highscore: " & $Highscore_key, 380, 490, 340, 30) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 18, 800, 2, "Arial") GUICtrlSetColor(-1, 0xFFF2CB) $BounceSound = _SoundOpen(@ScriptDir & "\Data\Sound\Bounce.wav") $HitSound = _SoundOpen(@ScriptDir & "\Data\Sound\Hit.wav") $Music1 = _SoundOpen(@ScriptDir & "\Data\Music\Music01.mp3") $Music2 = _SoundOpen(@ScriptDir & "\Data\Music\Music02.mp3") GUISetState(@SW_SHOW) _SoundPlay($Music1) AdlibEnable("_The_Ball_Is_alive", $OverAllSpeed) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SoundClose($BounceSound) _SoundClose($HitSound) _SoundClose($Music1) _SoundClose($Music2) Exit Case $Start_Button $Score = 0 $Tap_Counter = 1 $Counter = 0 GUICtrlSetData($Score_Label, "Score: 0") GUICtrlSetData($Hits_Label, "Hits: 0") $TheBallIsDown = False _WinAPI_ShowCursor(False) $PosX = 640/2-$BallWidth/2 $PosY = 0 $VelX = Random(-22, 22, 1) $VelY = 0 $Gravity = Number(IniRead($Save_File, "Options", "Gravity", "1.0")) GUICtrlSetState($Result_label, $GUI_HIDE) GUICtrlSetState($TheSpring, $GUI_SHOW) GUICtrlSetState($Start_Button, $GUI_HIDE) GUICtrlSetState($TheBall, $GUI_SHOW) Case $MusicButton if GUICtrlRead($MusicButton) = "Stop Music" Then GUICtrlSetData($MusicButton, "Start Music") if $CurMusic = 1 Then _SoundStop($Music1) Else _SoundStop($Music2) EndIf Else GUICtrlSetData($MusicButton, "Stop Music") $CurMusic = Random(1, 2, 1) if $CurMusic = 1 Then _SoundPlay($Music1) Else _SoundPlay($Music2) EndIf EndIf EndSwitch Local $mouseMsg = GUIGetCursorInfo() if NOT @error then Local $Mouse_X = $mouseMsg[0]-$SpringWidth/2 Local $Mouse_Y = $mouseMsg[1]-15/2 _move_the_object_to($TheSpring, $Mouse_X, $Mouse_Y) EndIf if $dynamicBackground = 1 then if Random(0, 1, 1) = 0 then if TimerDiff($Grass_Timer) >= $Grass_move_timer Then if $Grass_Current = 1 then $Grass_Current = 2 _move_the_object_to($Grass, 1, 477) Else $Grass_Current = 1 _move_the_object_to($Grass, 0, 477) EndIf $Grass_move_timer = Random(100, 800, 1) $Grass_Timer = TimerInit() EndIf Else If TimerDiff($Cloud_Timer) >= $Cloud_move_timer Then $Cloud_move_timer = Random(100, 300, 1) $Cloud_Timer = TimerInit() _Move_Clouds() EndIf EndIf EndIf WEnd func _Create_ini() if NOT FileExists(@ScriptDir & "\Data") then DirCreate(@ScriptDir & "\Data") FileWrite($Save_File, "") IniWrite($Save_File, "Options", "Gravity", "1.0") IniWrite($Save_File, "Options", "Acceleration X", "40") IniWrite($Save_File, "Options", "Bounce height", "22") IniWrite($Save_File, "Options", "Score multiplier", "8") IniWrite($Save_File, "Options", "GameSpeed", "16") IniWrite($Save_File, "Options", "BallSize", "56") IniWrite($Save_File, "Options", "SpringSize", "76") IniWrite($Save_File, "Options", "dynamicBackground", "1") IniWrite($Save_File, "Top score", "Score", "0/0") EndFunc func _Create_Sphere($x, $y, $width, $height, $color) Local $sphere = GUICtrlCreateGraphic($x, $y, $width, $height) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $color) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $x, $y, $width, $height) Return $sphere EndFunc func _Create_Clouds() dim $Cloouuudd[10] for $i = 1 to 9 $Cloouuudd[$i] = GUICtrlCreateGraphic(Random(5, 505, 1), Random(5, 240, 1), 155, 35+25) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFFFFFF, 0xFFFFFF) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, Random(10, 35, 1), Random(15, 25, 1), Random(40, 90, 1), Random(25, 35, 1)) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, Random(0, 15, 1), Random(10, 20, 1), Random(40, 70, 1), Random(25, 35, 1)) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, Random(50, 60, 1), Random(10, 20, 1), Random(40, 95, 1), Random(25, 35, 1)) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, Random(10, 35, 1), Random(0, 15, 1), Random(40, 95, 1), Random(25, 35, 1)) $Cloud_movement[$i] = Random(0, 1, 1) Next if $dynamicBackground = 1 then $Cloud_Timer = TimerInit() Return $Cloouuudd EndFunc func _Draw_ground_and_grass() Local $grass_graph1 = GUICtrlCreateGraphic(0, 479, 640, 1) Local $Grass_move = GUICtrlCreateGraphic(0, 477, 640, 2) for $i = 1 to 640 step 6 GUICtrlSetGraphic($grass_graph1, $GUI_GR_COLOR, 0x00570C) GUICtrlSetGraphic($Grass_move, $GUI_GR_COLOR, 0x00570C) GUICtrlSetGraphic($grass_graph1, $GUI_GR_RECT, $i, 0, 3, 1) GUICtrlSetGraphic($Grass_move, $GUI_GR_RECT, $i, 0, 2, 2) Next GUICtrlCreateGraphic(0, 480+5, 640, 40-5) GUICtrlSetBkColor(-1, 0x3E2300) GUICtrlCreateGraphic(0, 480, 640, 5) GUICtrlSetBkColor(-1, 0x00570C) if $dynamicBackground = 1 then $Grass_Timer = TimerInit() Return $Grass_move EndFunc func _The_Ball_Is_Alive() _Apply_Gravity() $PosX += $VelX $PosY += $VelY if $PosX > 640 - $BallWidth Then $PosX = 640 - $BallWidth _Apply_Rebound() ElseIf $PosX < 0 Then $PosX = 0 _Apply_Rebound() EndIf if $PosY > 480 - $BallWidth Then $PosY = 480 - $BallWidth _Apply_Bounce() ElseIf $PosY < 0 Then $PosY = 0 _Apply_Bounce() EndIf _move_the_object_to($TheBall, $PosX, $PosY) if GUICtrlRead($MusicButton) = "Stop Music" then _Change_Music() if $TheBallIsDown = False then _Collision() EndFunc func _Move_Clouds() Local $i = Random(1, 9, 1) Local $Cloud_Pos = ControlGetPos($Form1, "", $Clouds[$i]) if $Cloud_movement[$i] = 0 then ;left if $Cloud_Pos[0] <= -$Cloud_Pos[2] Then _move_the_object_to($Clouds[$i], 640, $Cloud_Pos[1]) Else _move_the_object_to($Clouds[$i], $Cloud_Pos[0]-2, $Cloud_Pos[1]) EndIf else ;right if $Cloud_Pos[0] >= 640+$Cloud_Pos[2] Then _move_the_object_to($Clouds[$i], -$Cloud_Pos[2], $Cloud_Pos[1]) Else _move_the_object_to($Clouds[$i], $Cloud_Pos[0]+2, $Cloud_Pos[1]) EndIf EndIf EndFunc func _Change_Music() if $CurMusic = 1 Then if _SoundPos($Music1, 2) >= _SoundLength($Music1, 2)-10 Then _SoundStop($Music1) $CurMusic = 2 _SoundPlay($Music2) EndIf Else if _SoundPos($Music2, 2) >= _SoundLength($Music2, 2)-10 Then _SoundStop($Music1) $CurMusic = 1 _SoundPlay($Music1) EndIf EndIf EndFunc func _Collision() Local $MousePos = MouseGetPos() Local $Mouse_X = $MousePos[0] Local $Mouse_Y = $MousePos[1] if ($Mouse_X+$SpringWidth/2 > $PosX) AND ($Mouse_X-$SpringWidth/2 < $PosX+$BallWidth) AND ($Mouse_Y+15/2 > $PosY) AND ($Mouse_Y-15/2 < $PosY+$BallWidth) then $Counter += 1 GUICtrlSetData($Hits_Label, "Hits: " & $Counter) _SoundPlay($HitSound) $VelY = -$BallBounceHeight $VelX = ((($PosX+$BallWidth/2)-$Mouse_X)/(100/$XAccelerate) * (2-(2-1)*($BallWidth-10)/(56-10))) ;the last should result with 1 unless shrinking ball starts working, and thus increase X speed of the ball if $VelX = 0 then $VelX = (Random(-10, 10, 1)/10) $Score += $Score_Multip*$Tap_Counter $Tap_Counter = 1 GUICtrlSetData($Score_Label, "Score: " & $Score) ;~ if $BallWidth > 10 then ;failed attemt to create ball and spring to shrink every 3 hits due to graphic display bug ;~ if Mod($Counter, 3) = 0 Then ;~ $BallWidth -= 1 ;~ $SpringWidth -= 1 ;~ GUICtrlSetGraphic($TheBall, $GUI_GR_ELLIPSE, 0, 0, $BallWidth, $BallWidth) ;~ GUICtrlSetGraphic($TheSpring, $GUI_GR_ELLIPSE, 0, 0, $SpringWidth, 15) ;~ GUICtrlSetData($BallSize_Label, "Size: " & $BallWidth) ;~ EndIf ;~ EndIf EndIf EndFunc func _Set_the_object_size($object, $dimension) GUICtrlSetGraphic($object, $GUI_GR_ELLIPSE, 0, 0, $dimension, $dimension) EndFunc func _move_the_object_to($object, $x, $y) GUICtrlSetPos($object, $x, $y) EndFunc func _Apply_Gravity() $VelY += $Gravity EndFunc func _Apply_Bounce() if Round($VelY) > 1 Then _SoundPlay($BounceSound) if $VelY > 0 Then $VelY *= (-0.85) if $TheBallIsDown = false Then _WinAPI_ShowCursor(True) $TheBallIsDown = True GUICtrlSetData($Start_Button, "&Try again") GUICtrlSetState($TheSpring, $GUI_HIDE) GUICtrlSetState($Start_Button, $GUI_SHOW) Local $show_result = "You score " & $Score & " points with " & $Counter & " hits" if $Score > $BestResult then $BestResult = $Score $show_result &= @CRLF & "AND You beat the highscore!" GUICtrlSetData($BestResult_Label, "Highscore: " & $Score & "/" & $Counter) IniWrite($Save_File, "Top score", "Score", $Score & "/" & $Counter) EndIf GUICtrlSetData($Result_label, $show_result) GUICtrlSetState($Result_label, $GUI_SHOW) EndIf Else $Tap_Counter += 1 _SoundPlay($BounceSound) $VelY *= (-1.0) EndIf $VelX *= 0.92 if Abs($VelX) < 1 Then $VelX = 0 if Abs($VelY) < 1 then $VelY = 0 EndFunc func _Apply_Rebound() $Tap_Counter += 1 _SoundPlay($BounceSound) $VelX *= (-0.9) if Abs($VelX) < 1 then $VelX = 0 EndFunc
  10. ...right... but why would u want to change entire windows style when you can change only 1 single control into classic style
  11. it is possible, but only in it's plain style, any other theme/style will disable it's ability to change colors, in order to set the progress as plain style, try this: DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($progressbar1), "wstr", 0, "wstr", 0) GUICtrlSetStyle($progressbar1, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH));doesn't have to be smooth, but I personally like this better and here's the full code: #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m GUICreate("My GUI Progressbar", 220, 100, 100, 200) $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20, -1, $WS_EX_WINDOWEDGE) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) GUICtrlSetStyle($progressbar1, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH)) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0) GUICtrlSetStyle($progressbar2, BitOr($GUI_SS_DEFAULT_PROGRESS, $PBS_SMOOTH)) GUICtrlSetColor(-1, 0x000000) ; Black GUICtrlSetBkColor(-1, 0xC2C2C2) ; Gray $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() $wait = 20; wait 20ms for next progressstep $s = 0; progressbar-saveposition Do $msg = GUIGetMsg() If $msg = $button Then GUICtrlSetData($button, "Stop") For $i = $s To 100 If GUICtrlRead($progressbar1) = 50 Then MsgBox(0, "Info", "The half is done...", 1) $m = GUIGetMsg() If $m = -3 Then ExitLoop If $m = $button Then GUICtrlSetData($button, "Next") $s = $i;save the current bar-position to $s ExitLoop Else $s = 0 GUICtrlSetData($progressbar1, $i) GUICtrlSetData($progressbar2, (100 - $i)) Sleep($wait) EndIf Next If $i > 100 Then ; $s=0 GUICtrlSetData($button, "Start") EndIf EndIf Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example
  12. first of all, many tnx to Bytencoder from Softpedia forum, he revealed his secret of intercepting Winfast PVR remote control keys. If you give any credit to this script it all goes to his nickname ;] The following script was made to intercept remote control keys from your WinFast PVR application. If you have Leadtek TV card, or WinFast PVR application, and remote control, you might find this useful, you could turn your TV card remote control into ultimate, distant PC control device. Please read the first few lines of the script, and choose first global variable, if you have WinFast PVR1, then use: Global $class = "Alec@Video(^0^)" if you have WinFast PVR2 or higher, then use: Global $class = "Alec@DVBT(>_<)" Also, this script was made tnx to register class function: http://www.autoitscript.com/forum/index.php?showtopic=79575 #Include <WinAPI.au3> #Include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> ;choose the class which depends on your PVR you're using. PVR1 = "Alec@Video(^0^)", PVR2 and higher = "Alec@DVBT(^_^)" ;~ Global $class = "Alec@Video(^0^)" ;for pvr1 Global $class = "Alec@DVBT(^_^)" ;for pvr2 and up Global $enabled = true Global Const $CS_VREDRAW = 0x0001; Global Const $CS_HREDRAW = 0x0002; Global Const $CS_DBLCLKS = 0x0008; Global Const $CS_OWNDC = 0x0020; Global Const $CS_CLASSDC = 0x0040; Global Const $CS_PARENTDC = 0x0080; Global Const $CS_NOCLOSE = 0x0200; Global Const $CS_SAVEBITS = 0x0800; Global Const $CS_BYTEALIGNCLIENT = 0x1000; Global Const $CS_BYTEALIGNWINDOW = 0x2000; Global Const $CS_GLOBALCLASS = 0x4000; Global Const $CS_DROPSHADOW = 0x00020000; Global Const $CS_DEFAULTSTYLE = BitOR($CS_VREDRAW, $CS_HREDRAW) Global Const $CW_USEDEFAULT = 0x80000000 ;#CS Global Const $CURSOR_ARROW =32512 Global Const $CURSOR_IBEAM =32513 Global Const $CURSOR_WAIT =32514 Global Const $CURSOR_CROSS =32515 Global Const $CURSOR_UPARROW =32516 Global Const $CURSOR_SIZENWSE =32642 Global Const $CURSOR_SIZENESW =32643 Global Const $CURSOR_SIZEWE =32644 Global Const $CURSOR_SIZENS =32645 Global Const $CURSOR_SIZEALL =32646 Global Const $CURSOR_NO =32648 Global Const $CURSOR_APPSTARTING =32650 Global Const $CURSOR_HELP =32651 ;#CE _WinAPI_RegisterClassEx($class, "WindowCallback", 0, 0, -1, $CS_DEFAULTSTYLE) ;registering window class which is designed to recieve PVR's remote ctrl commands, and setting up a func. for hooking msges from that class (this last require a window, that's why we have next line) $hWnd = _WinAPI_CreateWindowEx(0, $class, "REMOTE CONTROL", $WS_OVERLAPPEDWINDOW, @DesktopWidth+500, @DesktopHeight+500, 0, 0, 0) ;creating a window with registered class (required, but doesn't need to be shown) $gui = GUICreate("test", 400, 300) ;creating main GUI $button1 = GUICtrlCreateButton("Disable", 10, 10, 100) ;button for disabling/enabling keys intercepting (actually, registering and unregistering required window's class $display_label = GUICtrlCreateLabel("", 10, 50, 380, 20, 0x01) ;label for displaying keys you stroke on your remote ctrl. GUICtrlSetFont(-1, 12, 800, -1, "Arial") GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg($gui) Switch $nMsg case $button1 if $enabled = true Then GUICtrlSetData($button1, "Enable") $enabled = false _WinAPI_UnregisterClass($class) ;unregistering class and... _WinAPI_DestroyWindow($hWnd) ;...killing window with registered class $hWnd = 0 Else GUICtrlSetData($button1, "Disable") $enabled = true _WinAPI_RegisterClassEx($class, "WindowCallback", 0, 0, -1, $CS_DEFAULTSTYLE) ;just like @ the top of the script $hWnd = _WinAPI_CreateWindowEx(0, $class, "REMOTE CONTROL", $WS_OVERLAPPEDWINDOW, @DesktopWidth+500, @DesktopHeight+500, 0, 0, 0) EndIf Case $GUI_EVENT_CLOSE _WinAPI_UnregisterClass($class) Exit EndSwitch Sleep(10) WEnd Func _WinGetClassName($hWnd) $x = DLLCall("user32.dll","int","GetClassName","hWnd",$hWnd,"str","","int",64) ;getting classname of a window If Not @error And $x[0] <> 0 Then Return $x[2] Return "" EndFunc Func WindowCallback($hWnd, $iMsg, $wParam, $lParam) ;callback func. for recieving msges Switch $iMsg Case $WM_CLOSE _WinAPI_UnregisterClass($class) Exit EndSwitch Switch $wParam ;set your functions here: (this is the part that recognize your remote ctrl keys) case 0 if $iMsg = 2560 Then GUICtrlSetData($display_label, "Power") EndIf case 1 ;dunno case 2 ;dunno case 3 GUICtrlSetData($display_label, "Full screen") case 4 GUICtrlSetData($display_label, "Vol +") case 5 GUICtrlSetData($display_label, "Ch. 1") case 6 GUICtrlSetData($display_label, "Ch. 2") case 7 GUICtrlSetData($display_label, "Ch. 3") case 8 GUICtrlSetData($display_label, "Vol -") case 9 GUICtrlSetData($display_label, "Ch. 4") case 10 GUICtrlSetData($display_label, "Ch. 5") Case 11 GUICtrlSetData($display_label, "Ch. 6") case 12 GUICtrlSetData($display_label, "Ch. UP") case 13 GUICtrlSetData($display_label, "Ch. 7") case 14 GUICtrlSetData($display_label, "Ch. 8") Case 15 GUICtrlSetData($display_label, "Ch. 9") case 16 GUICtrlSetData($display_label, "Ch. Down") case 17 GUICtrlSetData($display_label, "Switch to previous") case 18 GUICtrlSetData($display_label, "Ch. 0") case 19 GUICtrlSetData($display_label, "Enter") case 20 GUICtrlSetData($display_label, "Mute") case 22 GUICtrlSetData($display_label, "Display") case 27 GUICtrlSetData($display_label, "Audio") case 30 GUICtrlSetData($display_label, "Video") case 31 GUICtrlSetData($display_label, "Teletext") case 64 GUICtrlSetData($display_label, "Sleep") case 65 GUICtrlSetData($display_label, ". (Dot)") case 66 GUICtrlSetData($display_label, "Previous") case 67 GUICtrlSetData($display_label, "Play/Pause") case 68 GUICtrlSetData($display_label, "Next") case 69 GUICtrlSetData($display_label, "Time Shifting") case 70 GUICtrlSetData($display_label, "Stop") case 71 GUICtrlSetData($display_label, "Rec") case 72 GUICtrlSetData($display_label, "(M) SnapShot") case 73 GUICtrlSetData($display_label, "Boss Key") case 74 GUICtrlSetData($display_label, "Pic. in Pic.") case 75 GUICtrlSetData($display_label, "Red color") case 76 GUICtrlSetData($display_label, "Green color") case 77 GUICtrlSetData($display_label, "Yellow color") case 78 GUICtrlSetData($display_label, "Blue color") case 79 GUICtrlSetData($display_label, "Menu") case 80 GUICtrlSetData($display_label, "Cancel") case 81 GUICtrlSetData($display_label, "Chan. Surf") case 82 GUICtrlSetData($display_label, "[...]") case 83 GUICtrlSetData($display_label, "EPG") case 84 GUICtrlSetData($display_label, "Backward") case 85 GUICtrlSetData($display_label, "Forward") case 1011 ;DVD or sometimes FM, so disable and not use is the best solution case Else GUICtrlSetData($display_label, "key for case: " & @CRLF & $wParam & @CRLF & "is not defined...") EndSwitch Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;---------------------------------------------------------------------------------------- ; register class function and it's details/authors shown below ; link: http://www.autoitscript.com/forum/index.php?showtopic=79575 ;---------------------------------------------------------------------------------------- #cs _WinAPI_RegisterClassEx($sClassName, $sCallbackFunction, $hIcon=0, $hCursor=0, $iBkColor=$COLOR_BTNFACE, $iStyle=$CS_DEFAULTSTYLE) $sClassName - Classname $sCallbackFunction - WindowProc callback function $hIcon - Handle to a icon which will be be used as the window icon (Default = application icon) $hCursor - Handle to cursor which will be used as the window cursor (Default = arraow cursor) Use _WinAPI_LoadCursor() [also included with this UDF] to load a system cursor: $CURSOR_ARROW $CURSOR_IBEAM $CURSOR_WAIT $CURSOR_CROSS $CURSOR_UPARROW $CURSOR_SIZENWSE $CURSOR_SIZENESW $CURSOR_SIZEWE $CURSOR_SIZENS $CURSOR_SIZEALL $CURSOR_NO $CURSOR_APPSTARTING $CURSOR_HELP Example: _WinAPI_LoadCursor(0, $CURSOR_IBEAM) Do not use the $IDC_ constants declared in Constants.au3 $iBkColor - RGB color code of window background color $iStyle - Class style. A combination of these values: (Default = $CS_DEFAULTSTYLE) $CS_VREDRAW $CS_HREDRAW $CS_DBLCLKS $CS_OWNDC $CS_CLASSDC $CS_PARENTDC $CS_NOCLOSE $CS_SAVEBITS $CS_BYTEALIGNCLIENT $CS_BYTEALIGNWINDOW $CS_GLOBALCLASS $CS_DROPSHADOW Function: Creating a class which can be used with CreateWindowEx, and others Author: Original - amel27 Working version - Kip #ce Func _WinAPI_RegisterClassEx($sClassName, $sCallbackFunction="", $hIcon=0, $hCursor=0, $iBkColor=$COLOR_BTNFACE, $iStyle=$CS_DEFAULTSTYLE) If not $hIcon Then Local $aIcon = DllCall("user32.dll", "hwnd", "LoadIcon", "hwnd", 0, "int", $IDI_APPLICATION) $hIcon = $aIcon[0] EndIf If not $hCursor Then $hCursor = _WinAPI_LoadCursor(0,$CURSOR_ARROW) EndIf local $hWndProc = DLLCallbackRegister ($sCallbackFunction, "int", "hwnd;int;wparam;lparam") Local $pCallback = DllCallbackGetPtr($hWndProc) Local $tWndClassEx = DllStructCreate("uint cbSize;uint style;ptr lpfnWndProc;int cbClsExtra;int cbWndExtra;hwnd hInstance;hwnd hIcon;hwnd hCursor;hwnd hbrBackground;ptr lpszMenuName;ptr lpszClassName;hwnd hIconSm") Local $tClassName = DllStructCreate("char["& StringLen($sClassName)+1 &"]") DllStructSetData($tClassName, 1, $sClassName) DllStructSetData($tWndClassEx, "cbSize", DllStructGetSize($tWndClassEx) ) DllStructSetData($tWndClassEx, "style", $iStyle) DllStructSetData($tWndClassEx, "lpfnWndProc", $pCallback) DllStructSetData($tWndClassEx, "hInstance", _WinAPI_GetModuleHandle("")) DllStructSetData($tWndClassEx, "hIcon", $hIcon) DllStructSetData($tWndClassEx, "hCursor", $hCursor) DllStructSetData($tWndClassEx, "hbrBackground", _WinAPI_CreateSolidBrush(RGB_to_BGR($iBkColor))) DllStructSetData($tWndClassEx, "lpszClassName", DllStructGetPtr($tClassName)) DllStructSetData($tWndClassEx, "hIconSm", $hIcon) Local $aRet = DllCall("user32.dll", "dword", "RegisterClassExA", "ptr", DllStructGetPtr($tWndClassEx) ) Return $aRet[0] EndFunc Func _WinAPI_UnregisterClass($sClassName) Local $aRet = DllCall("user32.dll", "int", "UnregisterClassA", "str", $sClassName, "hwnd", _WinAPI_GetModuleHandle("")) Return $aRet[0] EndFunc Func _WinAPI_LoadCursor($hInstance, $iCursor) $GuiCursor = DllCall("user32.dll", "hwnd", "LoadCursor", "hwnd", $hInstance, "int", $iCursor) Return $GuiCursor[0] EndFunc Func RGB_to_BGR($BRG) $b = BitAND(BitShift($BRG, 16), 0xFF) $g = BitAND(BitShift($BRG, 8), 0xFF) $r = BitAND($BRG, 0xFF) Return "0x"&Hex($r,2)&Hex($g,2)&Hex($b,2) EndFunc ...would be great if some leadtek TV card owners could test ;]
  13. Even though regular toolbar is more useful and easier to use, this is something made just for appearance. When you move your mouse on the edge of the window, or 100px left or right from the window (while window is active) toolbar will slide, and allow you to have more toolbar icons in less space. There are two known bugs: - After restoring window from minimized state, GDI+ disappear, though this can be fixed through WM_PAINT - For some strange reason, when you move your mouse to the right (then slider is going to the left), and after a while when you move your mouse left (then slider is going to the right) but only a little bit, so the slider is moving slowly, then I have some image displacement and flickering (but only for the first few icons), it might have something to do with the math of image movement, but it's working fine on the other side (and the math is similar) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GDIPlus.au3> #Include <Misc.au3> #Include <GuiEdit.au3> _GDIPlus_Startup() Opt("OnExitFunc", "endscript") ;func @ exiting script dim $icons[10] ;number of icons used dim $icon_info[10][6] ;number of icons used and their information global $shell32 = @SystemDir & "\shell32.dll" ;shell32.dll location, the file for icon extraction Global $cur_first = 0, $cur_last = 9, $moving = False, $timer_10, $hGraphic, $timer_end_txt, $inside = False ;some global variables $timer_10 = TimerInit() ;this timer is limiting sliding to max speed of 10ms/px $timer_end_txt = TimerInit() ;this timer is used for toolbar label to vanish (check While 1 section) _set_icon_info() ;setting icons info, check the function for detail info $Form1 = GUICreate("pr0 toolbar #1", 253, 300) ;gui creation GUISetBkColor(0) ;gui black background color GUICtrlCreateGroup("", 12, 76, 229, 212) ;group around edit $Edit1 = GUICtrlCreateEdit("Click any icon in the toolbar...", 15, 85, 223, 200, $WS_VSCROLL+0x0040+0x0004+0x1000) ;edit control to display icons clicking GUICtrlSetBkColor(-1, 0x333333) ;gray background of edit ctrl GUICtrlSetColor(-1, 0xFFFFFF) ;white letters inside of edit ctrl GUICtrlSetFont(-1, 8, 400, -1, "Arial") ;arial font for edit ctrl GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group $toolbar_display_txt = GUICtrlCreateLabel("", 10, 49+7, 233, 17, 0x01) ;label to display curent selected toolbar icon with "CENTER" style = 0x01 GUICtrlSetColor(-1, 0xFFFFFF) ;above label color is white GUICtrlSetFont(-1, 12, 800, 2, "Arial") ;above label's font = arial, 800=bold WinSetTrans($form1, "", 255) ;setting transp to 255 (max) will make GDI always visible (without disappearing when moved on the edge of the desktop, or when overlaped by another window ;note - must be before declaring graphic GDI in order for this to work $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) ;creating graphic for drawing toolbar icons _extract_icons() ;extracting icons from shell32.dll, check func for detail info GUISetState(@SW_SHOW, $form1) ;display main GUI $stemp = GUICreate("", 30, 14, 185, 293, BitOR($WS_POPUP, $WS_CHILD), $WS_EX_MDICHILD, $Form1) ;just another trick-window to make CLEAR label inside of main window's EDIT, pretty neat ;) WinSetTrans($stemp, "", 255) ;setting trans to 255 to clear bugs when moving main window GUISetBkColor(0x333333) ;background color is the same as EDIT in main window $clear_label = GUICtrlCreateLabel("clear", 0, 0, 30, 14, 0x01) ;clear label with "CENTER" style = 0x01 GUICtrlSetCursor(-1, 0) ;"finger" cursor on this label above GUICtrlSetColor(-1, 0xFF0000) ;red color label GUICtrlSetFont(-1, 8, 400, -1, "Arial") ;arial font for edit ctrl GUISetState(@SW_SHOW, $stemp) ;display clear label inside of edit control for $i = 0 to 4 _GDIPlus_GraphicsDrawImageRect($hGraphic, $icons[$i], $icon_info[$i][3], 15, 32, 32) ;drawing first 4 icons into GDI (window) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $clear_label ;edit label in the "trick" child-window inside of EDIT control GUICtrlSetData($Edit1, "") EndSwitch Local $c = GUIGetCursorInfo($Form1) ;get mouse location inside of GUI Local $x_coord = $c[0] ;mouse x coordinate inside of GUI Local $y_coord = $c[1] ;mouse y coordinate isnide of GUI if $y_coord < 52 AND $y_coord > 0 AND WinActive($Form1) Then ;top and bottom coordinate of toolbar if TimerDiff($timer_10) >= 10 then ;sliding is chaotic if there is no speed limitation, 10ms in this case is just enough $timer_10 = TimerInit() Switch $x_coord case -100 to 41 ;left corner - moving icons to the right $inside = true ;is mouse inside of sliding area? yes! _shrink_all() ;if there is any icon that is enlarged, it'll be decreased $moving = true ;is slider mooving? yes! Local $speed Local $x_coord1 = $x_coord if $x_coord1 < 0 then $x_coord1 = 0 ;if this isn't limited to 0 then the speed would continue to increase if the mouse is outside (but near) window EndIf $speed = int(((41-$x_coord1)/15)^2) ;acceleration and speed of sliding icons is increased parabolical, and not linear, that's why ^2 if $speed < 1 then $speed = 1 ;min speed should be 1px for $i = 0 to 9 $icon_info[$i][3] += $speed ;changing x starting coordinate for each icon $icon_info[$i][4] += $speed ;changing x starting coordinate for each icon if Int($icon_info[$cur_first][3]) >= 25 Then ;this is where last icon become first Local $previous = $cur_first $cur_first -= 1 if $cur_first < 0 then $cur_first = 9 $icon_info[$cur_first][3] = int($icon_info[$previous][3]) - 57 $icon_info[$cur_first][4] = int($icon_info[$previous][4]) - 57 EndIf if $icon_info[$i][3] < 253+25 then ;icons that aren't visible shouldn't move at all (and thus save pc resources) Local $width_x = 10 _GDIPlus_GraphicsFillRect($hGraphic, $icon_info[$i][4], 15, $width_x, 32);Right side filling black line _GDIPlus_GraphicsDrawImageRect($hGraphic, $icons[$i], $icon_info[$i][3], 15, 32, 32);icon image _GDIPlus_GraphicsFillRect($hGraphic, $icon_info[$i][3]-$width_x, 15, $width_x, 32);Left side filling black line EndIf Next case 212 to 253+100 ;right corner - moving to the left $inside = true _shrink_all() $moving = true Local $speed Local $x_coord1 = $x_coord if $x_coord1 > 253 then $x_coord1 = 253 EndIf $speed = Int((($x_coord1-212)/15)^2) if $speed < 1 then $speed = 1 for $i = 0 to 9 $icon_info[$i][3] -= $speed $icon_info[$i][4] -= $speed if int($icon_info[$cur_last][3]) <= 228 Then ;this is where first icon become last Local $previous = $cur_last $cur_last += 1 if $cur_last > 9 then $cur_last = 0 $icon_info[$cur_last][3] = int($icon_info[$previous][3]) + 57 $icon_info[$cur_last][4] = int($icon_info[$previous][4]) + 57 EndIf if $icon_info[$i][4]+25 > 0 then Local $width_x = 10 _GDIPlus_GraphicsFillRect($hGraphic, $icon_info[$i][3]-$width_x, 15, $width_x, 32);Left side filling black line _GDIPlus_GraphicsDrawImageRect($hGraphic, $icons[$i], $icon_info[$i][3], 15, 32, 32) _GDIPlus_GraphicsFillRect($hGraphic, $icon_info[$i][4], 15, $width_x, 32);Right side filling black line EndIf Next case Else $moving = False if $inside = True Then $inside = False Local $founded = 10 for $i = 0 to 9 if $icon_info[$i][2] = True Then $founded = $i ExitLoop EndIf Next if $founded <> 10 then if $icon_info[$founded][5] = false Then _easy_rise($icons[$founded], $icon_info[$founded][3]-2, 12, 37, 37) $icon_info[$founded][5] = true EndIf EndIf EndIf EndSwitch EndIf switch $x_coord case $icon_info[0][3]-5 to $icon_info[0][4]+5 ;1st icon, mouse is hovering above 1st icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(0) case $icon_info[1][3]-5 to $icon_info[1][4]+5 ;2nd icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(1) case $icon_info[2][3]-5 to $icon_info[2][4]+5 ;3rd icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(2) case $icon_info[3][3]-5 to $icon_info[3][4]+5 ;4th icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(3) case $icon_info[4][3]-5 to $icon_info[4][4]+5 ;5th icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(4) case $icon_info[5][3]-5 to $icon_info[5][4]+5 ;6th icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(5) case $icon_info[6][3]-5 to $icon_info[6][4]+5 ;7th icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(6) case $icon_info[7][3]-5 to $icon_info[7][4]+5 ;8th icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(7) case $icon_info[8][3]-5 to $icon_info[8][4]+5 ;9th icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(8) case $icon_info[9][3]-5 to $icon_info[9][4]+5 ;10th icon if $x_coord >= 0 AND $x_coord <= 253 then _for_icon(9) case Else _shrink_all() EndSwitch Else _shrink_all() EndIf if Round(TimerDiff($timer_end_txt)) >= 500 then GUICtrlSetData($toolbar_display_txt, "") ;if mouse wasn't hovering above any icon for 0.5sec, display txt should vanish if WinActive($stemp) then WinActivate($form1) ;if the child window with label "clear" inside of EDIT ctrl is active, then main window should activate and set as current WEnd func _for_icon($number) $timer_end_txt = TimerInit() ;timer for vanishing txt label that display txt of curent icon if $icon_info[$number][2] = False then ;prevent constant shrinking and enlarging GUICtrlSetData($toolbar_display_txt, $icon_info[$number][1]) ;set label txt to curent icon info if $moving = False then ;if the slider isn't moving then it's OK to resize icons _shrink_all() _easy_rise($icons[$number], $icon_info[$number][3]-2, 12, 37, 37) ;should enlarge selected icon $icon_info[$number][5] = true ;setting the curent icon as enlarged EndIf $icon_info[$number][2] = True ;setting the curent icon as selected EndIf If _IsPressed(01) then ;if mouse click is down on the selected icon if $icon_info[$number][5] = false Then _easy_rise($icons[$number], $icon_info[$number][3]-2, 12, 37, 37) $icon_info[$number][5] = true EndIf Do Until NOT _IsPressed(01) ;waiting for mouse key to release (like on regular buttons) Local $c = GUIGetCursorInfo($Form1) Local $x_coord = $c[0] Local $y_coord = $c[1] if $x_coord > $icon_info[$number][3]-5 AND $x_coord < $icon_info[$number][4]+5 AND $y_coord < 42 AND $y_coord > 0 AND WinActive($Form1) Then ;if the mouse click is released while cursor was still on that icon and while GUI is active... Switch $number case 0 ;func for icon 1 _GUICtrlEdit_AppendText($Edit1, @CRLF & "1st Icon Clicked - " & $icon_info[0][1]) ;edit this, and set any function you want to be called when you hit 1st icon case 1 ;func for icon 2 _GUICtrlEdit_AppendText($Edit1, @CRLF & "2nd Icon Clicked - " & $icon_info[1][1]) case 2 ;func for icon 3 _GUICtrlEdit_AppendText($Edit1, @CRLF & "3rd Icon Clicked - " & $icon_info[2][1]) case 3 ;func for icon 4 _GUICtrlEdit_AppendText($Edit1, @CRLF & "4th Icon Clicked - " & $icon_info[3][1]) case 4 ;func for icon 5 _GUICtrlEdit_AppendText($Edit1, @CRLF & "5th Icon Clicked - " & $icon_info[4][1]) case 5 ;func for icon 6 _GUICtrlEdit_AppendText($Edit1, @CRLF & "6th Icon Clicked - " & $icon_info[5][1]) case 6 ;func for icon 7 _GUICtrlEdit_AppendText($Edit1, @CRLF & "7th Icon Clicked - " & $icon_info[6][1]) case 7 ;func for icon 8 _GUICtrlEdit_AppendText($Edit1, @CRLF & "8th Icon Clicked - " & $icon_info[7][1]) case 8 ;func for icon 9 _GUICtrlEdit_AppendText($Edit1, @CRLF & "9th Icon Clicked - " & $icon_info[8][1]) case 9 ;func for icon 10 _GUICtrlEdit_AppendText($Edit1, @CRLF & "10th Icon Clicked - " & $icon_info[9][1]) EndSwitch EndIf EndIf EndFunc func _shrink_all() for $i = 0 to 9 if $icon_info[$i][2] = True Then ;if icon is selected if $icon_info[$i][5] = True then ;if icon is enlarged _easy_shrink($icons[$i], $icon_info[$i][3], 15, 32, 32) $icon_info[$i][5] = False EndIf $icon_info[$i][2] = false EndIf Next EndFunc func _easy_rise($immmmage, $iX, $iY, $iW, $iH, $maxxx=6, $step = 1) ;image to be resized, x-coord of the image, y-coord of the image, width of the image, height of the image, max enlargement, speed of enlargement for $i = 1 to $maxxx Step $step _GDIPlus_GraphicsDrawImageRect($hGraphic, $immmmage, $iX-$i, $iY-$i, $iW+2*$i, $iH+2*$i) ;enlarging icon Sleep(1) ;making it smooth Next EndFunc func _easy_shrink($immmmage, $iX, $iY, $iW, $iH, $maxxx=6, $step = 1) Local $cntr = 0 for $i = $maxxx to 1 Step -$step _GDIPlus_GraphicsDrawImageRect($hGraphic, $immmmage, $iX-$i, $iY-$i, $iW+2*$i, $iH+2*$i) ;shrinking icon _GDIPlus_GraphicsFillRect($hGraphic, $iX-$i-$step-3, $iY-$i-$step, $step+3, $iH+2*$i+2*$step);black goes Left _GDIPlus_GraphicsFillRect($hGraphic, $iX-$i+$iW+2*$i-$step+1, $iY-$i-$step, $step+3, $iH+2*$i+2*$step);black goes Right _GDIPlus_GraphicsFillRect($hGraphic, $iX-$i-$step-3, $iY-$i-$step-3, $iW+2*$i+($step+3)*2, $step+3);black goes Above _GDIPlus_GraphicsFillRect($hGraphic, $iX-$i-$step-3, $iY-$i+$iH+2*$i, $iW+2*$i+($step+3)*2, $step+3);black goes Bellow $cntr = $i Sleep(1) Next if $iW+2*$cntr <> $iW OR $iH+2*$cntr <> $iH then ;if shrinking didn't went to the exact size it was supposed to, this will make it regular size again _GDIPlus_GraphicsDrawImageRect($hGraphic, $immmmage, $iX, $iY, $iW, $iH) ;drawing icon @ it's original size _GDIPlus_GraphicsFillRect($hGraphic, $iX-$step-3, $iY, $step+3, $iH);Left _GDIPlus_GraphicsFillRect($hGraphic, $iX+$iW, $iY, $step+3, $iH);Right _GDIPlus_GraphicsFillRect($hGraphic, $iX-$step-3, $iY-$step-3, $iW+2*($step+3), $step+3);Above _GDIPlus_GraphicsFillRect($hGraphic, $iX-$step-3, $iY+$iH, $iW+2*($step+3), $step+3);Bellow EndIf EndFunc func _extract_icons() for $i = 0 to 9 Local $Ret = DllCall("shell32","long","ExtractAssociatedIcon","int",0,"str",$shell32,"int*",(-1*$icon_info[$i][0])-1) ;extract icon from file Local $hIcon = $Ret[0] ;icon's handle Local $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromHICON", "ptr",$hIcon, "int*",0) ;create bitmap from icon's handle _GDIPlus_ImageSaveToFile($pBitmap[2],@ScriptDir & "\test_image" & $i & ".bmp") ;why am I saving it instead of using it's handle? Using it's handle will make parts around icon transparent, _GDIPlus_ImageDispose($pBitmap[2]) ; thus ruining resize/select mode, but saving it as image will fill up the transparent parts with black color $icons[$i] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test_image" & $i & ".bmp") ;and now loading this file _WinAPI_DestroyIcon($Ret[0]) ;and clearing resources by destroying icon's handle we don't need anymore... Next EndFunc func _set_icon_info() ;icon value: $icon_info[0][0] = "-13"; = memory $icon_info[1][0] = "-204"; = Camera $icon_info[2][0] = "-197"; = Phone $icon_info[3][0] = "-131"; = MS Live $icon_info[4][0] = "-166"; = Gear $icon_info[5][0] = "-172"; = Search $icon_info[6][0] = "-169"; = Sound $icon_info[7][0] = "-171";= MSN $icon_info[8][0] = "-200"; = HDD $icon_info[9][0] = "-201"; = PDA ;icon name: $icon_info[0][1] = "Memory"; = memory $icon_info[1][1] = "Camera"; = Camera $icon_info[2][1] = "Phone"; = Phone $icon_info[3][1] = "MS Live"; = MS Live $icon_info[4][1] = "Gear"; = Gear $icon_info[5][1] = "Search"; = Search $icon_info[6][1] = "Sound"; = Sound $icon_info[7][1] = "MSN";= MSN $icon_info[8][1] = "HDD"; = HDD $icon_info[9][1] = "PDA"; = PDA ;icon hover: $icon_info[0][2] = False; = memory $icon_info[1][2] = False; = Camera $icon_info[2][2] = False; = Phone $icon_info[3][2] = False; = MS Live $icon_info[4][2] = False; = Gear $icon_info[5][2] = False; = Search $icon_info[6][2] = False; = Sound $icon_info[7][2] = False;= MSN $icon_info[8][2] = False; = HDD $icon_info[9][2] = False; = PDA ;icon enlarged: $icon_info[0][5] = False; = memory $icon_info[1][5] = False; = Camera $icon_info[2][5] = False; = Phone $icon_info[3][5] = False; = MS Live $icon_info[4][5] = False; = Gear $icon_info[5][5] = False; = Search $icon_info[6][5] = False; = Sound $icon_info[7][5] = False;= MSN $icon_info[8][5] = False; = HDD $icon_info[9][5] = False; = PDA ;icon start/end coordinate x: Local $x_x = 0 for $i = 0 to 9 $x_x += 25 $icon_info[$i][3] = $x_x ; = start X coordinate $x_x += 32 $icon_info[$i][4] = $x_x ; = end X coordinate Next EndFunc func endscript() ;clearing resources @ the and of the script _GDIPlus_GraphicsDispose($hGraphic) for $i = 0 to 9 _GDIPlus_ImageDispose($icons[$i]) FileDelete(@ScriptDir & "\test_image" & $i & ".bmp") Next _GDIPlus_Shutdown() EndFunc
  14. great results, I'm glad u've added the "-" and "," support, very useful application you made it would be great if you could add support for like AxA matrix (not only 4x4 max), and add the support for at least 4-5 extra numbers (5 just isn't enough, especially when you use "-" in front of the numbers). smth like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $last_matr = 4 While 1 _ispocetka() WEnd func _ispocetka() Local $velicina_matrice = _matrica_get_count() if $velicina_matrice <> 0 AND $velicina_matrice <> 1 then _prikazi_matricu($velicina_matrice) EndFunc func _matrica_get_count() Local $return_val Local $iform_x = GUICreate("Matrix dimensions", 200, 60) Local $iInput_x = GUICtrlCreateInput($last_matr, 120, 3, 70, 20, 0x2000) GUICtrlSetLimit(-1, 99, 1) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 2, 1) GUICtrlCreateLabel("Input matrix dimension", 10, 7, 105, 17) Local $ok_button = GUICtrlCreateButton("OK", 10, 30, 85, 20) Local $canc_button = GUICtrlCreateButton("Cancel", 105, 30, 85, 20) GUISetState(@SW_SHOW, $iform_x) While 1 Local $iMsg = GUIGetMsg() Switch $iMsg case $GUI_EVENT_CLOSE, $canc_button Exit case $ok_button, $iInput_x $return_val = GUICtrlRead($iInput_x) GUIDelete($iform_x) ExitLoop EndSwitch WEnd $last_matr = $return_val Return $return_val EndFunc func _prikazi_matricu($velicina_matrice) Local $x_coord = 10, $y_coord = 10 Local $Form1 = GUICreate("Matrix", $velicina_matrice*69+200, $velicina_matrice*16+50) Dim $inputs[$velicina_matrice+1][$velicina_matrice+1] for $i = 1 to $velicina_matrice for $j = 1 to $velicina_matrice $inputs[$i][$j] = GUICtrlCreateInput("", $x_coord, $y_coord, 70, 17) $y_coord += 16 Next $y_coord = 10 $x_coord += 69 Next dim $mnozioci[$velicina_matrice+1] $y_coord = 10 GUICtrlCreateLabel("x", $velicina_matrice*69+30-19, ($velicina_matrice*16)/2, 19, 20, 0x0001) GUICtrlSetFont(-1, 16, 800) for $i = 1 to $velicina_matrice $mnozioci[$i] = GUICtrlCreateInput("", $velicina_matrice*69+30, $y_coord, 70, 17) $y_coord += 16 Next GUICtrlCreateLabel("=", $velicina_matrice*69+100, ($velicina_matrice*16)/2, 19, 20, 0x0001) GUICtrlSetFont(-1, 16, 800) dim $resenja[$velicina_matrice+1] $y_coord = 10 for $i = 1 to $velicina_matrice $resenja[$i] = GUICtrlCreateInput("", $velicina_matrice*69+100+20, $y_coord, 70, 17) $y_coord += 16 Next Local $racunaj_button = GUICtrlCreateButton("Calculate", 10, $velicina_matrice*16+20, 60, 20) Local $novo_button = GUICtrlCreateButton("New matrix", 80, $velicina_matrice*16+20, 100, 20) Local $izlaz_button = GUICtrlCreateButton("Exit", $velicina_matrice*69+130, $velicina_matrice*16+20, 60, 20) GUISetState(@SW_SHOW, $Form1) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $izlaz_button Exit case $novo_button GUIDelete($Form1) ExitLoop case $racunaj_button for $j = 1 to $velicina_matrice Local $rezultat = 0 for $i = 1 to $velicina_matrice $rezultat += GUICtrlRead($inputs[$i][$j])*GUICtrlRead($mnozioci[$i]) Next GUICtrlSetData($resenja[$j], $rezultat) Next EndSwitch WEnd EndFunc it's just basic matrix multiplication (reverse of the thing you made, when you have the X, Y, Z, etc..., but you have no solution).
×
×
  • Create New...