Rendezvous: Difference between revisions

2,000 bytes added ,  15 years ago
+ AutoHotkey
(omit from E, JavaScript)
(+ AutoHotkey)
Line 143:
Mother Goose out of ink!
</pre>
=={{header|AutoHotkey}}==
sendmessage allows for synchronous message sending from the print routines with a 5 second timeout <br>
"Critical" declaration allows buffering of calls to callback routines used in printmonitor
<lang AutoHotkey>
OnMessage(0x4a, "PrintMonitor")
SetTimer, print2, 400
 
print1:
print("Old Mother Goose")
print("When she wanted to wander,")
print("Would ride through the air")
print("On a very fine gander.")
print("Jack's mother came in,")
print("And caught the goose soon,")
print("And mounting its back,")
print("Flew up to the moon.")
return
 
print2:
SetTimer, print2, Off
print("Humpty Dumpty sat on a wall.")
print("Humpty Dumpty had a great fall.")
print("All the king's horses and all the king's men")
print("Couldn't put Humpty together again.")
return
print(message)
{
static StringToSend
StringToSend := message
Gui +LastFound
VarSetCapacity(CopyDataStruct, 12, 0)
NumPut(StrLen(StringToSend) + 1, CopyDataStruct, 4)
NumPut(&StringToSend, CopyDataStruct, 8)
SendMessage, 0x4a, 0, &CopyDataStruct
If ErrorLevel
msgbox out of ink
sleep, 200
return
}
 
PrintMonitor(wParam, lParam, msg)
{
static ink = 5
global printed
Critical
if ink
{
StringAddress := NumGet(lParam + 8)
StringLength := DllCall("lstrlen", UInt, StringAddress)
VarSetCapacity(CopyOfData, StringLength)
DllCall("lstrcpy", "str", CopyOfData, "uint", StringAddress)
printed .= "primaryprinter: " . CopyOfData . "`n"
ToolTip, primary printer`n: %printed%
ink--
}
else
OnMessage(0x4a, "Reserve")
print(CopyOfData)
}
 
Reserve(wParam, lParam, msg)
{
static ink = 5
global printed
Critical
if ink
{
StringAddress := NumGet(lParam + 8)
StringLength := DllCall("lstrlen", UInt, StringAddress)
VarSetCapacity(CopyOfData, StringLength)
DllCall("lstrcpy", "str", CopyOfData, "uint", StringAddress)
printed .= "reserveprinter: " . CopyOfData . "`n"
ToolTip, Reserve printer`n: %printed%
ink--
}
else
return -1
}
</lang>
 
=={{header|Tcl}}==
Anonymous user