Jump to content

All Activity

This stream auto-updates

  1. Today
  2. Negative lookahead: Local $sLine = '{"Test":"test:test":"\"test:test\"":"Test:Test:Test":"Test"}' ConsoleWrite(StringRegExpReplace($sLine, ':(?!")', '') & @CRLF) or a more precise pattern that is aware of possible spaces: Local $sLine = '{"Test" : "test : test" : "\"test : test\"" : "Test : Test : Test" : "Test"}' ConsoleWrite(StringRegExpReplace($sLine, '((?<![" ])(?: *):(?: *)(?![" ]))', '') & @CRLF)
  3. I have this string : '{"Test":"test:test":"\"test:test\"":"Test:Test:Test":"Test"}' And I would like to remove all colon inside quotation marks and keep the others outside. My resulting string should be : '{"Test":"testtest":"\"testtest\"":"TestTestTest":"Test"}' Notice that some quotation marks maybe escapeded. I have this that works well, but I am curious if there is a way to perform the same in a single SRER. I tried multiple things but nothing has been successful... Local $sLine = '{"Test":"test:test":"\"test:test\"":"Test:Test:Test":"Test"}' ConsoleWrite($sLine & @CRLF) ; before ConsoleWrite(RemoveColon($sLine) & @CRLF) ;after Func RemoveColon($sText) Local $iPos = 1, $sFinal, $aTemp While True $aTemp = StringRegExp($sText, '(.*?")', 1, $iPos) ; get starting quote If @error Then ExitLoop $sFinal &= $aTemp[0] $iPos += StringLen($aTemp[0]) Do $aTemp = StringRegExp($sText, '(.*?")', 1, $iPos) $iPos += StringLen($aTemp[0]) $sFinal &= StringReplace($aTemp[0], ":", "") Until StringRight($aTemp[0], 2) <> '\"' ; till closing quote WEnd Return $sFinal & StringRegExp($sText, "(.*)", 1, $iPos)[0] EndFunc of course 'test' can be anything
  4. Github repository link: https://github.com/genius257/Manga Long story short: I wanted a simple manga reader and this project also let me test my AutoIt3 HTTP server code with real usage. This serves mostly as an example on how my AutoIt-HTTP-Server could be used for letting the browser handle all the UI. It does work as a manga downloader and reader, but currently only supports taadd. Steps to try it: Download and extract repository: https://github.com/genius257/Manga/archive/refs/heads/main.zip Open settings.ini and change Path under [AU3] to match your autoit installation folder (Example: C:\Program Files (x86)\AutoIt3). You can also change the Port under [core] if port 80 is occupied. Run main.au3 and goto http://localhost (add your port if anything other than 80), or use the "Open in browser" option from the right click on the tray menu.
  5. Assembly. I usually use FASM but you can use whatever flavor you like. 8B 74 24 04 mov esi, [esp+4] ; ESI = pointer to the data struct 8B 4C 24 08 mov ecx, [esp+8] ; ECX = number of items in the struct 8B 54 24 0C mov edx, [esp+12] ; EDX = value to be deleted :next AD lodsd ; Load dword at address DS:ESI into EAX. ESI is incremented by 4. 39 D0 cmp eax, edx ; Compare data loaded in EAX with the value that you intend to delete 75 07 jne skip ; If is different then skip the overwrite operation (with default value) C7 46 FC FF FF FF FF mov DWORD PTR [esi-4], 0xffffffff ; Otherwise overwrite previously compared data with default value :skip E2 F2 loop next ; Loop the process until every item in the struct is verified C2 0C 00 ret 12 ; Return from function This is possible but it won't break the original functionality, since you tried to dinamically obtain a new minimum (and distinct) value that was not allocated yet? Global $tData = DllStructCreate('int Data[20]') FillStruct($tData) DllStructSetData($tData, 'Data', 22, 6) DllStructSetData($tData, 'Data', 23, 9) DllStructSetData($tData, 'Data', 25, 11) DllStructSetData($tData, 'Data', 25, 17) ConsoleWrite("Items containing the value 25: " & CountValue($tData, 25) & @CRLF) ConsoleWrite("Empty items: " & CountValue($tData, -1) & @CRLF) Func FillStruct($tStruct) Local $Code = Binary('0x8B7424048B4C2408C706FFFFFFFF83C604E2F5C20800') Local $iSize = BinaryLen($Code) Local $tCode = DllStructCreate('byte Code[' & $iSize & ']') DllStructSetData($tCode, 'Code', $Code) Local $aCall = DllCallAddress('int', DllStructGetPtr($tCode), 'ptr', DllStructGetPtr($tStruct), 'int', DllStructGetSize($tStruct) / 4) EndFunc Func CountValue($tStruct, $iValue) Local $Code = Binary('0x8B7424048B4C24088B54240C31DBAD39D0750143E2F889D8C20C00') Local $iSize = BinaryLen($Code) Local $tCode = DllStructCreate('byte Code[' & $iSize & ']') DllStructSetData($tCode, 'Code', $Code) Local $aCall = DllCallAddress('int', DllStructGetPtr($tCode), 'ptr', DllStructGetPtr($tStruct), 'int', DllStructGetSize($tStruct) / 4, 'int', $iValue) Return $aCall[0] EndFunc And here is the ASM code and the corresponding binary data from my Real Time Assembler.
  6. Yes, that's it exactly thanks. One more another thing...I tried to figure it out myself, but I don't understand how this is working...particularly how the Binary $Code is created in the first place, where does that string come from. Or what to search for exactly to figure this out. Anyway, can you give me a search function to search for how many of a particular value are in the structure (I've expanded the use of this)? And also tell me what exactly I can read up on, or what to search for, to try and learn about this and coming up binary strings necessary to do things I want? Thanks
  7. I could verify your restore parameters (and syntax etc.) @Nine and could test it successfully on Chrome, Firefox and MSEdge. I also created (a few minutes ago) an GitHub Issue and PR for this topic that can be reviewed by @Danp2 when he have the time for it. I believe _WD_Window($sSession, 'restore') should be more intuitive or for some even more familiar like in other frameworks like Selenium or WebdriverIO. Let's see what will happen 😇 . ----------------- @MWIProd I guess this thread can be closed, right? Best regards Sven
  8. Salutations @teodoric666. Here how I would do it : #include <File.au3> Local $sDate = @MDAY & "-" & @MON Local $sSource = "C:\Users\" & @UserName & "\AppData\" Local $sBackupPath = "D:\" & $sDate & '\Backup\' Local $aList = _FileListToArrayRec($sSource, "*||LocalLow", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_RELPATH) ProgressOn("Backup " & $sDate, "0% completed") Local $nProgress, $nPrec For $i = 1 To $aList[0] FileCopy($sSource & $aList[$i], $sBackupPath & $aList[$i], $FC_OVERWRITE + $FC_CREATEPATH) $nProgress = Int($i / $aList[0] * 100) If $nProgress = $nPrec Then ContinueLoop ProgressSet($nProgress, $nProgress & "% completed") $nPrec = $nProgress Next ProgressSet(100, "Backup completed") Sleep(2000) ProgressOff()
  9. Hello Sven, I was a little busy, sorry if I have not contacted you before, I did not try a thing unfortunately, I will try in these days if time will allow it, thx very much
  10. I made an exe to save the AppData directory it works quite well I would like to add a progress bar but I am unable to, I don't have the level can anyone help me if not is not too complicated for you of course Thanks a lot #include <FileConstants.au3> #include <File.au3> #include <Date.au3> $date = @MDAY & "-" & @MON Local $AppDataPath = @AppDataDir Local $LocalAppDataPath = @LocalAppDataDir Local $BackupPath = "D:\" & $date & '.\Backup' Local $Search = FileFindFirstFile($AppDataPath & "\*.*") FileClose($Search) ; Copie récursive des fichiers et dossiers Func CopyFolder($SourcePath, $DestPath) Local $Search = FileFindFirstFile($SourcePath & "\*.*") If $Search = -1 Then Return Local $CopiedFiles = 0 While 1 Local $File = FileFindNextFile($Search) If @error Then ExitLoop If Not @extended Then ; Fichier trouvé, copie vers le répertoire de sauvegarde FileCopy($SourcePath & "\" & $File, $DestPath & "\" & $File, $FC_OVERWRITE) $CopiedFiles += 1 ElseIf StringInStr(FileGetAttrib($SourcePath & "\" & $File), "D") Then ; Dossier trouvé, récursion If $File <> "." And $File <> ".." Then DirCreate($DestPath & "\" & $File) CopyFolder($SourcePath & "\" & $File, $DestPath & "\" & $File) EndIf EndIf WEnd FileClose($Search) EndFunc ; Début de la copie des répertoires AppData, Local et Roaming CopyFolder($AppDataPath, $BackupPath &"\AppData\Roaming") CopyFolder($LocalAppDataPath, $BackupPath &"\AppData\Local") ; Affichage du message à la fin de la copie MsgBox(64, "Copie terminée", "La sauvegarde des répertoires Roaming , Local est terminée.")
  11. Another way less hacky maybe : #include <GUIConstantsEx.au3> #include <Misc.au3> If Not _Singleton("MyGui", 1) Then Exit WinSetState("gui V1.1.1", "", @SW_SHOW) + WinSetState("gui V1.1.1", "", @SW_RESTORE) $gui = GUICreate("gui V1.1.1", 445, 262, -1, -1, -1, -1) $button = GUICtrlCreateButton("Button", 60, 20, 100, 30, -1, -1) $bHide = GUICtrlCreateButton("Hide", 60, 60, 100, 30, -1, -1) $label = GUICtrlCreateLabel("My Text", 80, 100, 50, 15, -1, -1) $label2 = GUICtrlCreateLabel("My Text", 80, 130, 50, 15, -1, -1) GUISetState(@SW_SHOWMINIMIZED) WinSetState($gui, "", @SW_HIDE) $counter = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button $counter += 1 GUICtrlSetData($label, $counter) Case $bHide WinSetState($gui, "", @SW_HIDE) EndSwitch WEnd Yes, it made me laugh too...
  12. #include <GUIConstantsEx.au3> #include <Misc.au3> If WinExists("[TITLE:gui V1.1.1; CLASS:AutoIt v3 GUI]") Then WinActivate("[TITLE:gui V1.1.1; CLASS:AutoIt v3 GUI]") Send("+^h") Exit EndIf $beHide = False HotKeySet("+^h", "GuiHider") $gui = GUICreate("gui V1.1.1", 445, 262, -1, -1, -1, -1) $button = GUICtrlCreateButton("Button", 60, 20, 100, 30, -1, -1) $bHide = GUICtrlCreateButton("Hide", 60, 60, 100, 30, -1, -1) $label = GUICtrlCreateLabel("My Text", 80, 100, 50, 15, -1, -1) GUISetState(@SW_HIDE) $counter = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete() ; this should be here too Exit Case $button $counter += 1 GUICtrlSetData($label, $counter) Case $bHide GuiHider() EndSwitch WEnd Func GuiHider() ConsoleWrite("$beHide=" & $beHide & @CRLF) If $beHide = True Then GUISetState(@SW_HIDE) $beHide = False Else GUISetState(@SW_SHOW) $beHide = True EndIf EndFunc ;==>GuiHider
  13. Yes, I came up with this idea earlier. Look a few posts above It seems that there is no other way to do it. But thank you for your help
  14. #include <GUIConstantsEx.au3> #include <Misc.au3> If Not _Singleton("MyGui", 1) Then WinSetState("gui V1.1.1", "", @SW_SHOW) WinActivate("gui V1.1.1") ; easier to see when you "click click" the script Exit 5 EndIf Global $gui = GUICreate("gui V1.1.1",445,262,-1,-1,-1,-1) Global $button = GUICtrlCreateButton("Button",60,20,100,30,-1,-1) Global $bHide = GUICtrlCreateButton("Hide",60,60,100,30,-1,-1) Global $label = GUICtrlCreateLabel("My Text",80,100,50,15,-1,-1) WinSetTrans($gui, "", 0) ; fake not there GUISetState(@SW_SHOW) ; display the GUI WinSetState($gui, "", @SW_HIDE) ; hide WinSetTrans($gui, "", 255) ; restore tranparency back to solid $counter = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete() ; this should be here too Exit case $button $counter +=1 guictrlsetdata($label, $counter) case $bHide ConsoleWrite('case $bHide' & @CRLF) WinSetState($gui, "", @SW_HIDE) EndSwitch WEnd .. is a bit hacky but, if that does what you describe, then you are good. The GUIGetMsg() not working is either a bug or a caveat of win32.
  15. Hi Argumentum No, I didn't forget to add GUISetState() By design, the script is not supposed to show the window on startup. The window is supposed to show only after starting again the exe. The application will be started automatically at Windows startup and will be hidden. The application is an address book. The application is to have an option to be invoked (show main window) in three ways: 1. keyboard shortcut 3. clicking on the systray icon 4. running a shortcut on the desktop Yes, at first I thought that Nine's solution would be ok but unfortunately not in the case when we do not want to show the window at the start of the script.
  16. All, sorry for the long delay, work took over. The script is: #include <WinAPIShellEx.au3> Local $PhotosPath = @UserProfileDir & "\Pictures\iCloud Photos\Photos\" Local $PhotosPathBackup = @UserProfileDir & "\Pictures\iCloudPhotosBackUp\" If not FileExists($PhotosPathBackup) Then DirCreate($PhotosPathBackup) ShellExecute($PhotosPath) Sleep(500) If @UserName = "Raziel" Then Send("^e") Else Send("^a") EndIf Sleep(500) Send("{LSHIFT}+{F10}") Sleep(200) Send("{DOWN 14}") Sleep(100) Send("{ENTER}") Sleep(30000) ;one second just for testing change to (1000*60*30) for wait 30 minutes ;some bug here it seems to be always overwrite file ;~ _WinAPI_ShellFileOperation( $PhotosPath & "*.*", $PhotosPathBackup, $FO_COPY,BitOR( $FOF_NOCONFIRMMKDIR, $FOF_NOCONFIRMATION , $FOF_NOERRORUI, $FOF_NO_UI)) Local $hSearch = FileFindFirstFile($PhotosPath & "*.*") While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If not FileExists($PhotosPathBackup & $sFileName) Then FileCopy($PhotosPath & $sFileName, $PhotosPathBackup) WEnd FileClose($hSearch) MsgBox(0,"Information","Process Finsihed" & @CRLF & "Script will be closed in 5 Seconds...",5) This works in principle, but - for whatever reason, not all photos are downloaded, and clicking the menu item "keep on computer" toggles the command, so every other time it un-sets what I want to achieve. But it's the closest I have. Thanks to @Danyfirex
  17. 'cause you forgot to add GUISetState() ; display the GUI No big deal #include <GUIConstantsEx.au3> #include <Misc.au3> If Not _Singleton("MyGui", 1) Then WinSetState("gui V1.1.1", "", @SW_SHOW) WinActivate("gui V1.1.1") ; easier to see when you "click click" the script Exit 5 EndIf $gui = GUICreate("gui V1.1.1",445,262,-1,-1,-1,-1) $button = GUICtrlCreateButton("Button",60,20,100,30,-1,-1) $bHide = GUICtrlCreateButton("Hide",60,60,100,30,-1,-1) $label = GUICtrlCreateLabel("My Text",80,100,50,15,-1,-1) GUISetState() ; display the GUI $counter = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete() ; this should be here too Exit case $button $counter +=1 guictrlsetdata($label, $counter) case $bHide WinSetState($gui, "", @SW_HIDE) EndSwitch WEnd Edit: ..read the whole post and still believe that this code should have no problem. Edit 2: I see that you marked yourself as solving the problem. Genieal ?
  18. Thank you for your reply. I'm just not sure we understand each other. Use the code below and see if the button works for you after you run the exe a second time. The conditions that must be met are that the window after the startup must be hidden. The window is to appear only after the second launch of the exe. #include <GUIConstantsEx.au3> #include <Misc.au3> If Not _Singleton("MyGui", 1) Then Exit WinSetState("gui V1.1.1", "", @SW_SHOW) $gui = GUICreate("gui V1.1.1",445,262,-1,-1,-1,-1) $button = GUICtrlCreateButton("Button",60,20,100,30,-1,-1) $bHide = GUICtrlCreateButton("Hide",60,60,100,30,-1,-1) $label = GUICtrlCreateLabel("My Text",80,100,50,15,-1,-1) $counter = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $button $counter +=1 guictrlsetdata($label, $counter) case $bHide WinSetState($gui, "", @SW_HIDE) EndSwitch WEnd
  19. EDIT : I've added a pause feature for the snake. You can now press the S key to put the game on hold and take a coffee break.
  20. I've come up with a simplified version of the code where I've addressed the issue of the snake's self-collision. Additionally, you have the freedom to choose the color of the snake. This showcases the versatility of the tool I'm using. #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# ======================================================================================================================= ; Title .........: Snake Game ; AutoIt Version : 3.3 ; AutoItObject Version : v1.2.8.2 ; Language ......: English ; Description ...: A simple Snake game implementation using AutoIt->AutoItObject.au3. ; Dependencies ..: AutoItObject.au3 ; Author ........: Numeric ; =============================================================================================================================== #include <GUIConstantsEx.au3> #include "AutoItObject.au3" #include <GDIPlus.au3> #include <Misc.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _GDIPlus_Startup() _AutoItObject_Startup() Func Snake($iBgColor = 0xFF0000FF) Local $dx = Random(-1, 1, 1) Local $dy = Random(-1, 1, 1) Local $aMap[] MapAppend($aMap, Point(Random(10, 380, 1), Random(10, 380, 1))) ;food MapAppend($aMap, Point(Random(10, 380, 1), Random(10, 380, 1))) ; head Local $Board = GUICreate("Snake", 400, 400) GUISetState() Local $aBoardPos = WinGetClientSize($Board) Local $iBoardWidth = $aBoardPos[0] Local $iBoardHeight = $aBoardPos[1] Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Board) Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iBoardWidth, $iBoardHeight, $hGraphics) Local $hGraphicsCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphicsCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) Local $hBrush = _GDIPlus_BrushCreateSolid($iBgColor) Local $hFoodBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00) ;(0x00FF00) Local $aGDIMap[] $aGDIMap["hGraphics"] = $hGraphics $aGDIMap["hBitmap"] = $hBitmap $aGDIMap["hGraphicsCtxt"] = $hGraphicsCtxt $aGDIMap["hBrush"] = $hBrush $aGDIMap["hFoodBrush"] = $hFoodBrush Local $sClass = _AutoItObject_Class() With $sClass .Create() .AddProperty("dx", $ELSCOPE_PUBLIC, $dx) .AddProperty("dy", $ELSCOPE_PUBLIC, $dy) .AddProperty("speedLevel", $ELSCOPE_PUBLIC, 100) .AddProperty("foodCounter", $ELSCOPE_PUBLIC, 0) .AddProperty("Map", $ELSCOPE_PUBLIC, $aMap) .AddProperty("gdiMap", $ELSCOPE_PUBLIC, $aGDIMap) .AddProperty("Board", $ELSCOPE_PUBLIC, $Board) .AddProperty("iBoardWidth", $ELSCOPE_PUBLIC, $iBoardWidth) .AddProperty("iBoardHeight", $ELSCOPE_PUBLIC, $iBoardHeight) .AddMethod("move", "_move") .AddMethod("drawStage", "_drawStage") .AddMethod("resetGame", "_resetGame") .AddMethod("runGameLoop", "_runGameLoop") .AddMethod("cleanUpResources", "_cleanUpResources") .AddDestructor("_cleanUpResources") EndWith Return $sClass.Object EndFunc ;==>Snake Func _runGameLoop($this) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop If _IsPressed(25) Then $this.dx = -1 $this.dy = 0 EndIf If _IsPressed(27) Then $this.dx = 1 $this.dy = 0 EndIf If _IsPressed(26) Then $this.dx = 0 $this.dy = -1 EndIf If _IsPressed(28) Then $this.dx = 0 $this.dy = 1 EndIf If _IsPressed(53) Then While 1 If _IsPressed(25) Or _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) Then ExitLoop Sleep(100) WEnd EndIf $this.drawStage() Sleep($this.speedLevel) WEnd EndFunc ;==>_runGameLoop Func _move($this) Local $aMap = $this.Map Local $head = $aMap[1] Local $newX = $head.getXPos() + $this.dx * 10 Local $newY = $head.getYPos() + $this.dy * 10 Local $hW = $newX + 10 Local $hH = $newY + 10 If $newX <= 0 Or $newX >= 390 Or $newY <= 0 Or $newY >= 390 Then MsgBox(64, "Game Over", "Collision! Game Over.") Local $iResponse = MsgBox(36, "Restart Game", "Do you want to restart the game?") If $iResponse = 6 Then $this.resetGame() Return True Else $this.cleanUpResources() _GDIPlus_Shutdown() _AutoItObject_Shutdown() Exit EndIf EndIf For $i = 2 To UBound($aMap) - 1 Local $cX = $aMap[$i].getXPos() Local $cY = $aMap[$i].getYPos() Local $cW = $cX + 10 Local $cH = $cY + 10 If $newX < $cW And $hW > $cX And $newY < $cH And $hH > $cY Then MsgBox(64, "Game Over", " SELF!!! Collision! Game Over.") $iResponse = MsgBox(36, "Restart Game", "Do you want to restart the game?") If $iResponse = 6 Then $this.resetGame() Return True Else $this.cleanUpResources() _GDIPlus_Shutdown() _AutoItObject_Shutdown() Exit EndIf EndIf Next Local $food = $aMap[0] Local $fX = $food.getXPos() Local $fY = $food.getYPos() Local $fW = $fX + 10 Local $fH = $fY + 10 If $newX < $fW And $hW > $fX And $newY < $fH And $hH > $fY Then ;generate food $aMap[0].setXPos(Random(10, 390, 1)) $aMap[0].setYPos(Random(10, 390, 1)) Local $lastSegment = $aMap[UBound($aMap) - 1] Local $lastX = $lastSegment.getXPos() + $this.dx() * 10 Local $lastY = $lastSegment.getYPos() + $this.dy() * 10 MapAppend($aMap, Point($lastX, $lastY)) $this.Map = $aMap $this.foodCounter += 1 If $this.foodCounter = 4 Then $this.speedLevel -= 20 If $this.speedLevel < 0 Then $this.speedLevel = 1 EndIf $this.foodCounter = 0 EndIf EndIf $head.setXPos($newX) $head.setYPos($newY) For $i = UBound($aMap) - 1 To 2 Step -1 $aMap[$i].setXPos($aMap[$i - 1].getXPos()) $aMap[$i].setYPos($aMap[$i - 1].getYPos()) Next EndFunc ;==>_move Func _drawStage($this) Local $gdiMap = $this.gdiMap Local $aMap = $this.Map Local $hGraphics = $gdiMap["hGraphics"] Local $hBrush = $gdiMap["hBrush"] Local $hFoodBrush = $gdiMap["hFoodBrush"] $this.move() _GDIPlus_GraphicsClear($hGraphics, 0xFF000000) _GDIPlus_GraphicsFillRect($hGraphics, $aMap[0].getXPos(), $aMap[0].getYPos(), 10, 10, $hFoodBrush) For $i = 1 To UBound($aMap) - 1 _GDIPlus_GraphicsFillRect($hGraphics, $aMap[$i].getXPos(), $aMap[$i].getYPos(), 10, 10, $hBrush) Next EndFunc ;==>_drawStage Func _resetGame($this) For $item In $this.Map $item = 0 Next $this.Map = 0 Local $aNewMap[] MapAppend($aNewMap, Point(Random(10, $this.iBoardWidth - 10), Random(10, $this.iBoardHeight - 10))) MapAppend($aNewMap, Point(Random(10, $this.iBoardWidth - 10), Random(10, $this.iBoardHeight - 10))) $this.Map = $aNewMap $this.dx = Random(-1, 1, 1) $this.dy = Random(-1, 1, 1) $this.speedLevel = 100 $this.foodCounter = 0 $this.drawStage() EndFunc ;==>_resetGame Func _cleanUpResources($this) Local $gdiMap = $this.gdiMap Local $hGraphics = $gdiMap["hGraphics"] Local $hBrush = $gdiMap["hBrush"] Local $hFoodBrush = $gdiMap["hFoodBrush"] _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hFoodBrush) _GDIPlus_Shutdown() For $gdih In $gdiMap $gdih = 0 Next $this.gdiMap = 0 For $oPoint In $this.Map $oPoint = 0 Next $this.Map = 0 _AutoItObject_Shutdown() EndFunc ;==>_cleanUpResources Func Point($X = 0, $Y = 0) Local $cPoint = _AutoItObject_Class() With $cPoint .Create() .AddProperty("X", $ELSCOPE_PRIVATE, $X) .AddProperty("Y", $ELSCOPE_PRIVATE, $Y) .AddMethod("setXPos", "_setXPos") .AddMethod("setYPos", "_setYPos") .AddMethod("getXPos", "_getXPos") .AddMethod("getYPos", "_getYPos") EndWith Return $cPoint.Object EndFunc ;==>Point Func _setXPos($this, $iX) $this.X = $iX EndFunc ;==>_setXPos Func _setYPos($this, $iY) $this.Y = $iY EndFunc ;==>_setYPos Func _getXPos($this) Return $this.X EndFunc ;==>_getXPos Func _getYPos($this) Return $this.Y EndFunc ;==>_getYPos Func _ErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc ;***************************************************************************************************************************************** Global $sNake = Snake(0xFF8B4513) $sNake.runGameLoop() $sNake = 0 ;***************************************************************************************************************************************** _AutoItObject_Shutdown()
  1. Load more activity
×
×
  • Create New...