Herzlichen Glückwunsch allen, die heute Geburtstag haben. Feiert schön...
Gruß,
UEZ
Herzlichen Glückwunsch allen, die heute Geburtstag haben. Feiert schön...
Gruß,
UEZ
Alles Gute zum Geburtstag!
Gruß,
UEZ
Das hat was mit dem Repaint des Fensters zu tun. Die Version von name22 ist zwar länger, aber dafür "weicher" beim Resizen.
Machmal kommt es doch auf die Länge an...
Gruß,
UEZ ![]()
Hier die etwas längere Version, die das Bild entsprechend interpoliert.
#include <Constants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global Const $STM_SETIMAGE = 0x0172
Global $sPathKey = "HKLM64\SOFTWARE\AutoIt v3\AutoIt\"
If @OSArch = "x64" Then $sPathKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt\"
Global $sImage = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\logo4.gif"
_GDIPlus_Startup()
Global $hBmp = _GDIPlus_BitmapCreateFromFile($sImage)
Global $iW = _GDIPlus_ImageGetWidth($hBmp), $iH = _GDIPlus_ImageGetHeight($hBmp)
Global $hGUI = GUICreate("Test", 235, 112, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME))
Global $idPic = GUICtrlCreatePic("", 32, 16, $iW, $iH)
GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER)
Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
Global $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
If $hB Then _WinAPI_DeleteObject($hB)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
[/autoit] [autoit][/autoit] [autoit]While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_Shutdown()
GUIDelete()
Exit
EndSwitch
WEnd
Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam, $lParam
Local $aSize = ControlGetPos($hWnd, "", $idPic)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $aSize[2], "int", $aSize[3], "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
Local $hBitmap = $aResult[6]
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hContext, "int", 7)
_GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, 0, 0, $aSize[2], $aSize[3])
_GDIPlus_GraphicsDispose($hContext)
Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
Local $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBitmap)
_GDIPlus_BitmapDispose($hBitmap)
Return "GUI_RUNDEFMSG"
EndFunc
Gruß,
UEZ
Du musst dich nicht dämlich fühlen, denn viele Wege führen nach Rom. Manchmal denke auch zu kompliziert, obwohl der Weg nach Rom viel einfachen gehen kann.
Gruß,
UEZ ![]()
Ich habe nicht alle Beiträge gelesen und kann deshalb nicht sagen, ob so was ähnliches bereits gepostet wurde.
#include <Constants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global Const $STM_SETIMAGE = 0x0172
Global $sPathKey = "HKLM64\SOFTWARE\AutoIt v3\AutoIt\"
If @OSArch = "x64" Then $sPathKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt\"
Global $sImage = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\logo4.gif"
Global $hGUI = GUICreate("Test", 235, 112, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME))
Global $idPic = GUICtrlCreatePic("", 32, 16, 169, 68)
GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER)
_GDIPlus_Startup()
Global $hBmp = _GDIPlus_BitmapCreateFromFile($sImage)
Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
Global $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
If $hB Then _WinAPI_DeleteObject($hB)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_Shutdown()
GUIDelete()
Exit
EndSwitch
WEnd
Gruß,
UEZ
Happy Birthday allen Dreien und alles Gute!
Lasst die Sau raus...
Gruß,
UEZ
Junge, Junge. Habe ich es wieder mal kompliziert gemacht...
Gruß,
UEZ ![]()
Probiere es mal damit:
#include <WinAPI.au3>
#include <MenuConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd;INSTANCE:1]", "")
Global $iX, $iY, $iW, $iH
If $aTaskbar[2] < @DesktopWidth Then ;Taskbar ist vertikal
$iW = @DesktopWidth - $aTaskbar[2]
$iH = @DesktopHeight
$iY = 1
If Not $aTaskbar[0] Then
$iX = $aTaskbar[2]
Else
$iX = 1
EndIf
Else ;ansonsten ist die Taskbar horizontal
$iW = @DesktopWidth
$iH = @DesktopHeight - $aTaskbar[3]
$iX = 1
If Not $aTaskbar[1] Then
$iY = $aTaskbar[3]
Else
$iY = 1
EndIf
EndIf
Global Const $hGui = GUICreate("Test", $iW, $iH, $iX, $iY, Default, Default)
[/autoit] [autoit][/autoit] [autoit]Global Const $iWFrame = _WinAPI_GetSystemMetrics($SM_CXFRAME) / 2
Global Const $iHFrame = _WinAPI_GetSystemMetrics($SM_CYFRAME) / 2
WinMove($hGui, "", $iX, $iY, $iW - $iWFrame, $iH - $iHFrame)
GUISetState()
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
[/autoit] [autoit][/autoit] [autoit]While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False ;stop moves
Return $GUI_RUNDEFMSG
EndFunc
Getestet auf Win7 x64 inkl. Aero.
Gruß,
UEZ
Hmm, ich arbeite ausschließlich unter Win7 X64, wobei standardmäßig x86 Code ausgeführt wird. Vielleicht liegt's ja daran, dass es bei mir funzt.
Die Anordnung der Bilder in der GUI ist noch buggy, aber jetzt habe ich keine Lust mehr, das zu fixen.
Vielleicht irgend wann mal...
Gruß,
UEZ
Hier ein "Fast Hack" und nicht voll getestet:
;coded by UEZ 2012 build 2012-10-30
#AutoIt3Wrapper_Compile_Both=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
#AutoIt3Wrapper_UseUPX=y
#AutoIt3Wrapper_UPX_Parameters=--best --lzma
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <File.au3>
#include <Constants.au3>
#include <Array.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]If Not _WinAPI_DwmIsCompositionEnabled() Then Exit MsgBox(16, 'Error', 'Require Windows Vista or later with enabled Aero theme.')
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global Const $iW = 128, $iH = 128, $iSpace = 32, $iDW = Max(@DesktopWidth * 0.3, @DesktopWidth * 0.9), $iFont = 12, $iDeltaFrame = 8
[/autoit] [autoit][/autoit] [autoit]Global $sPathKey = "HKLM64\SOFTWARE\AutoIt v3\AutoIt\"
If @OSArch = "x64" Then $sPathKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt\"
Global $sPath = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\"
Global $aList = CreateImageArray($sPath, $iW, $iH)
If @error Then Exit MsgBox(16, "Error", "No images found")
Global $iImages = UBound($aList)
Global $iColum = Floor($iDW / ($iW + $iSpace))
Global $iRow = Ceiling($iImages / $iColum)
Global Const $STM_SETIMAGE = 0x0172
Global $iGUI_W = Min($iDW, $iImages * ($iSpace + $iW)), $iGUI_H = $iRow * ($iSpace + $iH) + 1.5 * $iFont + $iDeltaFrame * 5
Global $hGUI = GUICreate("Alt+Tab Preview Like Window by UEZ 2012 beta", $iGUI_W, $iGUI_H, -1, -1, 0, $WS_EX_DLGMODALFRAME)
GUISetBkColor(0)
_WinAPI_DwmExtendFrameIntoClientArea($hGUI)
Global $iLabel = GUICtrlCreateLabel("", 0, 0, $iGUI_W, $iFont * 1.75, $SS_CENTER)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, $iFont, 400, 0, "Tahoma", 5)
Global $j = 0, $x = 0, $y = 0, $hHBITMAP, $iYPos
[/autoit] [autoit][/autoit] [autoit]Do
$iYPos = 1.5 * $iFont + $iSpace / 2 + $y * ($iH + $iSpace)
$aList[$j][1] = GUICtrlCreateLabel("", -$iDeltaFrame + $iSpace / 2 + $x * ($iSpace + $iW), -$iDeltaFrame + $iYPos, $iW + $iDeltaFrame * 2, $iH + $iDeltaFrame * 2, Default, Default)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, 0x0)
$aList[$j][2] = GUICtrlCreatePic("", $iSpace / 2 + $x * ($iSpace + $iW), $iYPos, $iW, $iH, Default, Default)
$aList[$j][3] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($aList[$j][0])
_WinAPI_DeleteObject(GUICtrlSendMsg($aList[$j][2], $STM_SETIMAGE, $IMAGE_BITMAP, $aList[$j][3]))
$aList[$j][5] = 0
$x = Mod($x + 1, $iColum)
If Not $x Then $y = Mod($y + 1, $iRow)
$j += 1
Until $j = UBound($aList)
GUISetState()
Global $aChk
Do
If WinActive($hGUI) Then
$aChk = GUIGetCursorInfo($hGUI)
Hover($aChk[4], $aList, $aChk[2])
EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
[/autoit] [autoit][/autoit] [autoit];release ressources
For $j = 0 To UBound($aList) - 1
_WinAPI_DeleteObject($aList[$j][3])
_GDIPlus_BitmapDispose($aList[$j][0])
Next
_GDIPlus_Shutdown()
Exit
Func Hover($idCtrl, ByRef $array, $bPrimDown = False)
Local Static $iElement
Local $k
For $k = 0 To UBound($array) - 1
If $array[$k][2] = $idCtrl Then
If $bPrimDown = 1 Then
ShellExecute($array[$k][4])
$bPrimDown = False
Sleep(500)
EndIf
If $iElement <> $idCtrl Then ;check to avoid flickering
GUICtrlSetData($iLabel, $array[$k][4])
GUICtrlSetBkColor($array[$k][1], 0x101050)
GUICtrlSetStyle($aList[$k][1], Default, $WS_EX_STATICEDGE)
$iElement = $idCtrl
$array[$k][5] = 1
EndIf
Else
If $array[$k][5] = 1 Then ;check to avoid flickering
GUICtrlSetBkColor($array[$k][1], 0x0)
GUICtrlSetStyle($aList[$k][1], Default, 0)
$array[$k][5] = 0
$iElement = -1
EndIf
EndIf
Next
EndFunc ;==>Hover
Func Min($a, $b)
If $a < $b Then Return $a
Return $b
EndFunc ;==>Min
Func Max($a, $b)
If $a > $b Then Return $a
Return $b
EndFunc ;==>Max
Func CreateImageArray($sPath, $iW_TN = 128, $iH_TN = 128)
Local $aFiles = _FileListToArray($sPath, "*", 1)
If Not IsArray($aFiles) Then Return SetError(1, 0, 0)
Local $sExt = "JPG|BMP|GIF|PNG|"
Local $i = 0
While $i < UBound($aFiles) - 1
If Not StringInStr($sExt, StringRight($aFiles[$i], 3)) Then
_ArrayDelete($aFiles, $i)
Else
$i += 1
EndIf
WEnd
Local $iUB = UBound($aFiles) - 1
If Not $iUB Then Return SetError(2, 0, 0)
Local $aResult[$iUB + 1][6], $hImage, $hBmp, $hCtxt, $iW, $iH, $w, $h, $f
For $i = 0 To $iUB
$aResult[$i][4] = $sPath & $aFiles[$i]
$hImage = _GDIPlus_ImageLoadFromFile($aResult[$i][4])
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$hBmp = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW_TN, "int", $iH_TN, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
$aResult[$i][0] = $hBmp[6]
$hCtxt = _GDIPlus_ImageGetGraphicsContext($aResult[$i][0])
If $iW < $iW_TN And $iH < $iH_TN Then
_GDIPlus_GraphicsDrawImageRect($hCtxt, $hImage, $iW_TN / 2 - $iW / 2, $iH_TN / 2 - $iH / 2, $iW, $iH)
Else
If $iW > $iH Then
$f = $iW / $iW_TN
Else
$f = $iH / $iH_TN
EndIf
$w = Int($iW / $f)
$h = Int($iH / $f)
_GDIPlus_GraphicsDrawImageRect($hCtxt, $hImage, $iW_TN / 2 - $w / 2, $iH_TN / 2 - $h / 2, $w, $h)
EndIf
_GDIPlus_GraphicsDispose($hCtxt)
_GDIPlus_ImageDispose($hImage)
Next
Return $aResult
EndFunc ;==>CreateImageArray
Func _WinAPI_DwmExtendFrameIntoClientArea($hWnd, $tMARGINS = 0)
If Not IsDllStruct($tMARGINS) Then
$tMARGINS = _WinAPI_CreateMargins(-1, -1, -1, -1)
EndIf
Local $Ret = DllCall('dwmapi.dll', 'uint', 'DwmExtendFrameIntoClientArea', 'hwnd', $hWnd, 'ptr', DllStructGetPtr($tMARGINS))
If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Return 1
EndFunc ;==>_WinAPI_DwmExtendFrameIntoClientArea
Func _WinAPI_CreateMargins($iLeftWidth, $iRightWidth, $iTopHeight, $iBottomHeight)
Local $tMARGINS = DllStructCreate($tagMARGINS)
DllStructSetData($tMARGINS, 1, $iLeftWidth)
DllStructSetData($tMARGINS, 2, $iRightWidth)
DllStructSetData($tMARGINS, 3, $iTopHeight)
DllStructSetData($tMARGINS, 4, $iBottomHeight)
Return $tMARGINS
EndFunc ;==>_WinAPI_CreateMargins
Func _WinAPI_DwmIsCompositionEnabled()
Local $Ret = DllCall('dwmapi.dll', 'uint', 'DwmIsCompositionEnabled', 'int*', 0)
If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Return $Ret[1]
EndFunc ;==>_WinAPI_DwmIsCompositionEnabled
Gruß,
UEZ
Um x Zahlen zu prüfen, ob mind. eine doppelt vorkommt, würde ich nicht If ... Then benutzen, so wie in dem Beispiel, sondern würde die Zahl in ein Array schreiben, das Array sortieren und einfach die Zahl z.B. aufsteigen prüfen.
Z.B. so was hier:
#include <Array.au3>
Global $aZahlen[6]
Do
For $i = 0 To 5
$aZahlen[$i] = Random(1, 49, 1)
Next
Until Check($aZahlen)
_ArrayDisplay($aZahlen)
Func Check($aZahlen)
_ArraySort($aZahlen)
Local $i = 0
Do
If $aZahlen[$i] = $aZahlen[$i + 1] Then Return 0
$i += 1
Until $i = UBound($aZahlen) - 1
Return 1
EndFunc
Gruß,
UEZ
Probiere es mal damit:
[autoit]
While 1
$Zahl1 = Random(1, 3, 1)
$Zahl2 = Random(1, 3, 1)
$Zahl3 = Random(1, 3, 1)
Sleep(10)
If $Zahl1 <> $Zahl2 And $Zahl1 <> $Zahl3 And $Zahl2 <> $Zahl3 Then
MsgBox(0,"","Zahl 1 und 2 und 3 sind ungleich" & @CRLF & $Zahl1 & ":" & $Zahl2 & ":" & $Zahl3 & ":")
ExitLoop
EndIf
WEnd
Gruß,
UEZ
Ich kann mich hier nur Andy anschließen und wie er sagte, muss man erstmal die Rahmenbedingungen für die Tests abstecken und dann die Vergleiche machen.
Ich persönlich wäre nicht in der Lage in all den oben gelisteten Sprachen zu coden.
Ich gebe auch BugFix recht, dass man kritische Bereiche bzgl. der Laufzeit optimieren kann, z.B. mit ASM oder DLL's per FreeBasic erstellen und mit AutoIt benutzen.
Diese Flexibilität ist das Geniale an AutoIt, wobei die anderen Sprachen dies auch beherrschen...
Gruß,
UEZ
Willst du abfragen, ob du mit der Maus auf ein Control klickst? Wenn ja, dann ist dies sicherlich nicht der eleganteste Weg!
Gruß,
UEZ
Ich kann mich nur water anschließen. Warum mehr Aufwand betreiben? Was habt ihr gegen alte Threads? Und wann ist alt? Für mich wäre z.B. ein Thread alt, wenn dieser vor mehr als 5 Jahren eröffnet worden wäre, aber immer noch kein Grund ihn zu locken, wenn der Inhalt eben passt.
Es macht keinen Sinn einen Thread auszugraben, wenn der Inhalt nicht mehr aktuell ist, sprich der Source Code von einer Uralt Version ist.
Gruß,
UEZ
Richtig.
Gruß,
UEZ
Ich persönlich freue mich auch auf Feedback von meinen älteren Threads!
Deshalb wäre ich nicht dafür.
Gruß,
UEZ
Stimmt, da war doch noch was... ![]()
Gruß,
UEZ