latest AHK_H not working as expected

Ask for help, how to use AHK_H, etc.
dd900
Posts: 76
Joined: 27 Oct 2013, 16:03

latest AHK_H not working as expected

03 Mar 2015, 21:32

in AHK_H (1.1.13.0) this works

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

thread1 := AhkDllThread( A_ScriptDir "\autohotkey.dll" )
thread1.ahktextdll("msgbox 1")
sleep 5000
exitapp


but in the latest AHK_H (1.1.19.3) it does not work.

Edit:
To be more specific the following works fine with 1.1.13.0

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus



Using the latest AHK_H from git none of the dll threads start. I also used the latest libs that were in the git package. There seems to be an error with CreateScript(). The older version I have works fine , but the latest keeps telling me Function GetSearchIntegers() cannot contain functions.
HotKeyIt
Posts: 1573
Joined: 29 Sep 2013, 18:35
Contact:

Re: latest AHK_H not working as expected

04 Mar 2015, 04:37

There was an error in DynaCall that has been fixed now.
Also CreateScript has been fixed.
dd900
Posts: 76
Joined: 27 Oct 2013, 16:03

Re: latest AHK_H not working as expected

04 Mar 2015, 05:22

thanks. I will give it another go after work.
RHCP
Posts: 178
Joined: 30 Sep 2013, 10:59

Re: latest AHK_H not working as expected

04 Mar 2015, 06:49

I've been using AHK_H MD 32W v1.1.15.00 for a while without issue, but im running into trouble using the latest version.

Is this the correct link? https://github.com/HotKeyIt/ahkdll-v1-release
What happened to the MD/non-MD versions?

I've deleted my old lib folder and replaced it with the one from the current release.

When calling the function the passed values are ignored. It works fine in 1.1.15.
If i make the function variables 'a' and 'b' required i.e. f(a,b)... then it complains that that not enough parameters were passed to the function.

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus



Thanks.
HotKeyIt
Posts: 1573
Joined: 29 Sep 2013, 18:35
Contact:

Re: latest AHK_H not working as expected

04 Mar 2015, 07:28

What happened to the MD/non-MD versions?

There is no AutoHotkey.exe and AutoHotkeySC.bin MD version anymore and no AutoHotkey[Mini].dll non-MD version.

AutoHotkey.exe and SC.bin include AutoHotkey.dll and AutoHotkeyMini.dll as well as msvcr100.dll.
Using MemoryLoadLibrary, msvcr100.dll is not required anmore.
If you are using AHK_H version of AutoHotkey.exe and AutoHotkeySC.bin, there is a new function included.
With included dlls and this function you do not need AutoHotkey.dll anymore.

thread:=AhkThread(script:="",param:="",IsFile:=0,dll:="AutoHotkey.dll")
thread:=AhkMini(script:="",param:="",IsFile:=0,dll:="AutoHotkeyMini.dll")
- thread: Object that can run ahkdll functions like thread.ahkdll("File.ahk")
- script: script to start in new thread. "" will start "#Persistent`n#NoTrayIcon". 0 will return ahkdll object but not start a thread, use ahkdll or ahktextdll to start new thread
- param: parameters to pass to script.
- IsFile: true = script parameter is a file on disk. false = script parameter is a script as text
- dll: dll to be used for the thread


Note: Thread started by AhkThread() will not be freed until program exits.

For example:

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

obj := CriticalObject() ; Create new critical object
Loop, 3 ; Create 3 Threads.
AhkThread%A_Index% := AhkThread("obj:=CriticalObject(" (&obj) ")`nLoop`nobj[" A_Index "]:= A_Index")
Loop ; Show current content of object.
ToolTip, % obj.1 "`n" obj.2 "`n" obj.3
Esc::ExitApp


EDIT:
Updated MiniThread should be AhkMini
RHCP
Posts: 178
Joined: 30 Sep 2013, 10:59

Re: latest AHK_H not working as expected

04 Mar 2015, 10:00

Thanks for the quick fix! These are some great changes!

Unfortunately im still having issues. One of the worker threads is throwing up this error: http://imgur.com/ZtlL6eV

The issue is tied up with sharing an object between the AHK.exe and ahkdll worker thread. This script is massive, but commenting out these lines in the worker thread 'fixes' it. When I have some more free time I will play around with it some more (create a better test case) - as well as replace AhkDllThread() with AhkThread/AHKmini()

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus

Last edited by RHCP on 06 Mar 2015, 01:51, edited 1 time in total.
HotKeyIt
Posts: 1573
Joined: 29 Sep 2013, 18:35
Contact:

Re: latest AHK_H not working as expected

04 Mar 2015, 12:40

That is the down side of having one version of exe/dll only, you can't share data between exe and dll anymore.
But you can simply start your main script in dll or declare the shared objects in separate dll.
guest3456
Posts: 2118
Joined: 09 Oct 2013, 10:31

Re: latest AHK_H not working as expected

04 Mar 2015, 13:19

when were these AHK_H changes introduced? is there a changelog somewhere?

HotKeyIt
Posts: 1573
Joined: 29 Sep 2013, 18:35
Contact:

Re: latest AHK_H not working as expected

04 Mar 2015, 13:41

Today, changes are only on github.
I found a bug with 64-bit, just in case the previous versions can be found here.
dd900
Posts: 76
Joined: 27 Oct 2013, 16:03

Re: latest AHK_H not working as expected

04 Mar 2015, 23:47

thanks for the updates. Using the same script as above AhkThread() works great, but there is some slight lag in my gif animation when the threads start. Using AhkDllThread() there is no lag, but when i close the gui (exitapp) i get a memory error.

screenshots of error:
http://1drv.ms/1KoqogB
http://1drv.ms/1Koqzsn
http://1drv.ms/1w5yKDe
RHCP
Posts: 178
Joined: 30 Sep 2013, 10:59

Re: latest AHK_H not working as expected

05 Mar 2015, 23:45

HotKeyIt wrote:That is the down side of having one version of exe/dll only, you can't share data between exe and dll anymore.
But you can simply start your main script in dll or declare the shared objects in separate dll.


I was wondering if that had anything to do with it. Could I just compile the autoHotkey.exe from source using the MD (Multi-threaded DLL) flag setting? There are couple of minor (40 lines or so) additions that I need to add to the AHK source for my script to run correctly (hence why I rarely update), and I remember last time I couldn't compile the dlls as that required VS 2010 professional.

Thanks.
lexikos
Posts: 5598
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: latest AHK_H not working as expected

06 Mar 2015, 01:25

[...] I remember last time I couldn't compile the dlls as that required VS 2010 professional.
I see no reason you shouldn't be able to use Visual C++ Express 2010, 2012 or 2013 (I've used all three to compile dlls), or Visual Studio 2013 Community Edition, which "includes all the great functionality of Visual Studio Professional 2013".
RHCP
Posts: 178
Joined: 30 Sep 2013, 10:59

Re: latest AHK_H not working as expected

06 Mar 2015, 01:49

This was the error generated when compiling DLLs

source\dllmain.cpp(31): fatal error C1083: Cannot open include file: 'atlbase.h': No such file or directory


Hotkeyit suggested it was due to express and other posts seemed to back that up. I only needed to modify the exe build, so I never bothered to try any of the 'fixes'. After encountering other issues with VS i'm a little reluctant to mess around with it when it's working. I might try installing the community edition though. Thanks.
lexikos
Posts: 5598
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: latest AHK_H not working as expected

06 Mar 2015, 02:54

I see; HotKeyIt must be using ATL in his projects. There is nothing about the Express edition that should stop it compiling dlls in general, or base AutoHotkey 1.1.
HotKeyIt
Posts: 1573
Joined: 29 Sep 2013, 18:35
Contact:

Re: latest AHK_H not working as expected

13 Mar 2015, 16:06

I think all errors should be fixed now.

MSVCR is not included anymore and all files are compiled with /MD flag so require msvcr100.dll.

I had also problems compiling dll in Visual C++ Express and found no way around.
As Lexikos sugested Visual Studio 2013 Community Edition should be the right choice.

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 2 guests