Jump to content

Search the Community

Showing results for tags 'WM_CopyData'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. The example: The UDFish: The back story: I put together "Win 11 - My own border color" and looking at the logs I've found that I had a handle leak. The leak got fixed but I wanted ( out of OCD ? ) to have the script report on it's status. Ok, easy enough, I'll IPC the request. But I don't wanna have it in the main loop, constantly asking "are we there yet ?, are we there yet ?, ..." . I could not find a copy'n'paste UDF, that did that I wanted to have, so I had to code it 🥲 Now you can copy'n'paste it How does it work: When WM_COPYDATA gets a message, it puts the data in a global array that gets accessed by any user function triggered by AdlibRegister() after X mSec. You can set the AdlibRegister() time with WMCDIPC_AdlibTime(). Without a parameter it will return the current value. Can set the user function with WMCDIPC_AdlibFunc()**. Without a parameter it will return the current value. The UDF has notes that will hint it's use. Hope you find it useful. Edit: This is v2.0 ( yey ! ) ** there now is a WMCDIPC_AdlibRegister(func,time) that can do that too. This version allows running all Au3Stripper arguments, so that's good. Added WMCDIPC_PrintCallback() to handle the one line of debug in the UDF. Also added a return in case the script is already busy running in Adlib, therefore unable to process the IPC request right there and then. The int return is "0xFADE" and the string has how many mSec it's been busy. Giving the user a chance to know it "FADEd away" and formulate a resend or what not. Since is a new version, added WMCDIPC_Version(), just in case of a future one. But all in all, I think that this UDF is complete and needs no other functionality for the scenario it would be used at. Edit: This is v2.1 ( wow ! ) Added in the loop. Why ?. Well, the project that I wrote this for is GUIOnEventMode=1. Having the "are we there yet ?" is much slower given that a long Sleep() is common in that option. But the example I posted is GUIOnEventMode=0. It does use GUIGetMsg() to handle messages and CPU usage so, why not have the trigger right there. So that's what I added in this version. And obviously responds much faster than scheduling an Adlib. Edit: ..and this is v2.1.1 ( child proofing ? ) I was thinking that it would be nice to tell, the new to this UDF, that a set of choices would not work ( not as extreme as in MsgBox_Extn() but, something ). Also to run ControlViewer just in case of an "oops". where you can select a script, press DEL, and process close it, if something went wrong. ( and I use it a lot ) So there: for all those that should be sleeping at 3 AM but want to code and screw up, because the brain is sleeping regardless of will.
  2. The following is a script from Eukalyptus that plays an audio file and displays an FFT Visualization. Let's call it the "Child". My goal is to be able to close it AND to send volume-level change commands from a Parent program (script farther below). I'm trying to use WM_CopyData for IPC but it's not working for me. Part of my problem is I'm unsure about what's needed to initialize WM_CopyData in the Parent program -- if this is even necessary. I realize I could use the MailSlot UDF for this but would like to give WM_CopyData a go first, based on Guinness's recommendation. Once I get WM_CopyData working I might even try to use it to close the Child program. Other issues I'm unsure about are: 1. can I send decimal values via WM_CopyData_Send() ? (BASS_SetVolume() needs values between 0 and 1) 2. at the receiving end in the Child am I using the proper variable type and format for BASS_SetVolume()? "Child" (must be compiled and named "FFT-Viz-WM_CopyData" so Parent can run it) #AutoIt3Wrapper_UseX64=n #include "Bass.au3" #include "BassExt.au3" #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include 'WM_COPYDATA.au3' Opt("MustDeclareVars", 1) _WM_COPYDATA_SetID('MyUniqueID') ; set ID for WM_CopyData Global $sFile = FileOpenDialog("Open...", "..\audiofiles", "playable formats (*.MP3;*.MP2;*.MP1;*.OGG;*.WAV;*.AIFF;*.AIF)") If @error Or Not FileExists($sFile) Then Exit Global $iWidth = 522 Global $iHeight = 170 Global $hGui = GUICreate("FFT", $iWidth, $iHeight, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP)) GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT") _GDIPlus_Startup() Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Global $hBmp_Buffer = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Global $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, 2) Global $hBrush = _CreateFFTBrush(5, 5, $iWidth - 10, $iHeight - 10) GUIRegisterMsg($WM_PAINT, "WM_PAINT") GUISetState() _BASS_Startup() _BASS_EXT_Startup() _BASS_Init(0, -1, 44100, 0, "") Global $hStream = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_SAMPLE_FLOAT) Global $aFFT = _BASS_EXT_CreateFFT(128, 5, 5, $iWidth - 10, $iHeight - 10, 1, True) _BASS_ChannelPlay($hStream, True) Local $iControlID = _WM_COPYDATA_Start($hGui) ; Start the communication process. Global $iTimer = TimerInit() While _BASS_ChannelIsActive($hStream) If TimerDiff($iTimer) > 20 Then Switch GuiGetMsg() Case -3 ; allows Parent program to use WinClose to close this program. ExitLoop Case $iControlID ; if the Parent program sends a volume change value via WM_CopyData Local $volumelevel = _WM_COPYDATA_GetData() _BASS_SetVolume($volumelevel) Beep(1000, 100) ; for testing purposes to see if this Case ever gets triggered EndSwitch $iTimer = TimerInit() _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF110022) _BASS_EXT_ChannelGetFFT($hStream, $aFFT, 2) If Not @error Then DllCall($ghGDIPDll, "int", "GdipFillPolygon", "handle", $hGfx_Buffer, "handle", $hBrush, "ptr", $aFFT[0], "int", $aFFT[1], "int", "FillModeAlternate") _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0) EndIf WEnd _Exit() Func _CreateFFTBrush($iX, $iY, $iWidth, $iHeight) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hBrush_FFT = _GDIPlus_LineBrushCreate(0, 0, 0, $iHeight, 0, 0, 3) Local $aColors[5][2] = [[4]] $aColors[1][0] = 0xFFFF0000 $aColors[1][1] = 0 $aColors[2][0] = 0xFFFFAA00 $aColors[2][1] = 0.25 $aColors[3][0] = 0xFF00AAFF $aColors[3][1] = 0.5 $aColors[4][0] = 0xFF00AAFF $aColors[4][1] = 1 _GDIPlus_LineBrushSetPresetBlend($hBrush_FFT, $aColors) Local $hBrush_LED = _GDIPlus_LineBrushCreate(0, 0, 0, 4, 0xAA000000, 0x00000000, 0) _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iWidth, $iHeight, $hBrush_FFT) _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iWidth, $iHeight, $hBrush_LED) _GDIPlus_BrushDispose($hBrush_LED) _GDIPlus_BrushDispose($hBrush_FFT) _GDIPlus_GraphicsDispose($hContext) Local $hBrush = _GDIPlus_TextureCreate($hBitmap) _GDIPlus_BitmapDispose($hBitmap) DllCall($ghGDIPDll, "uint", "GdipTranslateTextureTransform", "hwnd", $hBrush, "float", $iX, "float", $iY, "int", 0) Return $hBrush EndFunc ;==>_CreateFFTBrush Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_PAINT ; #FUNCTION# ==================================================================================================================== ; Author ........: Authenticity ; Modified.......: UEZ ; =============================================================================================================================== Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 ; #FUNCTION# ==================================================================================================================== ; Author ........: Authenticity ; Modified.......: UEZ ; =============================================================================================================================== Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0) Local $tPointF1, $tPointF2, $aResult $tPointF1 = DllStructCreate("float;float") $tPointF2 = DllStructCreate("float;float") DllStructSetData($tPointF1, 1, $nX1) DllStructSetData($tPointF1, 2, $nY1) DllStructSetData($tPointF2, 1, $nX2) DllStructSetData($tPointF2, 2, $nY2) $aResult = DllCall($ghGDIPDll, "int", "GdipCreateLineBrush", "struct*", $tPointF1, "struct*", $tPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc ;==>_GDIPlus_LineBrushCreate ; #FUNCTION# ==================================================================================================================== ; Author ........: Authenticity ; Modified.......: UEZ ; =============================================================================================================================== Func _GDIPlus_LineBrushSetPresetBlend($hLineGradientBrush, $aInterpolations) Local $iI, $iCount, $tColors, $tPositions, $aResult $iCount = $aInterpolations[0][0] $tColors = DllStructCreate("uint[" & $iCount & "]") $tPositions = DllStructCreate("float[" & $iCount & "]") For $iI = 1 To $iCount DllStructSetData($tColors, 1, $aInterpolations[$iI][0], $iI) DllStructSetData($tPositions, 1, $aInterpolations[$iI][1], $iI) Next $aResult = DllCall($ghGDIPDll, "int", "GdipSetLinePresetBlend", "handle", $hLineGradientBrush, "struct*", $tColors, "struct*", $tPositions, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc ;==>_GDIPlus_LineBrushSetPresetBlend ; #FUNCTION# ==================================================================================================================== ; Author ........: Authenticity ; Modified.......: UEZ ; =============================================================================================================================== Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateTexture", "handle", $hImage, "int", $iWrapMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc ;==>_GDIPlus_TextureCreate Func _Exit() _BASS_StreamFree($hStream) _BASS_Free() _WM_COPYDATA_Shutdown() _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx_Buffer) _GDIPlus_BitmapDispose($hBmp_Buffer) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit And here's the Parent program, which you can run from SciTE. #include "ExtMsgBox.au3" #Include <WinAPIEx.au3> #include 'WM_COPYDATA.au3' ;_WM_COPYDATA_SetID('MyUniqueIDC') ; NOT SURE IF I NEED THIS ;Local $iControlID = _WM_COPYDATA_Start(Default) ; Start the communication process. NOT SURE IF I NEED THIS $wPID = run ("FFT-Viz-WM_CopyData.exe") sleep(2000) _ExtMsgBox(0,0,"","press enter to reduce volume",0,1,1) _WM_COPYDATA_Send(.2) ;can WM_CopyData send values like this or must they be strings? _ExtMsgBox(0,0,"","press enter to raise volume",0,1,1) _WM_COPYDATA_Send(1) _ExtMsgBox(0,0,"","press enter to exit",0,1,1) $aData = _WinAPI_EnumProcessWindows ($wPID) ConsoleWrite($aData[1][0] & @LF) Sleep(2000) $result = WinClose($aData[1][0]) ConsoleWrite ("winclose issued! Result = " & $result & @LF) sleep (2000) ;_WM_COPYDATA_Shutdown() ;NOT SURE IF I NEED THIS Exit
×
×
  • Create New...