Re: AHK v2
Posted: 15 Mar 2016, 05:28
Ja, da hast Du natürlich recht!
Code: Select all
#NoEnv
#Persistent
#SingleInstance force
script=
(
#Persistent
#SingleInstance force
F4::
MsgBox Hello World!
Return
F6::
MsgBox % A_AhkVersion " " (A_IsUnicode ? "Unicode" : "ANSI") " " (A_PtrSize * 8) "-bit (" (A_IsCompiled ? ".exe" : ".ahk") ")`nPID: " DllCall("GetCurrentProcessId")
Return
)
DllCall("LoadLibrary","Str",ahkdll:=A_ScriptDir "\AutoHotkey.dll")
hNewThread := DllCall(ahkdll "\ahktextdll","Str",script,"Str","","CDecl")
PID := DllCall("GetCurrentProcessId")
msgbox %PID%
Code: Select all
#NoEnv
#Persistent
#SingleInstance ignore
script=
(
#Persistent
#SingleInstance ignore
F4::
MsgBox Hello World!
Return
F6::
PID := DllCall("GetCurrentProcessId")
Msgbox %PID%
Return
)
MsgBox, %script%
Soll heißen, wenn die 'continuation section' %-Zeichen enthält, sorgt die %-Option dafür, dass sie wie jedes andere normale Zeichen behandelt werden und nicht versucht wird, sie als Variablenreferenzen zu interpretieren.% (Prozentzeichen): Behandelt Prozentzeichen nicht als Variablenverweise, sondern als literale Zeichen.
Code: Select all
#NoEnv
#SingleInstance ignore
script1=
(
#Persistent
#SingleInstance ignore
F4::
MsgBox Hello World!
Return
F6::
PID := DllCall("GetCurrentProcessId")
Msgbox %PID%
Return
)
script2=
(%
#Persistent
#SingleInstance ignore
F4::
MsgBox Hello World!
Return
F6::
PID := DllCall("GetCurrentProcessId")
Msgbox %PID%
Return
)
MsgBox, 0, script1 (ohne `%-Option), %script1%
MsgBox, 0, script2 (mit `%-Option), %script2%
Code: Select all
DllCall("FreeLibrary", "Ptr", hModule)
Code: Select all
hModule:=DllCall("LoadLibrary","Str",ahkdll:=A_ScriptDir "\AutoHotkey.dll")
Code: Select all
#NoEnv
#Persistent
#SingleInstance force
hModule:=DllCall("LoadLibrary","Str",ahkdll:=A_ScriptDir "\AutoHotkey.dll")
DllCall(ahkdll "\ahkdll","Str",A_ScriptDir "\PWM_Translater.ahk","Str","")
PID := DllCall("GetCurrentProcessId")
ESC::
DllCall("FreeLibrary", "Ptr", hModule)
Return
F8::
Critical
scr:=PID
detecthiddenwindows,on
settitlematchmode,2
PostMessage, 0x5555, 2,1,,ahk_pid %scr%
detecthiddenwindows,off
settitlematchmode,1
Return
Code: Select all
#Persistent
#SingleInstance ignore
OnMessage(0x5555, "Test")
Return
Test(wParam, lParam)
{
If (wParam=2 && lParam=1)
msgbox
}
Code: Select all
#Persistent
#SingleInstance force
ahkdll:=AhkThread("
(
#Persistent
#SingleInstance ignore
OnMessage(0x5555, "Test")
Return
Test(wParam, lParam)
{
If (wParam=2 && lParam=1)
msgbox
}
)")
dll_ScriptHwnd:=ahkdll.ahkgetvar("A_ScriptHwnd")
ESC::
ahkdll.ahkterminate()
ExitApp
Return
F8::PostMessage_(dll_ScriptHwnd,0x5555,2,1)
Code: Select all
F8::
Critical
scr:=A_ScriptHwnd
detecthiddenwindows,on
settitlematchmode,2
PostMessage, 0x5555, 2,1,,% scr
detecthiddenwindows,off
settitlematchmode,1
Return
Code: Select all
hModule:=DllCall("LoadLibrary","Str",ahkdll:=A_ScriptDir "\AutoHotkey.dll")
DllCall(ahkdll "\ahkdll","Str",A_ScriptDir "\Translater.ahk","Str","")
Code: Select all
obj:=CriticalObject(["A","B","C"])
FileRead,Script,A_ScriptDir "\Translater.ahk"
DllCall("LoadLibrary","Str",ahkdll:=A_ScriptDir "\AutoHotkey.dll")
DllCall(ahkdll "\ahktextdll","Str","obj:=CriticalObject(" (&obj) ")`nMsgBox `% obj.2`n" Script,"Str","")
MsgBox End
Code: Select all
F8::
Critical
scr:=DllCall(ahkdll "\ahkgetvar","Str","A_ScriptHwnd","UInt",0,"Str")
detecthiddenwindows,on
settitlematchmode,2
PostMessage, 0x5555, 2,1,,% "ahk_id " scr
detecthiddenwindows,off
settitlematchmode,1
Return
Code: Select all
var:="Hello World!"
DllCall("LoadLibrary","Str",ahkdll:=A_AhkDir "\AutoHotkey.dll")
DllCall(ahkdll "\ahktextdll","Str","Alias(var," getvar(var) ")`nMsgBox `% var","Str","","Cdecl")
MsgBox end