Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/30/2021 in all areas

  1. Look here - solution for this using GUICtrlCreateDummy()
    1 point
  2. In this case use GUISetAccelerators() instead of HotkeySet(). Such accelerators are active only in your GUI by default.
    1 point
  3. He has 100% post solution ! Quite rare...
    1 point
  4. LarsJ

    ObjGet failed why?

    I assume that your expectation of the code line with the ObjCreateInterface() function is that it gives you a new reference to the $oDict_A object. Ie. that $oDict_A and $oDict_B are two different references to the same object. But that's not the case. $oDict_B is a new object apparently created in the same memory block as $oDict_A. That's why you get Memory Access Violation errors. You also assume that your code works. But it doesn't. This is because you have only tested the code that works. You haven't tested the code that doesn't work. You create two references $oDict_A and $oDict_B to the same object this way. Because they are two references to the same object, this code works. Example() Func Example() Local $oDict_A = ObjCreate( "Scripting.Dictionary" ) ; Object reference counter = 1 $oDict_A( "Test" ) = 123 ConsoleWrite( "$oDict_A( ""Test"" ) = " & $oDict_A( "Test" ) & @CRLF ) $oDict_B = $oDict_A ; $oDict_A and $oDict_B references the same object ; Object reference counter = 2 $oDict_A = 0 ; Object reference counter = 1 ConsoleWrite( "$oDict_B( ""Test"" ) = " & $oDict_B( "Test" ) & @CRLF ) EndFunc If you test the same code (deletion of $oDict_A) with your $oDict_A and $oDict_B objects you'll see that the code doesn't work after deletion of $oDict_A. #include <WinAPICom.au3> __Example1() Func __Example1() Local $String_A = "Apple" _WinAPI_CoInitialize( $COINIT_APARTMENTTHREADED ) Local $oDict_A = ObjCreate( "Scripting.Dictionary" ) If IsObj($oDict_A) Then $oDict_A.add("$String_A", $String_A) ConsoleWrite("----->" & @CRLF) ConsoleWrite("[$oDict_A] [$String_A] => " & $oDict_A.Item("$String_A") & @CRLF) Local $pObject = Ptr( $oDict_A ) Local $oDict_B = ObjCreateInterface($pObject, "{42C642C1-97E1-11CF-978F-00A02463E06F}", Default, False) If @error Then ConsoleWrite("ObjCreateInterface failed.... Error code: " & Hex(@error, 8) & @CRLF) $oDict_A = 0 Exit Endif $oDict_A = 0 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("----->" & @CRLF) ConsoleWrite("$oDict_A has been deleted" & @CRLF) Local $String_B = "Orange" $oDict_B.add("$String_B", $String_B) ConsoleWrite("----->" & @CRLF) ConsoleWrite("[$oDict_B] [$String_B] => " & $oDict_B.Item("$String_B") & @CRLF) ConsoleWrite("[$oDict_B] [$String_A] => " & $oDict_B.Item("$String_A") & @CRLF) ConsoleWrite("----->" & @CRLF) _WinAPI_CoUninitialize() $oDict_B = 0 Endif EndFunc The fact that $oDict_B doesn't work when $oDict_A is deleted clearly indicates that $oDict_A and $oDict_B aren't references to the same object. If they were, the code would have worked. $oDict_A and $oDict_B are two different objects. That parts of the code works as in your example along with all the Memory Access Violation errors indicates that the two objects have overlapping memory blocks. If you just want to create a new reference to an existing object simply use $oDict_B = $oDict_A.
    1 point
  5. Hi Lars, This is again a realy nice example, which shows the interaction between AU3 and .NET. Making the AU3 functionality more extensible and powerfull. A nice real live use case Example for scripters would be to have PowerShell interact, bi-directional with AU3 using this technique. The reason is the PS is much more accessible for most users / scripters than C# or vb.NET using System; using System.Collections.Generic; using System.Management.Automation; using System.Management.Automation.Runspaces; using System.Threading.Tasks; public class Program { static void Main() { // create empty pipeline PowerShell ps = PowerShell.Create(); // add command ps.AddCommand("Get-Date"); // run command(s) Console.WriteLine("Date: {0}", ps.Invoke().First()); Console.ReadLine(); } } Since PS is based on .Net, that should be feasible I guess - using the System.Management.Automation class. Thanks again for sharing !!
    1 point
×
×
  • Create New...