Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/06/2024 in all areas

  1. ioa747

    TennisPong

    What can I say, the holidays are coming, ho ho ho Happy holidays to all of you with health and joy. prologue: Pong is one of the first computer games that ever created, Research Interview Series #16: Allan Alcorn, the creator of Pong This is a simple outline variation "tennis like" game, that helped me kill my time ; https://www.autoitscript.com/forum/topic/212523-tennispong/ ;---------------------------------------------------------------------------------------- ; Title...........: TennisPong.au3 ; Description.....: Pong is one of the first computer games that ever created, ; this a simple outline "tennis like" game ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 1.0 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Misc.au3> #include <WinAPISysWin.au3> HotKeySet("{ESC}", "_Exit") _Pong() Func _Pong() Local $iWidth = @DesktopWidth, $iHeight = @DesktopHeight Local $iBallSize = 25 Local $iPaddleWidth = 200, $iPaddleHeight = 165 Local $iBallX = $iWidth / 2, $iBallY = $iHeight / 2 Local $iBallSpeedX = 15, $iBallSpeedY = 15 Local $iPaddleX = ($iWidth / 2) - ($iPaddleWidth / 2) Local $iPaddelSpace = 30 Local $iScore = 0 ; Create score GUI as parent Local $hDisplay = GUICreate("TennisPong", 150, 50, $iWidth - 160, 3, $WS_POPUP, BitOR($WS_EX_COMPOSITED, $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TRANSPARENT)) Local $idScore = GUICtrlCreateLabel($iScore, 0, 0, 150, 50, $SS_CENTER) GUICtrlSetFont(-1, 30, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF21) GUISetBkColor(0x000000, $hDisplay) WinSetTrans($hDisplay, "", 80) GUISetState(@SW_SHOW, $hDisplay) ; Create paddle GUI Local $hPaddle = GUICreate("", $iPaddleWidth, $iPaddleHeight, $iPaddleX, $iHeight - $iPaddleHeight + $iPaddelSpace, _ $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDisplay) GUICtrlCreatePic(".\res\paddel2.gif", 0, 0, 0, 0) ; Create ball GUI Local $hBall = GUICreate("", $iBallSize, $iBallSize, $iBallX, $iBallY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDisplay) GUICtrlCreatePic(".\res\Tball.gif", 0, 0, 0, 0) GUISetState(@SW_SHOW, $hPaddle) GUISetState(@SW_SHOW, $hBall) While 1 Local $aMPos = MouseGetPos() $iPaddleX = $aMPos[0] ; Keep paddle within screen If $iPaddleX < 0 Then $iPaddleX = 0 If $iPaddleX > $iWidth - $iPaddleWidth Then $iPaddleX = $iWidth - $iPaddleWidth ; Move the ball $iBallX += $iBallSpeedX $iBallY += $iBallSpeedY ; Ball collision with top If $iBallY <= 0 Then $iBallSpeedY = -$iBallSpeedY Beep(300, 100) EndIf ; Ball collision with left and right If $iBallX <= 0 Or $iBallX >= ($iWidth - $iBallSize) Then $iBallSpeedX = -$iBallSpeedX Beep(200, 100) EndIf ; Ball collision with paddle If ($iBallX >= $iPaddleX And $iBallX <= ($iPaddleX + $iPaddleWidth) And _ $iBallY >= ($iHeight - $iPaddleHeight - $iBallSize + $iPaddelSpace)) And _ $iBallY <= ($iHeight - $iPaddleHeight - $iBallSize + $iPaddelSpace + $iBallSize / 2) Then $iBallSpeedY = -$iBallSpeedY Beep(300, 100) $iScore += 1 GUICtrlSetData($idScore, $iScore) EndIf ; Reset ball if it goes out of bounds If $iBallY > $iHeight Then $iBallX = $iWidth / 2 $iBallY = $iHeight / 2 Sleep(3000) $iScore = 0 GUICtrlSetData($idScore, $iScore) Beep(200, 200) EndIf WinMove($hPaddle, "", $iPaddleX, $iHeight - $iPaddleHeight) WinMove($hBall, "", $iBallX, $iBallY) ; Check for exit If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop Sleep(30) WEnd GUIDelete() EndFunc ;==>_Pong ;---------------------------------------------------------------------------------------- Func _Exit() Exit EndFunc ;==>_Exit ;---------------------------------------------------------------------------------------- TennisPong.zip have fun Thank you very much
    3 points
  2. Nine

    x64 bitwise operations

    I needed a very fast x64 unsigned shift right, and doing it through an AutoIt array was way too slow. So I decided to make a .dll to perform such a task. While I was there, why not include all the bitwise operators that I know of. And then why not make a UDF. This is a bit like my wife does, she buys some draperies and then I end up repainting the whole room because the colors do not match anymore. Anyway, hope it can be useful for you too. Let me know if you have enhancements or comments, I will be glad to incorporate them (if possible). Version 2024-12-07 ASM * Code optimization (elimination of redundancy) Version 2024-12-06 ASM Func BitAND64 Func BitOR64 Func BitXOR64 Func BitSHIFT64 Func BitROTATE64 Func BitNOT64 Version 2020-04-27 DLL Func _BitAND64 Func _BitOR64 Func _BitXOR64 Func _BitEQV64 Func _BitIMP64 Func _BitSHIFT64 Func _BitROTATE64 Func _BitNOT64 Func _x64CloseDLL Version 2020-04-27 Util Func _Hex2Dec x64_Ops.zip
    2 points
  3. Can somebody please explain why this would be needed at all?
    2 points
  4. WildByDesign

    x64 bitwise operations

    This is incredible. I've got the ASM version working already and it is fast. Thanks for sharing.
    1 point
  5. @WildByDesign Just in case you need to generate a version number from the version string parts, I added a function that shows the inverse conversion. Although the inverse conversion may be obvious to me, it might not be so obvious to others how simple it is, especially for those who are not familiar with structs and how values are stored in memory. #include <Constants.au3> MsgBox($MB_ICONINFORMATION, "Info", _ "Version string = " & get_version_string(2814749767106561) & @CRLF & _ "Version number = " & get_version_number(10, 0, 0, 1) _ ) Func get_version_string($iVersion) Local $tVerNum = DllStructCreate("uint64 value;"), _ $tVersion = DllStructCreate("word revision; word build; word minor; word major", DllStructGetPtr($tVerNum)) ;Load integer into struct $tVerNum.value = $iVersion ;Return version string Return StringFormat('%i.%i.%i.%i', $tVersion.major, $tVersion.minor, $tVersion.build, $tVersion.revision) EndFunc Func get_version_number($iMajor, $iMinor = 0, $iBuild = 0, $iRevision = 0) Local $tVerNum = DllStructCreate("uint64 value;"), _ $tVersion = DllStructCreate("word revision; word build; word minor; word major", DllStructGetPtr($tVerNum)) ;Load version parts into struct $tVersion.major = $iMajor $tVersion.minor = $iMinor $tVersion.build = $iBuild $tVersion.revision = $iRevision ;Return version number Return $tVerNum.value EndFunc
    1 point
  6. No, at least I can't . It looks like a typical XY problem to me - https://en.wikipedia.org/wiki/XY_problem
    1 point
  7. argumentum

    TennisPong

    ..added "demo mode" 😇 Because I enjoy watching it
    1 point
  8. I can't say it's fixed for sure, but I haven't hit the problem yet anyway! Thanks Jos!
    1 point
  9. You must send it as HTML not as TEXT and of course you must prepare your HTML to be like a MHT file. I mean the HTML should include image as a base64 encoded string. for example:
    1 point
  10. Is using the SMTP Mailer UDF a hard requirement? If so, I will let someone else figure that out. I don't use the SMTP Mailer UDF. I use my own UDF which is based on the CMail CLI tool. I've used CMail to send emails from AutoIt for several years (2017) and it works quite well. As you can see below, it can handle sending inline images to Gmail recipients (or any other recipients) without any issues. Since CMail is a command line tool, you just need to build the correct command line and execute it. CMail also lets you use configuration files. Using a config file makes building the command line much easier. Image of GMail email sent from AutoIt script using CMail: To point you in the right direction, the CMail parameter for attaching an inline image is "-ai:file". The HTML email then needs to include the following img tag where you want the inline image embedded. In general, to send an inline image in an HTML email, you need to send it as a "multipart/related" MIME type. The content ID (CID) in the img tag tells it which multipart section to embed. The email client, in my case CMail, is responsible for including the file in the correct format. I don't want to get too deep into the weeds of SMTP and MIME types, so if you have additional questions, feel free to ask for more information. <img width="48" height="48" src="cid:BrainAvatar.jpg"> The section below shows the HTML used to send the email from the image above. Near the bottom, you will see img tag with the CID referencing the image to embed. Basically, the "-ai:file" parameter in CMail attaches a "multipart/related" section in the email, which is needed for inline images. The relevant lines in the script that set up and sent the email looks like this: This gives you an idea of how it can be done using an alternate method. If you want to stick with your current method, or prefer some other method, please disregard it all together.
    1 point
  11. In my OutlookEX UDF I had to do it in two steps: First add the picture as attachment to the mail item, then refer to this attachment in the mail text. The trick is to create an inline picture by using a content id (CID). Please see example 4 from _OL_ItemCreate.au3.
    1 point
  12. you can make a Signature Defaults Create a Gmail signature settings/general
    1 point
  13. Hi @Jemboy 👋 , I guess it's not possible. In case gmail has such restrictions that the embedded image (in the email body) cannot be base64 based, then you can only add the image as attachment like you already dicovered on your own. I see no other chance. I am very curious about other opinions ... maybe it can be achieved, but I am very sceptical. Best of luck 🍀 . Best regards Sven
    1 point
  14. After seeing a number of threads talking about how to exchange efficiently messages between processes (Inter Process Communication), I decided to create a framework using Windows Messages WM_COPYDATA. What is new with this UDF you ask ? Well it will depends how familiar you are with IPC. One thing is sure, the simplicity of use and the fabulous speed are amazing. This is based on a Clients-Server approach. You can have an unlimited number of clients talking with a single server. You will have to define the protocol of communication between them, but the code you have to create is incredibly low. The UDF proposes 2 simple message properties of communication. The first (called data) is based on a number. You can decide what value 1,2,3, etc. means between your client and server. Server will react upon the value of the data field. Second, there is a string field where you can inscribe additional information on request, and where the server will respond to client request (if necessary). Here are the functions that I have wrapped around this : Func _WCD_CreateServer Func _WCD_CreateClient Func _WCD_GetServerHandle Func _WCD_IsServerAvailable Func _WCD_Send Func _WCD_WM_COPYDATA_CLIENT_HANDLER Func _WCD_Client_GetResponse Func _WCD_WM_COPYDATA_SERVER_HANDLER Func _WCD_Server_PeekRequest Func _WCD_Server_GetRequest Func _WCD_Server_IsRequestAvail Here an example of the server : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = False ; make it True if you want to follow the convos. False is by default. Local $hServer = _WCD_CreateServer () Local $aReq, $iData While True If _WCD_Server_IsRequestAvail () Then $aReq = _WCD_Server_GetRequest () $iData = @extended Switch $iData Case 1 ; who are you _WCD_Send($hServer, $aReq[0], $iData, @ComputerName) Case 2 Switch Number($aReq[1]) Case 1 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress1) Case 2 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress2) Case 3 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress3) Case 4 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress4) Case Else _WCD_Send($hServer, $aReq[0], $iData, "Invalid parameter") EndSwitch EndSwitch EndIf Sleep (100) WEnd And the client : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = True ; as for the server, you can decide to make client verbose or not Global $hWnd = _WCD_CreateClient ("Test WCD Client") Global $hWndServer = _WCD_GetServerHandle () _WCD_Send($hWnd, $hWndServer, 1) ; simple request - who are you ? Local $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) _WCD_Send($hWnd, $hWndServer, 2, "5") ; adding text to a more complex request $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) Func WaitForResponse () Local $sResp While _WCD_IsServerAvailable () $sResp = _WCD_Client_GetResponse () If $sResp <> "" Then Return $sResp Sleep (100) WEnd EndFunc As always, let me know if you got issues, comments, suggestions. I will be glad to answer. Version 2020-06-27 * Allows processes with different levels of privilege to communicate with each other WCD_IPC.au3
    1 point
  15. I might add that it is a safe practice to click the input element before sending "^v" keys, especially after issuing a "clear" command. Or @Danp2may know how to send the keys to the element instead of the session. _WD_ElementAction($sSession, $sElement, "clear") _WD_ElementAction($sSession, $sElement, "click") Sleep(100) ; Press ctrl $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE009"},' ; Pause $sAction &= '{"type": "pause", "duration": 500},' ; Press v $sAction &= '{"type": "keyDown", "value": "v"}, {"type": "keyUp", "value": "v"},' ; Release ctrl $sAction &= '{"type": "keyUp", "value": "\uE009"}]}]}' _WD_Action($sSession, "actions", $sAction)
    1 point
  16. The Webdriver "actions" is an advanced feature that can be difficult to format correctly. In this case, the string of actions isn't properly formatted, so the Webdriver is throwing an error. Here's a simplified example that worked for me -- ; Press ctrl $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE009"},' ; Pause $sAction &= '{"type": "pause", "duration": 500},' ; Press v $sAction &= '{"type": "keyDown", "value": "v"}, {"type": "keyUp", "value": "v"},' ; Release ctrl $sAction &= '{"type": "keyUp", "value": "\uE009"}]}]}' _WD_Action($sSession, "actions", $sAction)
    1 point
×
×
  • Create New...