Jump to content

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

AutoHotkey.dll


  • Please log in to reply
1328 replies to this topic
Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

Report BUG

 

 

If the script is set up hotkeys, then when the script crashes, Mouse and keyboard short No response. The mouse cursor can not be moved.
In XP, the performance of the huge delays.
in WIN8.1, there will be half a minute, mouse and keyboard No unresponsive.

The BUG caused huge problems for me, because I often collapse.
Once crumbles, I have to wait for some time, wait computer appear response.
I always think that this is causing my code
now found that this is AHKH own reasons.

AhkThread := AhkDllThread()
AhkThread.ahktextdll("*wheelup::") ; !!!!!!!
AhkThread.addScript("Sub:`nMsgbox Sub`nReturn`nA(){`nA}",0) ; 追加但不执行.
Sleep, 200
AhkThread.ahkFunction("A")
AhkThread.ahkLabel.Sub 
AhkDllThread(a:=""){
	static f:={ahkFunction:"s==sssssssssss", ahkPostFunction : "i==sssssssssss", ahkdll : "ut==sss", ahktextdll : "ut==sss", ahkReady : "", ahkReload : "i", ahkTerminate : "i", addFile : "ut==sucuc", addScript:"ut==si", ahkExec  : "ui==s", ahkassign : "ui==ss", ahkExecuteLine : "ut=utuiui", ahkFindFunc : "ut==s", ahkFindLabel : "ut==s", ahkgetvar : "s==sui", ahkLabel : "ui==sui", ahkPause : "s", ahkIsUnicode : ""}
		,w:=[],e:=SubStr(A_AhkPath, 1, InStr(A_AhkPath, "\", "", 0)-1)

	if !(d:=w[a]) and !w[a]:=d:=(FileExist(A_ScriptDir d:="\AutoHotkey" (a?(a=1?"Mini":"2"):"") ".dll") ? A_ScriptDir d: FileExist(e d)? e d : "")
	{
		MsgBox,Not found ahk.dll, script will exit.
		ExitApp
	}
	b := {"&":{},"":r:=MemoryLoadLibrary(d)}, a?b["Type"]:=a:""
	for i,n in f
		b[i]:=DynaCall(MemoryGetProcAddress(r,i), n)
	return	b
}


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

I assume the script should simulate a crash by calling a recursively in AHK v2, for above I get an error here: a(){`nA`n}?

 

I think the freeze and delay when app crashes is caused by windows for some reason but I am not sure and have no idea where to look.
I had this problem with other apps too but it is not on every laptop/desktop that slow and unresponsive, on my Win7 32bit and 64bit I get ~1 second delay/freeze only..

 

Probably it happens because we are calling the code in dll and app gets kind of lost after the crash.

Do you get the same problem calling only this: MsgBox % AhkThread.ahktextdll("a()`na(){`na`n}")

Also what happens when you call the code in exe?

a()
a(){
  a
}


Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

 

MsgBox % AhkThread.ahktextdll("a()`na(){`na`n}")


It does not crash, will prompt an error.
Even though collapse, nor stagnation will happen.
Only when set hotkeys, crashes appear stalled.

It is important: AhkThread.ahktextdll("*wheelup::")
if AhkThread.ahktextdll("#Persistent") not Stagnation


I use a lot of objects, but V2 improvement on the object, will only increase the burden on me, There is no benefits.
So I Temporarily do not use it。
I can not find the resulting EXE collapse code.

 

This may be WIN8 cause problems.



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

I don't think it is related to hotkeys, try this:

AhkThread := AhkDllThread()
AhkThread.ahktextdll("#Persistent`nSub:`nMsgbox Sub`nReturn`nA(){`nA()`n}")
MsgBox % AhkThread.ahkFunction("A")


Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

Your example does not cause crashes, the script automatically exit.
Examples of crashes caused by:

AhkThread := AhkDllThread()
AhkThread.ahktextdll("#Persistent") 
AhkThread.addScript("Sub:`nMsgbox Sub`nReturn`nA(){`nA}",0) 
Sleep, 200
AhkThread.ahkFunction("A")
AhkThread.ahkLabel.Sub 

Resulting in the collapse and stagnation examples:

AhkThread := AhkDllThread()
AhkThread.ahktextdll("*wheelup::") 
AhkThread.addScript("Sub:`nMsgbox Sub`nReturn`nA(){`nA}",0)
Sleep, 200
AhkThread.ahkFunction("A")
AhkThread.ahkLabel.Sub 


HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Do you get an error here: AhkThread.addScript("Sub:`nMsgbox Sub`nReturn`nA(){`nA}",0)?

Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

Yes, Code error, of course error. determining After that,Crash.

 

 

important:
same crashes
wheelup:: Stagnation
#Persistent NO Stagnation

 

addition: AHKH Is it possible be transfer to ahkscript.org



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Are you an admin on your machine? Does it make difference when you run as admin?

addition: AHKH Is it possible be transfer to ahkscript.org

Probably when I finish docs and compiler.

Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

yes, i admin.



Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

I try to organize this post useful functions.

The following script,Use DLL load,Modify Label Normal, Modify Func,DLL Exit Resulting EXE Exit

global h_Self:= ;If you want to test, must Need themselves DLLThread
;http://www.autohotkey.com/board/topic/39588-autohotkeydll/page-54



;Modify Label Normal
gosub Label
ModifyScript("Label","MsgBox new code`nReturn")
gosub Label

;Modify Func,Automatically exit
MsgBox % A(1)
ModifyScript("A","(V,M=2){`nReturn M`n}")
/*
addition,If  Once again modify, will collapse.:
ModifyScript("A","(V,M=2){`nReturn 3`n}")
*/


MsgBox % A(1)

ExitApp

Label:
	MsgBox Old code
	Return

A(V){
	Return V
	}


ModifyScript(a,d){
	static _AHKDerefType := "LPTSTR marker,{_AHKVar *var,_AHKFunc *func},BYTE is_function,BYTE param_count,WORD length"
	static _AHKExprTokenType := "{__int64 value_int64,double value_double,struct{{PTR *object,_AHKDerefType *deref,_AHKVar *var,LPTSTR marker},{LPTSTR buf,size_t marker_length}}},UINT symbol,{_AHKExprTokenType *circuit_token,LPTSTR mem_to_free}"
	static _AHKArgStruct := "BYTE type,BYTE is_expression,WORD length,LPTSTR text,_AHKDerefType *deref,_AHKExprTokenType *postfix"
	static _AHKLine := "BYTE ActionType,BYTE Argc,WORD FileIndex,UINT LineNumber,_AHKArgStruct *Arg,PTR *Attribute,*_AHKLine PrevLine,*_AHKLine NextLine,*_AHKLine RelatedLine,*_AHKLine ParentLine"
	static _AHKLabel := "LPTSTR name,*_AHKLine JumpToLine,*_AHKLabel PrevLabel,*_AHKLabel NextLabel"
	static _AHKFuncParam := "*_AHKVar var,UShort is_byref,UShort default_type,{default_str,Int64 default_int64,Double default_double}"

	static _AHKRCCallbackFunc := (A_PtrSize = 8) ? "UINT64 data1,UINT64 data2,PTR stub,UINT_PTR callfuncptr,BYTE actual_param_count,BYTE create_new_thread,event_info,*_AHKFunc func"
	: "ULONG data1,ULONG data2,ULONG data3,PTR stub,UINT_PTR callfuncptr,ULONG data4,ULONG data5,BYTE actual_param_count,BYTE create_new_thread,event_info,*_AHKFunc func"
	static _AHKFunc := "PTR vTable,LPTSTR name,{PTR BIF,*_AHKLine JumpToLine},*_AHKFuncParam Param,Int ParamCount,Int MinParams,*_AHKVar var,*_AHKVar LazyVar,Int VarCount,Int VarCountMax,Int LazyVarCount,Int Instances,*_AHKFunc NextFunc,BYTE DefaultVarType,BYTE IsBuiltIn"
	static _AHKVar := "{Int64 ContentsInt64,Double ContentsDouble,PTR object},{char *mByteContents,LPTSTR CharContents},{UINT_PTR Length,_AHKVar *AliasFor},{UINT_PTR Capacity,UINT_PTR BIV},BYTE HowAllocated,BYTE Attrib,BYTE IsLocal,BYTE Type,LPTSTR Name"

	if (IsFunc(a) and SubStr(d,1,1) = "(")
	{
		h_Self.addScript("____" a d)
			,oldF:=Struct(_AhkFunc,FindFunc(a))
			,newF:=Struct(_AhkFunc,FindFunc("____" a))
		for k in oldF
			oldF.IsPointer(k)
				?oldF[k,""]:=newF[k,"",""]
				:oldF[k]:=newF[k]
	}
	else if IsLabel(a)
		Struct(_AhkLabel,FindLabel(a)).JumpToLine[""]:=h_Self.addScript(d)
}

I found the recent crash reduction, Seems to be related to this issue.
crashes decreased, but my script recently often automatically exit.
This is an improvement you make of it?

 

addition, modification of method must be used addScript? Is there any other way?

 

 



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Did you forget global h_Self:=AhkExported()? In AHK v2 you would get an error happy.png
Also when you addScript, I suggest to check if it was added properly If !h_self.addScript(...),Return 0
 
 

crashes decreased, but my script recently often automatically exit.
This is an improvement you make of it?

It is probably due to all recent fixes, my script do not crash anymore.

addition, modification of method must be used addScript? Is there any other way?

 
What do you mean?

Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

I am helpless to re-write the examples. I'm on my bad English feel sad.

SetBatchLines -1

DLL:=AhkDllThread()


m=
( % `

;Modify Label Normal
gosub Label
ModifyScript("Label","MsgBox new code`nReturn")
gosub Label

;Modify Func,Automatically exit
MsgBox % A(1)
ModifyScript("A","(V,M=2){`nReturn M`n}")
ModifyScript("A","(V,M=3){`nReturn M`n}") ;If Once again modify, will Invalid.


MsgBox % A(1)

ExitApp

Label:
	MsgBox Old code
	Return

A(V){
	Return V
	}


ModifyScript(a,d){
	static j:=0,_AHKDerefType := "LPTSTR marker,{_AHKVar *var,_AHKFunc *func},BYTE is_function,BYTE param_count,WORD length"
	,_AHKExprTokenType := "{__int64 value_int64,double value_double,struct{{PTR *object,_AHKDerefType *deref,_AHKVar *var,LPTSTR marker},{LPTSTR buf,size_t marker_length}}},UINT symbol,{_AHKExprTokenType *circuit_token,LPTSTR mem_to_free}"
	,_AHKArgStruct := "BYTE type,BYTE is_expression,WORD length,LPTSTR text,_AHKDerefType *deref,_AHKExprTokenType *postfix"
	,_AHKLine := "BYTE ActionType,BYTE Argc,WORD FileIndex,UINT LineNumber,_AHKArgStruct *Arg,PTR *Attribute,*_AHKLine PrevLine,*_AHKLine NextLine,*_AHKLine RelatedLine,*_AHKLine ParentLine"
	,_AHKLabel := "LPTSTR name,*_AHKLine JumpToLine,*_AHKLabel PrevLabel,*_AHKLabel NextLabel"
	,_AHKFuncParam := "*_AHKVar var,UShort is_byref,UShort default_type,{default_str,Int64 default_int64,Double default_double}"

	,_AHKRCCallbackFunc := (A_PtrSize = 8) ? "UINT64 data1,UINT64 data2,PTR stub,UINT_PTR callfuncptr,BYTE actual_param_count,BYTE create_new_thread,event_info,*_AHKFunc func"
			: "ULONG data1,ULONG data2,ULONG data3,PTR stub,UINT_PTR callfuncptr,ULONG data4,ULONG data5,BYTE actual_param_count,BYTE create_new_thread,event_info,*_AHKFunc func"
	,_AHKFunc := "PTR vTable,LPTSTR name,{PTR BIF,*_AHKLine JumpToLine},*_AHKFuncParam Param,Int ParamCount,Int MinParams,*_AHKVar var,*_AHKVar LazyVar,Int VarCount,Int VarCountMax,Int LazyVarCount,Int Instances,*_AHKFunc NextFunc,BYTE DefaultVarType,BYTE IsBuiltIn"
	,_AHKVar := "{Int64 ContentsInt64,Double ContentsDouble,PTR object},{char *mByteContents,LPTSTR CharContents},{UINT_PTR Length,_AHKVar *AliasFor},{UINT_PTR Capacity,UINT_PTR BIV},BYTE HowAllocated,BYTE Attrib,BYTE IsLocal,BYTE Type,LPTSTR Name"
/*
 Can not Can Use addScript?
IF :
Loop 100000
ModifyScript("A","(V,M=2){`nReturn " A_Index "`n}")
Script Memory Excessive
addScript() Not real Modify
*/
	if (IsFunc(a) and SubStr(d,1,1) = "(")
	{
		j++
		h_Self.addScript("____" j a d)
			,oldF:=Struct(_AhkFunc,FindFunc(a))
			,newF:=Struct(_AhkFunc,FindFunc("____" j a))
		for k in oldF
			oldF.IsPointer(k)
				?oldF[k,""]:=newF[k,"",""]
				:oldF[k]:=newF[k]
	}
	else if IsLabel(a)
		Struct(_AhkLabel,FindLabel(a)).JumpToLine[""]:=h_Self.addScript(d)
}
)
DLL.ahktextdll("global h_Self:=Object(" Object(DLL) ")`n" m) 

MsgBox  I will disappear

Can ahkscript.org Release Temporary discussion?
I often can not access autohotkey.com

 

 

Also, I think we should try to try and let h_Self become built-in variables, which will greatly improve the H Availability.
It is HY a built-in function, really easy and Convenient.



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

Can ahkscript.org Release Temporary discussion?
I often can not access autohotkey.com


yeah you should create an AHK_H thread in the other forum

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

When you modify the functions and labels you manipulate the memory and destroy internal structure.
This will cause access violation when freeing data since the original function also exist, also script could not free original function.
When you revert all changes it might work but I am not even sure.
 

Also, I think we should try to try and let h_Self become built-in variables, which will greatly improve the H Availability.
It is HY a built-in function, really easy and Convenient.

 

Rather then h_Self object I will add 'included' functions to access own exported functions.
For example addScript:

addScript(Script,waitExecute:=0){
static ahkExec:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"addScript"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","addScript","PTR"),"i==si")
return ahkExec[Script,waitExecute]
} 


Larctic
  • Members
  • 303 posts
  • Last active: May 10 2016 04:56 PM
  • Joined: 21 Jul 2012

Well, now there are three questions:
1,key + crash = mouse stagnation (win8)
2,crash- = Automatically exit+
3,Updated help files,Too many features not understood.