HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Sat Nov 22, 2008 3:04 pm Post subject: |
|
|
In this case please explain your problem.
With dynamic scripting you can run several scripts from one file, each can be executed separately or even together.
E.g.:
| Code: |
Script1 =
(
a = FIRST
MsgBox This is the `%a`% Script
)
Script2 =
(
MsgBox This is the SECOND Script``nContent of a = `%a`%
)
SetTimer, ChangeButtons, -50
MsgBox, 262147, Select script, Witch script would you like to run?
IfMsgBox Yes
{
#__RUN_TEMP_SCRIPT(script1, "Your first script")
}
else IfMsgBox No
{
#__RUN_TEMP_SCRIPT(script2, "Your second script")
}
else IfMsgBox Cancel
{
#__RUN_TEMP_SCRIPT(script1 . script2, "Both Scripts in one")
}
ExitApp
ChangeButtons:
WinWait, Select script AHK_class #32770
ControlSetText, Button1, Script1, Select script AHK_class #32770
ControlSetText, Button2, Script2, Select script AHK_class #32770
ControlSetText, Button3, Run Both, Select script AHK_class #32770
WinActivate, Select script AHK_class #32770
Return
#__RUN_TEMP_SCRIPT(script, scriptname="")
{
If scriptname =
#__PIPE_NAME_ := A_TickCount
else
#__PIPE_NAME_ := scriptname
#__PIPE_GA_ := CreateNamedPipe(#__PIPE_NAME_, 2)
#__PIPE_ := CreateNamedPipe(#__PIPE_NAME_, 2)
if (#__PIPE_=-1 or #__PIPE_GA_=-1) {
MsgBox CreateNamedPipe failed.
Return
}
Run, %A_AhkPath% "\\.\pipe\%#__PIPE_NAME_%"
DllCall("ConnectNamedPipe","uint",#__PIPE_GA_,"uint",0)
DllCall("CloseHandle","uint",#__PIPE_GA_)
DllCall("ConnectNamedPipe","uint",#__PIPE_,"uint",0)
script := chr(239) . chr(187) . chr(191) . script
if !DllCall("WriteFile","uint",#__PIPE_,"str",script,"uint",StrLen(script)+1,"uint*",0,"uint",0)
MsgBox WriteFile failed: %ErrorLevel%/%A_LastError%
DllCall("CloseHandle","uint",#__PIPE_)
Return #__PIPE_NAME_
}
CreateNamedPipe(Name, OpenMode=3, PipeMode=0, MaxInstances=255) {
return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode
,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,"uint",0)
} |
_________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|