Wenn du willst, kann du mal in AutoIt Windows Screenshooter reinschauen. Dort habe ich einige Möglichkeiten implementiert, um Screenshots zu erstellen, sollte auch mit Spielen funzen ![]()
Gruß,
UEZ
Wenn du willst, kann du mal in AutoIt Windows Screenshooter reinschauen. Dort habe ich einige Möglichkeiten implementiert, um Screenshots zu erstellen, sollte auch mit Spielen funzen ![]()
Gruß,
UEZ
Ganz so einfach scheint's dann auch net zu klappen...
Kommazahlen z.B. 80.3 (wobei im NC-Programm das Komma nen Punkt is) werden auch geteilt dadurchSo, hier für euch mal zum Testen ein Ausschnitt eines echten NC-Programmes:
Was erwartest du, wenn du nur die Hälfte erwähnst?
Gruß,
UEZ
Hier noch eine Variante:
[autoit]
$sSource = _
"N5M6T1(BOHRER D10)" & @LF & _
"N10G0G54X10Y30S500M3" & @LF & _
"N15G0Z30" & @LF & _
"N20G81R2Z-15F500" & @LF & _
"N20G0G80Z300"
$sNew = StringRegExpReplace($sSource, "(\w\d+)", "$1 ")
MsgBox(0, "Test", $sNew)
Gruß,
UEZ
Ich glaube die Länge des Strings darf höchstens 2048 Zeichen lang sein.
Hier der Code, den ich benutze, um den Binärstring zu erzeugen:
; ============================================================================================================================
; Purpose : Converts any file to HEX binary string
; Author : Ward / UEZ
; ============================================================================================================================
Local $VarName = StringStripWS(InputBox("Convert to Binary String", "Select a name for the variable." & @CRLF & @CRLF & "$ will automatically added to the beginning of the variable!:", "BinaryString"), 3)
If $VarName = "" Then Exit
Local $FileName = FileOpenDialog("Open a file", @ScriptDir, "DLL file (*.*)")
If $FileName = "" Then Exit
Local $Handle = FileOpen($FileName, 16)
Local $BinaryString = FileRead($Handle)
FileClose($Handle)
Local $LineLen = 1024
Local $DllString = String($BinaryString)
Local $Script = "Func " & $VarName & "()" & @CRLF & @TAB & "Local _" & @CRLF & @TAB & "$" & $VarName & " = '" & StringLeft($DllString, $LineLen) & "'" & @CRLF
$DllString = StringTrimLeft($DllString, $LineLen)
While StringLen($DllString) > $LineLen
$Script &= " $" & $VarName & " &= '" & StringLeft($DllString, $LineLen) & "'" & @CRLF
$DllString = StringTrimLeft($DllString, $LineLen)
WEnd
If StringLen($DllString) <> 0 Then $Script &= " $" & $VarName & " &= '" & $DllString & "'" & @CRLF
$Script &= @TAB & "Return Binary($" & $VarName & ")" & @CRLF & "EndFunc"
ClipPut($Script)
MsgBox(64, "Convert to Binary String", "The result is in the clipboard, you can paste it to your script.")
[/autoit]Das Resultat ist eine Funktion mit dem String und es wird in den Zwischenspeicher kopiert.
Gruß,
UEZ
Hier eine weitere Möglichkeit:
[autoit]
#include <Array.au3>
$hFullScreen = WinGetHandle("Program Manager")
$aFullScreen = WinGetPos($hFullScreen)
_ArrayDisplay($aFullScreen)
Gruß,
UEZ
Die MSDN scheint ja die Bibel der Coder zu sein. Man muss nur daran glauben, suchen, finden und verstehen - und alles wird gut.
Danke,
UEZ
Hola,
du könntest das Bild in ein Binärstring umwandeln und direkt vom Speicher darstellen. Beispiel hier: [ offen ] "Binärbild" mit GDI laden! (jetzt ohne Memory Leak Dank Progandy!)
Wie kannst du ein Bild in ein Binärstring umwandeln? Schaue mal hier rein: http://www.autoitscript.com/forum/topic/12…post__p__879238
Gruß,
UEZ
Du bist ja krass drauf ![]()
Da dies hier wunderbar hier rein passt passt, habe ich es in deinen Code mit eingebaut -> ist nicht vollständig, z.B. fehlen die statischen Controls, wie GUICtrlCreatePic, etc.
_WinGetControls.au3
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include-once
; #DEMOFUNCTION# ================================================================================================================
; Name...........: _WinGetControls
; Description ...: Liefert ein 2D-Array für die Controls eines Fensters.
; Das Array enhält für jedes Control die folgenden Informationen:
; |[0] HWND - HWND des Controls
; |[1] Class - Klasse des Controls
; |[2] NN - ClassNN des Controls
; |[3] ID - ID des Controls
; |[4] Visible - Sichtbar? 1 = ja, 0 = nein
; Das Feld Array[0][0] enthält die Anzahl der Controls.
; Syntax.........: _WinGetControls($hWnd)
; Parameters ....: $hWnd - HWND des Fensters (z.B. Rückgabewert von GUICreate)
; Return values .: Erfolg: Controlarray
; Fehler: False, @error = 1
; Author ........: Großvater (http://www.autoit.de)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _WinGetControls($hWnd)
Local $hCB
If Not IsHWnd($hWnd) Then Return SetError(1, 0, False)
__WinGetControlsAddControl("Init", 0)
$hCB = DLLCallbackRegister("__WinGetControlsAddControl", "Int", "HWND;LPARAM")
DllCall("User32.dll", "Int", "EnumChildWindows", "HWND", $hWnd, "Ptr", DllCallbackGetPtr($hCB), "LPARAM", $hWnd)
If @error Then Return SetError(DllCallbackFree($hCB), 0, False)
DllCallbackFree($hCB)
Return __WinGetControlsAddControl("Result", 0)
EndFunc
; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __WinGetControlsAddControl
; Description ...: Callback-Funktion für DLLCall "EnumChildWindows" in _WinGetControls
; Remarks .......: Weil ich globale Variable für die Rückgabe von Funktionswerten nicht mag und die Implementierung
; der statischen Arrays recht rudimentär ist, sind die maximale Anzahl von Controls auf 1024
; und die maximale Anzahl von Klassen auf 256 begrenzt.
; ===============================================================================================================================
Func __WinGetControlsAddControl($hWnd, $lParam)
Local Static $UControls = 1024
Local Static $UClasses = 256
Local Static $aControls[$UControls + 1][6]
Local Static $aClasses[$UClasses + 1][2]
Local $aResult, $C, $Class, $ClassExist, $ID, $NN
Switch $hWnd
Case "Init"
$aControls[0][0] = 0
$aClasses[0][0] = 0
Return
Case "Result"
$C = $aControls[0][0] + 1
$aResult = $aControls
Redim $aResult[$C][6]
Return $aResult
EndSwitch
$aResult = DllCall("User32.dll", "Int", "GetClassNameW", "HWND", $hWnd, "WStr", "", "Int", 260)
If @error Or $aResult[0] = 0 Then Return True
$Class = $aResult[2]
$aResult = DllCall("User32.dll", "Int", "GetDlgCtrlID", "HWND", $hWnd)
If @error Or $aResult[0] = 0 Then Return True
$ID = $aResult[0]
$ClassExist = False
$C = $aClasses[0][0]
For $I = 1 To $C
If $aClasses[$I][0] = $Class Then
$NN = $aClasses[$I][1] + 1
$aClasses[$I][1] = $NN
$ClassExist = True
ExitLoop
EndIf
Next
If Not $ClassExist Then
$NN = 1
$C += 1
If $C > $UClasses Then Return False
$aClasses[0][0] = $C
$aClasses[$C][0] = $Class
$aClasses[$C][1] = $NN
EndIf
$C = $aControls[0][0] + 1
If $C > $UControls Then Return False
$aControls[0][0] = $C
$aControls[$C][0] = $hWnd
$aControls[$C][1] = $Class
$aControls[$C][2] = $NN
$aControls[$C][3] = $ID
$aControls[$C][4] = ControlCommand(HWnd($lParam), "", $ID, "IsVisible", "")
$aControls[$C][5] = __myCtrlGetClass($hWnd)
Return True
EndFunc
; ===============================================================================================================================
Func __myCtrlGetClass($hHandle) ;code by SmOke_N, modified by Guiness
Local Const $GWL_STYLE = -16
Local $iLong, $sClass
If IsHWnd($hHandle) = 0 Then
$hHandle = GUICtrlGetHandle($hHandle)
If IsHWnd($hHandle) = 0 Then
Return SetError(1, 0, "Unknown")
EndIf
EndIf
$sClass = _WinAPI_GetClassName($hHandle)
If @error Then
Return "Unknown"
EndIf
$iLong = _WinAPI_GetWindowLong($hHandle, $GWL_STYLE)
If @error Then
Return SetError(2, 0, 0)
EndIf
Switch $sClass
Case "Button"
Select
Case BitAND($iLong, $BS_GROUPBOX) = $BS_GROUPBOX
Return "Group"
Case BitAND($iLong, $BS_CHECKBOX) = $BS_CHECKBOX
Return "Checkbox"
Case BitAND($iLong, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX
Return "Checkbox"
Case BitAND($iLong, $BS_RADIOBUTTON) = $BS_RADIOBUTTON
Return "Radio"
Case BitAND($iLong, $BS_AUTORADIOBUTTON) = $BS_AUTORADIOBUTTON
Return "Radio"
EndSelect
Case "Edit"
Select
Case BitAND($iLong, $ES_WANTRETURN) = $ES_WANTRETURN
Return "Edit"
Case Else
Return "Input"
EndSelect
Case "Static"
Select
Case BitAND($iLong, $SS_BITMAP) = $SS_BITMAP
Return "Pic"
Case BitAND($iLong, $SS_ICON) = $SS_ICON
Return "Icon"
Case BitAND($iLong, $SS_LEFT) = $SS_LEFT
If BitAND($iLong, $SS_NOTIFY) = $SS_NOTIFY Then
Return "Label"
EndIf
Return "Graphic"
EndSelect
Case "ComboBox"
Return "Combo"
Case "ListBox"
Return "List"
Case "msctls_progress32"
Return "Progress"
Case "msctls_trackbar32"
Return "Slider"
Case "SysDateTimePick32"
Return "Date"
Case "SysListView32"
Return "ListView"
Case "SysMonthCal32"
Return "MonthCal"
Case "SysTabControl32"
Return "Tab"
Case "SysTreeView32"
Return "TreeView"
EndSwitch
Return $sClass
EndFunc
_WinGetControls Example 2.au3
#include "WinGetControls.au3"
#include <Array.au3>
$sGUITitle1 = "Test Getting GUI Control Types"
[/autoit] [autoit][/autoit] [autoit]$hGUI1 = GUICreate($sGUITitle1, 400, 500, -1, -1)
[/autoit] [autoit][/autoit] [autoit]$x3 = GUICtrlCreateButton("button1", 10, 10, 60, 20) ; button, it's a Group
$x4 = GUICtrlCreateButton("button2", 10, 40, 60, 20) ; button
$x5 = GUICtrlCreateButton("button3", 10, 70, 60, 20) ; button
$x6 = GUICtrlCreateEdit("Edit1", 10, 100, 60, 20) ; edit, it's a HScroll
$x7 = GUICtrlCreateInput("Input1", 10, 130, 60, 20) ; edit
$x8 = GUICtrlCreateLabel("Label1", 10, 160, 60, 20) ; static
$x9 = GUICtrlCreateRadio("Radio1", 10, 190, 60, 20) ; button
$x10 = GUICtrlCreateRadio("Radio2", 10, 220, 60, 20) ; button
$x11 = GUICtrlCreateCheckbox("CheckBox1", 10, 250, 60, 20) ; button
$x12 = GUICtrlCreateGroup("Group1", 10, 280, 80, 50) ; button, it's a Group
$x13 = GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group, it's a Group
$x14 = GUICtrlCreateCombo("", 10, 340, 60, 20) ; ComboBox
GUICtrlSetData(-1, "ComboItem1|Comboitem2|Comboitem3", "Comboitem3")
$x15 = GUICtrlCreateList("List1", 10, 370, 60, 20) ; ListBox
GUICtrlSetData(-1, "ListItem1|Listitem2|Listitem3", "Listitem2")
GUISetState(@SW_SHOW, $sGUITitle1)
[/autoit] [autoit][/autoit] [autoit]Dim $aControls, $hWnd, $Title
$Title = WinGetTitle($hGUI1 )
$aControls = _WinGetControls($hGUI1)
If Not IsArray($aControls) Then
MsgBox(0, "ERROR", "Der Aufruf von _WinGetControls() ist fehlgeschlagen!")
Else
_ArrayDisplay($aControls, $Title, -1, 0, "", "|", "Zeile|HWND|Class|NN|ID|Visible|Controls")
EndIf
Sleep(1000)
Exit
Wie hast du das ganze Zeug gelernt?
Gruß,
UEZ
Vielleicht so?
[autoit]
$min = 200 * 1024 ;200 kb = 200 * 1024 Bytes
$datei = "Text1.txt"
If FileExists($datei) And FileGetSize($datei) < $min Then MsgBox(0, "Info", "Datei ist kleiner als 200kb!")
Gruß,
UEZ
Durch Zufall habe ich von einem anderen Forum erfahren, dank Google, dass in dem UDF ein Bug ist. Das Positionieren des Textes auf x zentriert, aber auf y manuell war nicht möglich.
Bug sollte jetzt gefixt sein.
Schade, dass niemand den Bug hier gemeldet hat. ![]()
Gruß,
UEZ
Hier noch eine Möglichkeit:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
Global Const $fScale = 30
Global Const $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\sworddg.png")
Global Const $iW = _GDIPlus_ImageGetWidth($hImage)
Global Const $iH = _GDIPlus_ImageGetHeight($hImage)
Global Const $iWidth = $iW * 96 / _GDIPlus_ImageGetHorizontalResolution($hImage) * $fScale
Global Const $iHeight = $iH * 96 / _GDIPlus_ImageGetVerticalResolution($hImage) * $fScale
Global Const $hGui = GUICreate("Test", $iWidth, $iHeight)
GUISetBkColor(0xE0E080)
Global Const $cPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)
Global Const $hPic = GUICtrlGetHandle($cPic)
GUISetState()
Global Const $hDC = _WinAPI_GetWindowDC($hPic)
Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC)
Global Const $hBitmap_backbuffer = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hBitmap_backbuffer)
Global Const $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer)
_GDIPlus_GraphicsDrawImage($hGfx, $hImage, 0, 0)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_Shutdown()
_WinAPI_AlphaBlend($hDC, 0, 0, $iWidth, $iHeight, $hDC_backbuffer, 0, 0, $iW, $iH, 255, 1)
_WinAPI_BitBlt($hDC_backbuffer, 0, 0, $iWidth, $iHeight, $hDC, 0, 0, $SRCCOPY)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDC_backbuffer, $DC_obj)
_WinAPI_DeleteDC($hDC_backbuffer)
Global Const $STM_SETIMAGE = 0x0172
Global Const $STM_GETIMAGE = 0x0173
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap_backbuffer)
Global Const $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap_backbuffer Then
_WinAPI_DeleteObject($hBitmap_backbuffer)
EndIf
GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
[/autoit] [autoit][/autoit] [autoit]While Sleep(100000)
WEnd
Func _Exit()
GUIDelete($hGui)
Exit
EndFunc ;==>_Exit
Func _WinAPI_AlphaBlend($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iAlpha, $fAlpha = 0)
Local $iBlend = BitOR(BitShift(Not ($fAlpha = 0), -24), BitShift(BitAND($iAlpha, 0xFF), -16))
Local $Ret = DllCall('gdi32.dll', 'int', 'GdiAlphaBlend', 'hwnd', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'hwnd', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'dword', $iBlend)
If @error Or (Not $Ret[0]) Then Return SetError(1, 0, 0)
Return 1
EndFunc ;==>_WinAPI_AlphaBlend
Gruß,
UEZ
Auch von mir ein herzliches Happy Birthday und alles Gute!
Gruß,
UEZ
Kleines Update:
Man kann jetzt die Hintergrundfarbe der GUI ändern und eine Datei aussuchen, die standardmäßig geladen wird. Die Einstellungen werden in einer Ini Datei im Skript Verzeichnis gespeichert.
Gruß,
UEZ
Ja,
[autoit]
...
$Input = GUICtrlCreateInput("", 88, 64, 313, 21)
GUICtrlSetTip(-1, "Bitte eine Zahl eingeben")
...
Gruß,
UEZ
In der Hilfe unter GUICtrlCreateInput ist ein Beispiel, das du suchst oder?
#include <GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]Example()
[/autoit] [autoit][/autoit] [autoit]Func Example()
Local $file, $btn, $msg
GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput("", 10, 5, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files
$btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)
GUISetState()
[/autoit] [autoit][/autoit] [autoit]$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
ExitLoop
EndSelect
WEnd
MsgBox(4096, "drag drop file", GUICtrlRead($file))
EndFunc ;==>Example
Gruß,
UEZ
Ich benötige die MSVCR100.dll - genauso wie in der AutoIt v3.3.7.0 (Beta) ![]()
Gruß,
UEZ
Bei mir gibt's keine Probleme: Win7 x64.
Gruß,
UEZ
Der Nachteil der _ArrayPermute() Methode ist, wenn du ein größers Array nimmst, welches dann n! + 1 Arrayspeicher frisst.
Besser wäre ein Mischen des Arrays.
Wie? Z.B so:
#include-once
; #FUNCTION# ======================================================================================
; Name ................: Shuffle_Array()
; Version .............: v0.50 build 2011-05-24 beta
; Description .......: Shuffles an array - support 1D and 2D arrays only
; Syntax ..............: Shuffle_Array(ByRef $array, $startindex = 0, $endindex = 0)
; Parameters ........: $array - the array to shuffle
; $startindex = from which index to start the shuffling
; $endindex = to which index to start the shuffling; 0 means last index of the array
; Return values ....: True
; Failure 1 - $array is not an array
; Failure 2 - array has more than 2 dimensions
; Failure 3 - array is empty
; Failure 4 - $startindex / $endindex are set wrongly
; Author ..............: UEZ
; Modified ............:
; Remarks ............:
; Related ..............: Array
; =================================================================================================
Func Shuffle_Array(ByRef $array, $startindex = 0, $endindex = 0)
If Not IsArray($array) Then Return SetError(1, 0, 0)
If UBound($array, 0) > 2 Then Return SetError(2, 0, 0)
If UBound($array) = 1 Then Return SetError(3, 0, 0)
Local $u1
If Not $endindex Then
$u1 = UBound($array) - 1
Else
If $endindex > $startindex And $endindex < UBound($array) Then
$u1 = $endindex
Else
Return SetError(4, 0, 0)
EndIf
EndIf
If UBound($array, 2) Then
Local $aSwap[1][UBound($array, 2)], $u2 = UBound($array, 2) - 1
Local $i, $j, $r
For $i = $startindex To $u1
$r = Random($startindex, $u1, 1)
For $j = 0 To $u2
$aSwap[0][$j] = $array[$i][$j]
$array[$i][$j] = $array[$r][$j]
$array[$r][$j] = $aSwap[0][$j]
Next
Next
Else
Local $aSwap[1]
For $i = $startindex To $u1
$r = Random($startindex, $u1, 1)
$aSwap[0] = $array[$i]
$array[$i] = $array[$r]
$array[$r] = $aSwap[0]
Next
EndIf
Return 1
EndFunc
Du mischst das Array und nimmst die Reihenfolge der Zahlen Lochnummer.
Gruß,
UEZ
Hier ein andere Variante:
[autoit]
#include <Array.au3>
Dim $aArray[6] = [1, 2, 3, 4, 5, 6]
$aNewArray = _ArrayPermute($aArray, ",") ;permutiere Array
MsgBox(0, "Zufall", "Löcher Reihenfolge: " & StringTrimRight($aNewArray[Random(1, $aNewArray[0], 1)], 2))
Idee: es werden alle Möglichkeiten (Permutation) der 6 Zahlen in ein Array abgelegt und anschließend per Zufall ausgesucht.
Gruß,
UEZ