Salut wakillon,
merci de vos commentaires - devrait maintenant fonctionner parfaitement.
Cordialement,
UEZ
Salut wakillon,
merci de vos commentaires - devrait maintenant fonctionner parfaitement.
Cordialement,
UEZ
Du kannst auch ein Bild laden und es in den Button senden. Siehe hier: File to Base64 String Code Generator v1.03 Build 2011-11-21 (1. Beispiel).
Oder:
;By Malkey
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client
[/autoit] [autoit][/autoit] [autoit]Global $hGUI, $hGraphicGUI, $hBMPBuff
[/autoit] [autoit][/autoit] [autoit]_Main()
Func _Main()
Local $hBMP, $hBitmap, $hGraphic, $hImage, $iX, $iY, $hClone, $t, $aMPos
Local $GuiSizeX = 400, $GuiSizeY = 300
Local $pngFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") _
& "\Examples\GUI\Advanced\Images\Button.png"
; Create GUI
$hGUI = GUICreate("GDI+", $GuiSizeX, $GuiSizeY)
;GUISetBkColor(0xFFFFEF)
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hBitmap = _GDIPlus_ImageLoadFromFile($pngFile)
$hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)
GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3)
GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize.
_GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
Do
$aMPos = MouseGetPos()
If ispressed("01") Then
Select
Case _WinAPI_PtInRectEx($aMPos[0], $aMPos[1], 5, 5, 112, 56)
MsgBox(0, "", " Top button clicked", 1)
Case _PointInEllipse($aMPos[0], $aMPos[1], 122, 100, 132, 45)
MsgBox(0, "", "Middle elliptic button clicked", 1)
Case _WinAPI_PtInRectEx($aMPos[0], $aMPos[1], 5, 192, 112, 243)
MsgBox(0, "", "Lowest button clicked", 1)
EndSelect
EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_GraphicsDispose($hGraphicGUI)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hBMPBuff)
_GDIPlus_Shutdown()
EndFunc ;==>_Main
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; ($xPt, $yPt) - x, y position of the point to check
; $xTL, $yTL, Top left x Pos, top left Y position of the rectangle encompassing the ellipse.
; $w, $h - The width an height of ellipse
; http://www.autoitscript.com/forum/index.ph…ndpost&p=639786
;
Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
Local $bInside = False, $a = $w / 2, $b = $h / 2
Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
$c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position
$c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position
$dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
If $dist <= $w Then $bInside = Not $bInside
Return $bInside
EndFunc ;==>_PointInEllipse
; ($iX, $iY) - x, y position of the point to check
; ($iLeft, $iTop) - x, y position of the top left corner of rectangle
; ($iRight, $iBottom) - x, y position of the bottom right corner of rectangle
; http://www.autoitscript.com/forum/index.ph…ndpost&p=639786
;
Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iRight, $iBottom)
Local $aResult
Local $tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, "Left", $iLeft)
DllStructSetData($tRect, "Top", $iTop)
DllStructSetData($tRect, "Right", $iRight)
DllStructSetData($tRect, "Bottom", $iBottom)
$aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY)
If @error Then Return SetError(@error, 0, False)
Return $aResult[0] <> 0
EndFunc ;==>_WinAPI_PtInRectEx
; Copied from ...\Include\Misc.au3 File
Func IsPressed($sHexKey)
Local $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
Return 0
EndFunc ;==>IsPressed
;Func to redraw on PAINT MSG
Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
_WinAPI_RedrawWindow($hGUI, "", "", BitOR($RDW_INVALIDATE, $RDW_FRAME, $RDW_ALLCHILDREN)) ;
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_PAINT
Oder:
;By smashly
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
_Main()
[/autoit] [autoit][/autoit] [autoit]Func _Main()
Local $hGUI, $iPicButton, $hGraphic, $hImage, $hBitmap1, $hGraphic1, $hBMP1, $iMsg
Local $pngFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") _
& "\Examples\GUI\Advanced\Images\Button.png"
$hGUI = GUICreate("GDI+", 400, 300)
GUISetBkColor(0x000000, $hGUI)
$iPicButton = GUICtrlCreatePic("", 10, 10, 82, 36)
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hImage = _GDIPlus_ImageLoadFromFile($pngFile)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap1 = _GDIPlus_BitmapCreateFromGraphics(82, 36, $hGraphic)
$hGraphic1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic1, $hImage, 11, 145, 82, 36, 0, 0, 82, 36)
$hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1)
_GDIPlus_GraphicsDispose($hGraphic1)
_GDIPlus_BitmapDispose($hBitmap1)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
_WinAPI_DeleteObject(GUICtrlSendMsg($iPicButton, 0x0172, 0, $hBMP1))
[/autoit] [autoit][/autoit] [autoit]While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
_WinAPI_DeleteObject($hBMP1)
ExitLoop
Case $iPicButton
MsgBox(64, "Picture Clicked", "Yep picture has been clicked")
EndSwitch
WEnd
EndFunc ;==>_Main
Gruß,
UEZ
Happy Birthday to you und alles Gute!
Gruß,
UEZ
Die Lösung des Problems ist hier: _GuiCtrlSetPath
Gruß,
UEZ
Ich habe mal die WinAPIEx gecheckt und da ist bereits die Funktion implementiert... Aber egal!
Gruß,
UEZ
Hilft dir vielleicht _GDIPlus_StringFormatSetAlign() weiter?
Gruß,
UEZ
Cool, was so in der WinAPI alles steckt!
Gruß,
UEZ
Du kannst das Skript extrem beschleunigen, wenn du _GDIPlus_Startup() / _GDIPlus_Shutdown() vorher aufrufst!
#include <GDIPlus.au3>
_GDIPlus_Startup()
$iFontSize = 24
$sFontname = 'Times New Roman'
;~ $sFontname = 'Courier New'
$hGui = GUICreate('Test', 600, 200)
GUISetFont($iFontSize, 400, 0, $sFontname)
$hPath1 = GUICtrlCreateLabel('', 10, 10, 300, 50)
GUICtrlSetBkColor(-1, 0xCCCCCC)
$hPath2 = GUICtrlCreateLabel('', 10, 80, 580, 50)
GUICtrlSetBkColor(-1, 0xCCCCCC)
GUISetState()
; Beispiel 1
$sPath1 = 'c:\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$iTimer = TimerInit()
$sPath1 = _FilePathTrimToLabelWidth($sPath1, $hGui, $hPath1, $iFontSize, $sFontname)
ConsoleWrite(Int(TimerDiff($iTimer)) & ' mSec.' & @CR)
GUICtrlSetData($hPath1, $sPath1)
; Beispiel 2
$sPath2 = '\\Server\d\Backup\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$iTimer = TimerInit()
$sPath2 = _FilePathTrimToLabelWidth($sPath2, $hGui, $hPath2, $iFontSize, $sFontname)
ConsoleWrite(Int(TimerDiff($iTimer)) & ' mSec.' & @CR)
GUICtrlSetData($hPath2, $sPath2)
Do
Until GUIGetMsg() = -3
_GDIPlus_Shutdown()
;===============================================================================
; Function Name: _FilePathTrimToLabelWidth($sFilepath, $CtrlID, $iFontSize, $sFontname)
; Description:: Begrenzt einen Dateipfad auf die Breite eines Labels.
; Dabei wird er aber nicht vorn oder hinten abgeschnitten,
; sondern es bleibt das Device erhalten und der rechte Teil
; des Pfades.
; Parameter(s): $sFilepath = der Pfad, der gekürzt werden soll
; $hGui = das Handle des Fensters
; $CtrlID = die Control ID des Label
; $iFontSize = Fontgröße
; $sFontname = Fontname
; Requirement(s): #include <GDIPlus.au3>
; Return Value(s): Der gekürzte Pfad
; Author(s): Oscar + UEZ + peethebee (http://www.autoit.de)
;===============================================================================
Func _FilePathTrimToLabelWidth($sFilepath, $hGui, $CtrlID, $iFontSize, $sFontname)
Local $sDevice, $iLen = StringLen($sFilepath)
Local $iSize = _GetStringSize($sFilepath, $sFontname, $iFontSize, 0)
Local $aPosCtrl = ControlGetPos($hGui, '', $CtrlID)
If $iSize < $aPosCtrl[2] Then Return $sFilepath
$sDevice = StringRegExpReplace($sFilepath, '([a-z]:\\|\\\\.+?\\[a-z]\\).+', '$1') & '...'
For $i = $iLen - StringLen($sDevice) To 1 Step -1
$iSize = _GetStringSize($sDevice & StringRight($sFilepath, $i), $sFontname, $iFontSize, 0)
If $iSize < $aPosCtrl[2] Then ExitLoop
Next
Return $sDevice & StringRight($sFilepath, $i)
EndFunc ;==>_FilePathTrimToLabelWidth
Func _GetStringSize($string, $font, $fontsize, $fontstyle)
Local $GDIp = False
Local $iWidth = StringLen($string) * $fontsize
Local $iHeight = 2 * $fontsize
If Not $ghGDIPDll Then
_GDIPlus_Startup()
$GDIp = True
EndIf
Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromScan0', 'int', $iWidth, 'int', $iHeight, 'int', 0, 'int', 0x0026200A, 'ptr', 0, 'int*', 0)
Local $hBitmap = $aResult[6]
Local $hGrphContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate($font)
Local $hFont = _GDIPlus_FontCreate($hFamily, $fontsize, $fontstyle)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGrphContext, $string, $hFont, $tLayout, $hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGrphContext)
If $GDIp Then _GDIPlus_Shutdown()
Return Int(DllStructGetData($aInfo[0], 'Width'))
EndFunc ;==>_GetStringSize
Gruß,
UEZ
War auch nur eine "Studie". Leider dauert das Erstellen in _FilePathTrimToLabelWidth zu lange.
Ich schaue mal, ob mir dazu noch was einfällt....
Gruß,
UEZ
Z.B. das IE Fenster im Vollbildmodus unter Win7:
[autoit]
$hIE = WinGetHandle("[CLASS:IEFrame; INSTANCE:1]", "")
WinSetState($hIE, "", @SW_RESTORE)
Gruß,
UEZ
Und dies hier?
#include <GDIPlus.au3>
$iFontSize = 12
$sFontname = 'Courier New'
$hGui = GUICreate('Test', 400, 200)
GUISetFont($iFontSize, 400, 0, $sFontname)
$hPath1 = GUICtrlCreateLabel('', 10, 10, 280, 20)
GUICtrlSetBkColor(-1, 0xCCCCCC)
$hPath2 = GUICtrlCreateLabel('', 10, 60, 300, 20)
GUICtrlSetBkColor(-1, 0xCCCCCC)
GUISetState()
; Beispiel 1
$sPath1 = 'c:\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$sPath1 = _FilePathTrimToLimit($sPath1, $hPath1, $iFontSize, $sFontname)
GUICtrlSetData($hPath1, $sPath1)
; Beispiel 2
$sPath2 = '\\Server\d\Backup\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$sPath2 = _FilePathTrimToLimit($sPath2, $hPath2, $iFontSize, $sFontname)
GUICtrlSetData($hPath2, $sPath2)
Do
Until GUIGetMsg() = -3
;===============================================================================
; Function Name: _FilePathTrimToLimit($sFilepath, $iLimit)
; Description:: Begrenzt einen Dateipfad auf eine anzugebene Stringlänge.
; Dabei wird er aber nicht vorn oder hinten abgeschnitten,
; sondern es bleibt das Device erhalten und der rechte Teil
; des Pfades.
; Parameter(s): $sFilepath = der Pfad, der gekürzt werden soll
; $CtrlID = die Control ID des Label
; $iFontSize = die Fontgröße des Labels
; $sFontname = Font Name
; Requirement(s): ---
; Return Value(s): Der gekürzte Pfad
; Author(s): Oscar (http://www.autoit.de)
;===============================================================================
Func _FilePathTrimToLimit($sFilepath, $CtrlID, $iFontSize, $sFontname)
Local $aSize = GetStringSize($sFilepath, $sFontname, $iFontSize, 0)
Local $aPosCtrl = ControlGetPos("", "", $CtrlID)
Local $iLimit = StringLen($sFilepath) - Ceiling(Ceiling(1 + ($aSize[0] - $aPosCtrl[2]) / 100) + ($aSize[0] - $aPosCtrl[2]) / $iFontSize)
Local $sDevice, $iLen = StringLen($sFilepath)
If $iLimit < 1 Or $iLimit >= $iLen Then Return $sFilepath
$sDevice = StringRegExpReplace($sFilepath, '([a-z]:\\|\\\\.+?\\[a-z]\\).+', '$1') & '...'
Return $sDevice & StringRight($sFilepath, $iLimit - StringLen($sDevice))
EndFunc ;==>_FilePathTrimToLimit
Func GetStringSize($string, $font, $fontsize, $fontstyle)
Local $GDIp = False
Local $iWidth = StringLen($string) * $fontsize
Local $iHeight = 2 * $fontsize
If Not $ghGDIPDll Then
_GDIPlus_Startup()
$GDIp = True
EndIf
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
Local $hBitmap = $aResult[6]
Local $hGrphContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
;~ Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate($font)
Local $hFont = _GDIPlus_FontCreate($hFamily, $fontsize, $fontstyle)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGrphContext, $string, $hFont, $tLayout, $hFormat)
;~ _GDIPlus_GraphicsDrawStringEx($hGrphContext, $string, $hFont, $aInfo[0], $hFormat, $hBrush)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
;~ _GDIPlus_BrushDispose($hBrush)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGrphContext)
If $GDIp Then _GDIPlus_Shutdown()
Local $aDim[2] = [Int(DllStructGetData($aInfo[0], "Width")), Int(DllStructGetData($aInfo[0], "Height"))]
Return $aDim
EndFunc
Gruß,
UEZ
Nette Funktion!
Cool wäre es, wenn die Funktion anhand der String Länge respektiv Font Größe und die Länge/Breite des Label berechnen würde.
Wenn du z.B. in deinem Beispiel die Zeile
$hPath1 = GUICtrlCreateLabel('', 10, 10, 380, 20)
in
$hPath1 = GUICtrlCreateLabel('', 10, 10, 280, 20)
umänderst, dann fehlt ein Teil des Dateinamens.
Gruß,
UEZ
So würde auch das nicht machen!
Eher so:
[autoit]
$run = Run(@ComSpec & " /k ipconfig", "", @SW_SHOW)
Gruß,
UEZ
Danke für den Hinweis! Kann ich vielleicht bei Gelegenheit einbauen, wenn es Sinn macht.
http://www.downforeveryoneorjustme.com/www.amazon.de funzt auch nicht!
Gruß,
UEZ
Und wieder ein kleines Update.
Gruß,
UEZ
Ich hab's mal getestet und Notepad.exe wird zwar gestartet, aber man bekommt die GUI nicht zu sehen!
Func _RemoteStart($Program, $RemoteComputer, $ShowWindow, $usr, $pass)
;ShowWindow = 1 => Show / 0 => Hide
Local $oWMIService, $oStartup, $oConfig, $oProcess
Local $iProcessID, $iReturn
Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator")
Local $oWMIService = $objWMILocator.ConnectServer($RemoteComputer, "\root\cimv2", $usr, $pass, "", "", 128)
;~ $oWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy, (Debug)}!\\" & $RemoteComputer & "\root\cimv2")
$oStartup = $oWMIService.Get("Win32_ProcessStartup")
$oConfig = $oStartup.SpawnInstance_
$oConfig.ShowWindow = $ShowWindow
$oProcess = $oWMIService.Get("Win32_Process")
$iReturn = $oProcess.Create($Program, Default, $oConfig, $iProcessID)
$oWMIService = 0
$oStartup = 0
$oConfig = 0
$oProcess = 0
If $iReturn <> 0 Then
Return False
Else
Return True
EndIf
EndFunc ;==>_RemoteStart
Der Prozess wird unter svchost.exe -> wmiprvse.exe -> notepad.exe aufgehängt.
Gruß,
UEZ
Hast du auf dem Remote System die entsprechenden Rechte? Das Skript versucht mit den angemeldeten Account auf dem Remote Computer zuzugreifen.
Gruß,
UEZ
Schaue mal hier rein: Audio CD To Wave Or MP3
Gruß,
UEZ
Funzt nicht im Multi Monitor Betrieb (siehe Bild)!
Du kannst z.B. die Größe so abfragen:
[autoit]
$hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]")
$aFullScreen = WinGetPos($hFullScreen)
In aFullScreen stehen die Infos.
Bei mir:
@@ Debug(3) : $aFullScreen[0] = -1280
>Error code: 0
@@ Debug(4) : $aFullScreen[1] = 0
>Error code: 0
@@ Debug(5) : $aFullScreen[2] = 2960
>Error code: 0
@@ Debug(6) : $aFullScreen[3] = 1050
Gruß,
UEZ