Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHK_H(+dll) / AHK_L / v2] AhkDllThread+AhkExported


  • Please log in to reply
274 replies to this topic
aSEioT
  • Members
  • 87 posts
  • Last active:
  • Joined: 31 Oct 2010
bug Report!
ahkdll := AhkDllThread()
ahkdll.ahktextdll()
msgbox % "ahkgetvar a not existence addr is " ahkdll.ahkgetvar("nothing", 1)  ; add this may induce error for the following code, You can comment it out to test the different behavior.

ahkdll.addscript("tooltip addscript is ok!`n ret := true`n func(var){`nglobal`n return `%var`%`n}", 1)      ; show the script is running
Sleep, 1000
ahkdll.addscript("tooltip", 1)         ; dismiss the tooltip
msgbox % "test for ahkfunction the ret = " ahkdll.ahkfunction("func", "ret")             ; this is ok
MsgBox % "test for ahkgetvar ret = " ahkdll.ahkgetvar.ret
ahkdll.ahkassign.ret := "222"
msgbox % "test for ahkassign the ret should be 222, but actually ret = " ahkdll.ahkgetvar.ret
~VKFF::return
And there is maybe another bug when we terminate one ahkdll, and create a new one. Sometimes it would bring up a error message with "RegClass". This is occur in my complicated application. Don't figure out how this happen right now!

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

bug Report!

Thanks, try again now.

aSEioT
  • Members
  • 87 posts
  • Last active:
  • Joined: 31 Oct 2010

bug Report!

Thanks, try again now.

The zip seems broken, can not normally unzip! And did see my previous request? :oops:

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Zip should be ok now.

You can already get the refference to the variable ahkgetvar(var, 1) and I do not see a way how to make it possible to return objects.

OK, maybe I'm not make it clear!
If the var we get is an object, we can return string "object" to indicate the var type and distinct it with blank var. Or we may have other function 'ahkgetvartype' or similar.

All this can be done with Alias() and ahkgetvar(var, 1), so why do we need more?
You can also use AhkStructuresand _Struct.
ahkdll := AhkDllThread()
ahkdll.ahktextdll("#Persistent`nvar:={}")
Alias(var,ahkdll.ahkgetvar["var",1])
MsgBox % "Var IsObject: " IsObject(var)


aSEioT
  • Members
  • 87 posts
  • Last active:
  • Joined: 31 Oct 2010
I got the new vervison. But the bug is still there!

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
It is not a bug.
DynaCall allows you to omit parameters, so the last used parameter will be used.
dll.ahkgetvar["var",1]
dll.ahkgetvar.var ;this will be same as above because second parameter is already set to 1
dll.ahkgetvar["var",0] ; will get vars value and set second parameter to 0 so ahkgetvar.var can be used again

With regards to RegClass, can you try to reproduce the bug?
I could remove the message for the dll and just continue the execution, not sure what the impact would be.

aSEioT
  • Members
  • 87 posts
  • Last active:
  • Joined: 31 Oct 2010

It is not a bug.
DynaCall allows you to omit parameters, so the last used parameter will be used.

dll.ahkgetvar["var",1]
dll.ahkgetvar.var ;this will be same as above because second parameter is already set to 1
dll.ahkgetvar["var",0] ; will get vars value and set second parameter to 0 so ahkgetvar.var can be used again

:shock:
Maybe every time just use ahkgetvar("var", 0) will be safe.

With regards to RegClass, can you try to reproduce the bug?
I could remove the message for the dll and just continue the execution, not sure what the impact would be.

It happen when I terminate and reload the ahkdll immediately. If I wait for a minute between them, it's no problem! When I got the message, the whole script will crash!

Guest_AutoHokey_L
  • Guests
  • Last active:
  • Joined: --
Windows 7 (64-bit), in Win32w folder (with AhkDllObject.ahk copied into Win32w folder), the following code:

#Include AhkDllObject.ahk
AhkDll:=AhkDllObject("AutoHotkey.dll")
AhkDll.ahktextdll("MsgBox MsgBox from AutoHotkey.dll")
MsgBox end main thread
gives an error here (when placed in a file in the same folder and dropped on to AutoHotkey.exe in the same folder):

Error in #include file "X:\AutoHotkey_HotkeyIt\Win32w\AhkDllObject.ahk":
Duplicate declaration.

Specifically: AHK_H:=VarSetCapacity( Trans,8*(A_IsUnicode?2:1)),AHK_H:=DllCall("Version\GetFileVersionInfo", "Str"...

Line#
004: DynaCall := "DynaCall"
004: uc := "UChar"
004: ui := "UInt"
004: i := "Int"
004: s := "Str"
004: functions := "ahkKey:s|ahkFunction:s=sssssssssss|ahkPostFunction:i=sssssssssss|ahkdll:ui=sss|ahktextdll:ui=sss|ahkReady:|ahkReload:ui=|ahkTerminate:i|addFile:ui=sucuc|addScript:ui=si|ahkExec:ui=s|ahkassign:ui=ss|ahkExecuteLine:ui=uiuiui|ahkFindFunc:ui=s|ahkFindLabel:ui=s|ahkgetvar:s=sui|ahkLabel:ui=sui|ahkPause:s"
012: FSz := DllCall("Version\GetFileVersionInfoSize", "Str",A_AhkPath, "UInt",0 )
---> 012: AHK_H := VarSetCapacity( FVI, FSz, 0 )

The program will exit.

Am I doing something wrong? Also, any more info I should provide?

Guest_AutoHotkey_L
  • Guests
  • Last active:
  • Joined: --
FWIW, with Windows XP SP3 (32-bit), I get:

Error at line 1.

#Include file "AhkDllObject.ahk" cannot be opened.

The program will exit.



Guest_AutoHotkey_L
  • Guests
  • Last active:
  • Joined: --
The MD5 checksum of the downloaded AutoHotkey.zip file appears to be:

0419EE8A9EAE6EDEC91B30F3B6DB0BBF



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Windows 7 (64-bit), in Win32w folder (with AhkDllObject.ahk copied into Win32w folder), the following code:

#Include AhkDllObject.ahk
AhkDll:=AhkDllObject("AutoHotkey.dll")
AhkDll.ahktextdll("MsgBox MsgBox from AutoHotkey.dll")
MsgBox end main thread
gives an error here (when placed in a file in the same folder and dropped on to AutoHotkey.exe in the same folder):

Sorry I have not updated the functions in the zip package, can you try the one from first post in this thread, I will update with next release.

"#Include file "AhkDllObject.ahk" cannot be opened.

Place it in your lib folder and use
#Include <AhkDllObject>


Guest_AutoHotkey_L
  • Guests
  • Last active:
  • Joined: --

...I have not updated the functions in the zip package, can you try the one from first post in this thread, I will update with next release.

Thanks for the explanation -- looking forward to the next release :)

"#Include file "AhkDllObject.ahk" cannot be opened.

Place it in your lib folder and use
#Include <AhkDllObject>

I created a file named AhkDllObject.ahk and placed in it code from the first post in this thread. I also changed the line with the #Include in the sample code to use angle brackets.

When executing the results, I got an error:

Error at line 1 in #include file "X:\AutoHotkey_HotkeyIt\Win32w\Lib\AhkDllObject.ahk".

Line Text: #include
Error: Function library not found.

The program will exit.

I searched the forums and found:

http://www.autohotke...ic.php?p=233188

Then I placed the code from the first post in that thread (function definition for FileGetVersionInfo_AW minus the example code near the end) in a file named FileGetVersionInfo.ahk and placed this in the Lib directory.

Subsequent executions of the code seem to behave appropriately.

Was this a reasonable course of action?

Guest_AutoHotkey_L
  • Guests
  • Last active:
  • Joined: --
With an appropriately populated Lib subfolder (contains AhkDllObject.ahk and FileGetVersionInfo.ahk), the sample code appears to run without:

#Include <AhkDllObject>

Is this an example of:

Files can be automatically included (i.e. without having to use #Include) by calling a library function by name.


(from AHK_L's #Include documentation)?

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

With regards to RegClass, can you try to reproduce the bug?
I could remove the message for the dll and just continue the execution, not sure what the impact would be.

It happen when I terminate and reload the ahkdll immediately. If I wait for a minute between them, it's no problem! When I got the message, the whole script will crash!

This should be now fixed (in 1.1.05.02)

aSEioT
  • Members
  • 87 posts
  • Last active:
  • Joined: 31 Oct 2010

This should be now fixed (in 1.1.05.02)

It's great! And may thanks for implementing of CriticalObject :D