Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. ....and don't get me in trouble. The one chatting with you is well respected by me and a moderator in this site. And I didn't like your typo in regards to the name. And don't say "my English", I've read every post you made.
  3. I don't see that include. Nor any code. Don't upload the script as I will not download it. When posting code, do it in a code box. Make sure is running code and not just chucks.
  4. thanks argumentum for replying. what I am looking for is how to save the time as soon as I close it Chronometer.au3 example: time -05:35 and I close it .au3. when I open the .au3 again it will continue in the time -05:34.
  5. Today
  6. Hello Jose, I apologize for the misunderstandings. I'm just learning to program with autoit. If the problem is that you don't want me to post about the stopwatch? I understand you. but in this case I just want to learn how to program with autoit. I don't know what the problem is that you have with me and I would like to solve it? I've already apologized to you, about my question, I just want you to save the elapsed time and then continue where you left off. I am just asking for help on how to do it or where to look for it or examples that can help me. just that sorry for my bad English, I hope you understand me.
  7. The output comes out as weird characters like a symbol as shown in the attached image. I'm trying to get the whole page content (source) and then parse the data I need. I'm just wondering if you know a way to get the source code for that page again. I'd do it the _IECreate /w _IEDocReadHTML method but that makes my tool run slower because it technically has to open a hidden browser and then take the source code from that and then close that hidden browser, but if there's no solution to the _InetGetSource way then i'll do it.
  8. Yesterday
  9. The script doesn't run since you use some unknown script called Print.au3 (at least in the latest AutoIt version). If you comment the line then the script run but the collision doesn't seems to work. Also the flicker is present even when the length of the snake it's just one and get worse when the length increase. Mabye drawing the objects using GDI+ will fix this issue. Overall it's a good start but it leaves room for improvements.
  10. Sometimes, the most interesting discoveries happen by accident. That's how I stumbled upon an old post presenting a classic version of the game Snake. However, rather than simply appreciating the game as it was, I saw an opportunity for improvement by using AutoItObject.au3 , a powerful tool that didn't exist at the time of the original version's creation. In this article, I'll introduce you to my object-oriented version of Snake Game, which brings flexibility and modernity to this timeless classic. AutoItObject.au3 is an incredibly flexible tool that allows for modular and efficient application and game development. With this library, I was able to completely rethink the structure of the Snake game, transforming it into a rich and dynamic object-oriented experience. This means that every entity in the game, from the snake to the food to the user interface, is represented as a distinct object, offering extraordinary flexibility and extensibility. One of the main features of my version of Snake Game is the ability for players to express their own preferences and customize the gaming experience to their liking. Whether adjusting the score, modifying the difficulty level, or adding new game elements, players have the freedom to shape the game to suit their preferences. Despite its underlying complexity, using AutoItObject.au3 makes the code for Snake Game surprisingly simple and easy to understand. Each game object is carefully encapsulated and modeled to accurately reflect its behavior in the real world. This means that developers can easily add new features or modify the game without compromising its stability or quality. By reimagining Snake Game through the lens of object-oriented programming with AutoItObject.au3, I was able to create a version of the game that combines the simplicity of the original classic with the flexibility and modernity of object-oriented programming. I look forward to seeing how this version evolves over time, and I hope it inspires other developers to rethink their own projects using this powerful library. #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 <Print.au3> #include <Misc.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _AutoItObject_Startup() Func Snake($oPoint = 0, $Board = Default) Local $aRandomDirectionTab = [-1, 0, 1] Local $dx = $aRandomDirectionTab[Int(Random(0, 2, 1))] Local $dy = $aRandomDirectionTab[Int(Random(0, 2, 1))] Local $iLowSpeed = 100 Local $foodCounter = 0 If $Board = Default Then $Board = GUICreate("Snake", 400, 400) GUISetBkColor(0x000000) GUISetState() Local $aBoardPos = WinGetClientSize($Board) If @error Then Return SetError(1, 0, False) ; window not found Local $iBoardWidth = $aBoardPos[0] Local $iBoardHeight = $aBoardPos[1] Local $X = Random(10, $iBoardWidth - 10, 1) Local $Y = Random(10, $iBoardHeight - 10, 1) If $oPoint = 0 Then $oPoint = Point($X, $Y) Local $aMap[] MapAppend($aMap, $oPoint) Local $oFood = Point(Random(10, $iBoardWidth - 10), Random(10, $iBoardHeight - 10), 39219) Local $sClass = _AutoItObject_Class() With $sClass .Create() .AddProperty("head", $ELSCOPE_PRIVATE, $oPoint) .AddProperty("aMap", $ELSCOPE_PRIVATE, $aMap) .AddProperty("food", $ELSCOPE_PRIVATE, $oFood) .AddProperty("foodCounter", $ELSCOPE_PRIVATE, $foodCounter) .AddProperty("dx", $ELSCOPE_PRIVATE, $dx) .AddProperty("dy", $ELSCOPE_PRIVATE, $dy) .AddProperty("Board", $ELSCOPE_PRIVATE, $Board) .AddProperty("speedLevel", $ELSCOPE_PRIVATE, $iLowSpeed) .AddProperty("iBoardWidth", $ELSCOPE_PRIVATE, $iBoardWidth) .AddProperty("iBoardHeight", $ELSCOPE_PRIVATE, $iBoardHeight) .AddMethod("getBoard", "_getBoard") .AddMethod("setSpeedLevel", "_setSpeedLevel") .AddMethod("getSpeedLevel", "_getSpeedLevel") .AddMethod("runGameLoop", "_runGameLoop") .AddMethod("setdx", "_setdx") .AddMethod("setdy", "_setdy") .AddMethod("getdx", "_getdx") .AddMethod("getdy", "_getdy") .AddMethod("sleepW", "_sleepW") .AddMethod("getMap", "_getMap") .AddMethod("setMap", "_setMap") .AddMethod("getHead", "_getHead") .AddMethod("getBoardHeight", "_getBoardHeight") .AddMethod("getBoardWidth", "_getBoardWidth") .AddMethod("getFoodCounter", "_getFoodCounter") .AddMethod("setFoodCounter", "_setFoodCounter", True) .AddMethod("move", "_move", True) .AddMethod("generateFood", "_generateFood") .AddMethod("setFood", "_setFood") .AddMethod("getFood", "_getFood") .AddDestructor("_destructor") EndWith Return $sClass.Object EndFunc ;==>Snake Func _destructor($this) ConsoleWrite("Destructor ....." & @CRLF) Local $aMap = $this.getMap() For $oPoint In $aMap $oPoint = 0 Next $aMap = 0 $this.setMap(0) EndFunc ;==>_destructor Func _getFoodCounter($this) Return $this.foodCounter EndFunc ;==>_getFoodCounter Func _setFoodCounter($this, $foodCounter) $this.foodCounter = $foodCounter EndFunc ;==>_setFoodCounter Func _setSpeedLevel($this, $iLevel) $this.speedLevel = $iLevel EndFunc ;==>_setSpeedLevel Func _getSpeedLevel($this) Return $this.speedLevel EndFunc ;==>_getSpeedLevel Func _getBoard($this) Return $this.Board EndFunc ;==>_getBoard Func _runGameLoop($this) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop If _IsPressed(25) Then $this.setdx(-1) $this.setdy(0) EndIf If _IsPressed(27) Then $this.setdx(1) $this.setdy(0) EndIf If _IsPressed(26) Then $this.setdx(0) $this.setdy(-1) EndIf If _IsPressed(28) Then $this.setdx(0) $this.setdy(1) EndIf If _IsPressed(53) Then $this.sleepW() EndIf $this.move() Sleep($this.getSpeedLevel()) WEnd EndFunc ;==>_runGameLoop Func _getBoardWidth($this) Return $this.iBoardWidth EndFunc ;==>_getBoardWidth Func _getBoardHeight($this) Return $this.iBoardHeight EndFunc ;==>_getBoardHeight Func _generateFood($this) Local $oFood = Point(Random(10, $this.getBoardWidth() - 10), Random(10, $this.getBoardHeight() - 10), 39219) $this.setFood($oFood) EndFunc ;==>_generateFood Func _setFood($this, $oFood) $this.food = $oFood EndFunc ;==>_setFood Func _getFood($this) Return $this.food EndFunc ;==>_getFood Func _getHead($this) Return $this.head EndFunc ;==>_getHead Func _setdx($this, $dx) $this.dx = $dx EndFunc ;==>_setdx Func _setdy($this, $dy) $this.dy = $dy EndFunc ;==>_setdy Func _getdx($this) Return $this.dx EndFunc ;==>_getdx Func _getdy($this) Return $this.dy EndFunc ;==>_getdy Func _getMap($this) Return $this.aMap EndFunc ;==>_getMap Func _setMap($this, $aMap) $this.aMap = $aMap EndFunc ;==>_setMap Func _move($this) Local $aMap = $this.getMap() Local $head = $aMap[0] Local $newX = $head.getXPos() + $this.getdx() * 10 Local $newY = $head.getYPos() + $this.getdy() * 10 ; Vérifier si la tête du serpent sort de l'écran If $newX <= 0 Or $newX >= $this.getBoardWidth() - 10 Or $newY <= 0 Or $newY >= $this.getBoardHeight() - 10 Then Return SetError(1, 0, False) EndIf Local $oFood = $this.getFood() If $head.checkCollision($oFood) Then $this.setFoodCounter($this.getFoodCounter() + 1) Local $lastSegment = $aMap[UBound($aMap) - 1] Local $lastX = $lastSegment.getXPos() + $this.getdx() * 10 Local $lastY = $lastSegment.getYPos() + $this.getdy() * 10 MapAppend($aMap, Point($lastX, $lastY)) $this.setMap($aMap) If $this.getFoodCounter() = 4 Then Local $newSpeedLevel = $this.getSpeedLevel() - 20 If $newSpeedLevel < 0 Then $newSpeedLevel = 1 $this.setSpeedLevel($newSpeedLevel) $this.setFoodCounter(0) EndIf GUICtrlDelete($oFood.getID()) $this.generateFood() EndIf ; Mettre à jour la position de la tête du serpent $head.setXPos($newX) $head.setYPos($newY) ; Déplacer les segments du serpent For $i = UBound($aMap) - 1 To 1 Step -1 $aMap[$i].setXPos($aMap[$i - 1].getXPos()) $aMap[$i].setYPos($aMap[$i - 1].getYPos()) Next EndFunc ;==>_move ;bug Func _sleepW(ByRef $this) Do Do Sleep(100) Until _IsPressed(25) Or _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) If _IsPressed(25) Then $this.setdx(-1) $this.setdy(0) EndIf If _IsPressed(27) Then $this.setdx(1) $this.setdy(0) EndIf If _IsPressed(26) Then $this.setdx(0) $this.setdy(-1) EndIf If _IsPressed(28) Then $this.setdx(0) $this.setdy(1) EndIf Until _IsPressed(25) Or _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) EndFunc ;==>_sleepW Func Point($X = 0, $Y = 0, $iClolor = 16777215) Local $idLabel = GUICtrlCreateLabel("", $X, $Y, 10, 10, 0x0001) ; $BS_CENTER GUICtrlSetBkColor($idLabel, $iClolor) Local $cPoint = _AutoItObject_Class() With $cPoint .Create() .AddProperty("___sType___", $ELSCOPE_PRIVATE, "Point") .AddProperty("X", $ELSCOPE_PRIVATE, $X) .AddProperty("Y", $ELSCOPE_PRIVATE, $Y) .AddProperty("iColor", $ELSCOPE_PRIVATE, $iClolor) .AddProperty("idLabel", $ELSCOPE_PRIVATE, $idLabel) .AddMethod("getObjType", "_getObjType") .AddMethod("setXPos", "_setXPos") .AddMethod("setYPos", "_setYPos") .AddMethod("getID", "_getID") .AddMethod("setID", "_setID") .AddMethod("getXPos", "_getXPos") .AddMethod("getYPos", "_getYPos") .AddMethod("checkCollision", "_checkCollision") EndWith Return $cPoint.Object EndFunc ;==>Point Func _getObjType($this) Return $this.___sType___ EndFunc ;==>_getObjType Func _checkCollision($this, $oPoint) If Not IsObj($oPoint) Then Return SetError(1, 0, False) Local $sType = $oPoint.getObjType() If $sType <> "Point" Then Return SetError(2, 0, False) Local $aPos1 = ControlGetPos("", "", $this.getID()) Local $aPos2 = ControlGetPos("", "", $oPoint.getID()) If $aPos1[0] + $aPos1[2] >= $aPos2[0] And $aPos1[0] <= $aPos2[0] + $aPos2[2] And $aPos1[1] + $aPos1[3] >= $aPos2[1] And $aPos1[1] <= $aPos2[1] + $aPos2[3] Then Return True EndIf Return False EndFunc ;==>_checkCollision Func _setXPos($this, $iX) $this.X = $iX GUICtrlSetPos($this.idLabel, $iX, $this.getYPos()) EndFunc ;==>_setXPos Func _setYPos($this, $iY) $this.Y = $iY GUICtrlSetPos($this.idLabel, $this.getXPos(), $iY) EndFunc ;==>_setYPos Func _getXPos($this) Return $this.X EndFunc ;==>_getXPos Func _getYPos($this) Return $this.Y EndFunc ;==>_getYPos Func _getID($this) Return $this.idLabel EndFunc ;==>_getID Func _setID($this, $idLabel) $this.idLabel = $idLabel EndFunc ;==>_setID ;*************************************************** Global $sNake = Snake() $sNake.runGameLoop() $sNake = 0 ;************************************************** _AutoItObject_Shutdown()
  11. btw. Used several times today. It worked like a charm.
  12. There was a time when I had major depression combined with professional burnout. I'm getting over it. In the meantime, I didn't feel like programming, so I might have forgotten some things
  13. This is what we call decompiling and there are strict forum rules around that! *click*
  14. You are getting old my friend and start forgetting things
  15. I inherited a bunch of AutoIT scripts from a previous engineer and majority of them are in a code repository so I have access to the source code. There are a couple however that I aren't in the repo that I need to get the source code for. My issue is that they are .a3x files and are encoded. How would I go about decoding these files so I can get the source code?
  16. That's more like it. now I get... Eagle 1785 Face 1690
  17. I changed it to 2 decimals, too. Now more colors will be used.
  18. Earlier i adjusted this part... Select Case fGreys Case 0.05 To 0.18 iB = 1 Case 0.19 To 0.34 iG = 1 Case 0.35 To 0.50 iB = 1 iG = 1 Case 0.51 To 0.66 iR = 1 Case 0.67 To 0.82 iR = 1 iB = 1 Case 0.83 To 0.95 iR = 1 iG = 1 End Select ..to use only 2 decimal places, if the decimal places are longer than 2 it misses some going from case to case, scroll up and see the changes.
  19. Here the function in FB: Function _GDIPlus_BitmapCreateFakeGreyscale(hImage As Any Ptr, bGDI As BOOL = False) As Any Ptr Export Dim As Single iW, iH Dim As Double fGreys, fLuma Dim As Any Ptr hBitmap_Greyscale, hGDIBitmap Dim As BitmapData tBitmapData, tBitmapData_Greyscale Dim As Long iX, iY, iRowOffset, iColor, c, iR, iG, iB GdipGetImageDimension(hImage, @iW, @iH) Dim As RECT tRect = Type(0, 0, iW - 1, iH - 1) GdipCreateBitmapFromScan0(iW, iH, 0, PixelFormat32bppARGB, 0, @hBitmap_Greyscale) GdipBitmapLockBits(hBitmap_Greyscale, Cast(Any Ptr, @tRect), ImageLockModeWrite, PixelFormat32bppARGB, @tBitmapData_Greyscale) GdipBitmapLockBits(hImage, Cast(Any Ptr, @tRect), ImageLockModeRead, PixelFormat32bppARGB, @tBitmapData) For iY = 0 To iH - 1 iRowOffset = iY * iW For iX = 0 To iW - 1 iColor = Cast(ULong Ptr, tBitmapData.Scan0)[iRowOffset + iX] iR = (iColor Shr 16) And &hFF iG = (iColor Shr 8) And &hFF iB = iColor And &hFF fLuma = (iR * 213 + iG * 715 + iB * 72) / 1000 'fLuma = ((iR * 0.3) + (iG * 0.59) + (iB * 0.11) / 3) fGreys = fLuma - CUByte(fLuma) fLuma = CUByte(fLuma) iR = 0 iG = 0 iB = 0 Select Case fGreys Case 0.05 To 0.18 iB = 1 Case 0.19 To 0.34 iG = 1 Case 0.35 To 0.50 iB = 1 iG = 1 Case 0.51 To 0.66 iR = 1 Case 0.67 To 0.82 iR = 1 iB = 1 Case 0.83 To 0.95 iR = 1 iG = 1 End Select Cast(ULong Ptr, tBitmapData_Greyscale.Scan0)[iRowOffset + iX] = &hFF000000 Or ((fLuma + iR) Shl 16) Or ((fLuma + iG) Shl 8) Or (fLuma + iB) Shl 0 Next Next GdipBitmapUnlockBits(hBitmap_Greyscale, @tBitmapData_Greyscale) GdipBitmapUnlockBits(hImage, @tBitmapData) If bGDI Then GdipCreateHBITMAPFromBitmap(hBitmap_Greyscale, @hGDIBitmap, &hFF000000) GdipDisposeImage(hBitmap_Greyscale) Return hGDIBitmap EndIf Return hBitmap_Greyscale End Function I will play around with different values...
  20. Nice, how does the code look in freebasic, not that I'm gonna start with freebasic, just curious. I noticed we dont get same results, I take it you didnt use LUMA but the " (iR * 213 + iG * 715 + iB * 72) / 1000" you mentioned, quite a difference, i get... Eagle.jpg: yours 1020 grays, mine 1654 Face, png: yours 978, mine 1576 Maybe a switch parameter where the user can select between "Average", "LUMA", "Yours" and whatever other there might be.
  21. Done. Check out Download the 7-Zip archive and look for _GDIPlus_BitmapApplyFilter_FakeGreyscale.au3 example.
  22. First, I must sincerely apologize to @paw for being so stubborn in refusing to incorporate the notion of injection into my UDF. After careful consideration, I must admit my mistake. It was a very good idea, and I should have agreed to it. But to keep the UDF completely safe, it will be possible to authorize injection or refuse it. When the injection is authorized, the Send and Mouse* functions will operate normally even if manual inputs are rejected. New version available
  23. My fault - wrong wording. Let me correct my statement. I missed this one. I missed this functionality. I was not a conscious user in this regard.
  24. When you post code, use the method shown in the link. Put all statements into a func and link the function with a HotKeySet , something like this : HotKeySet("{F8}", DelCommand) While Sleep(100) WEnd Func DelCommand() Send("+{SPACE}") ;select row Sleep(100) Send("{F10}") ;opens hotkey menu Sleep(100) Send("h") ;opens home menu Sleep(100) Send("d") ;opens delete menu Sleep(100) Send("r") ;deletes row EndFunc ;==>DelCommand ps. you could also use Excel UDF, to perform those tasks instead of sending keys, which would make your script way more reliable.
  25. Hello, I'm super new to AutoIT and I'm working on a making a series of commands to clean up one of my large excel files this includes the reuse of the same commands: Send("+{SPACE}") ;select row Sleep(100) Send("{F10}") ;opens hotkey menu Sleep(100) Send("h") ;opens home menu Sleep(100) Send("d") ;opens delete menu Sleep(100) Send("r") ;deletes row and I was wondering if there was a way to define that group of commands (i,e. "DEL COMMAND" = [then type out those commands once]) so instead of copying/pasting the command multiple times I could just type the defining term of DEL COMMAND or whatever defining term. A while/do/for loop won't work because there's inconsistent down/over keys that need to happen between sets of the DEL COMMAND.
  26. Agreed. But I would call the css "/custom.css" to clarify that is not the expected default and that is the one that gets customized. Overwritten manually or by the css editor. Edit: >When that is the case we are forced to any relative path to the helpfile and those are by default read only when the installer is used. Yes. Maybe replying with a note about the name of the css was not needed as you later realized that the setup is more involved than earlier realized. That thinking back..., I should have added the sources to the zip. I too understand better following code than reading a description.
  1. Load more activity
×
×
  • Create New...