OK - it looks like I have my work cut out for me in comparing some of the approaches. Performance (time sensitivity) is as much of an issue as is relibility - for instance the onmessage approach depends on a visible window, and a small chain of events etc. Registry approaches I fear might be slow too.
I was reading up on DLL calls etc, and of course this is half of my ideal-solution description, but I could not find out if the DLLs allow for 'persistent global variables' (is there a better term?), and also, if there is an easy way to convert an AHK script-library into a DLL.
My application needs to be able to say something like "Don't execute URLDownloadtoFile(myserver..) in ANY running script more than 2 times per second." So the function needs to look to the last tick that ANY script queried myserver and ensure that at least 500ms has passed. At the same time I don't want to pad each script with unneccessary delays - which would not solve the problem. There must be an awareness between processes.
Sharing the value via a small file is looking like the most straight forward solution right now.
Superfraggle wrote:
does this help
helpfile wrote:
Code:
; Example: Have a script receive a custom message and up to two numbers from some other script or program
; (to send strings rather than numbers, see the example after this one).
OnMessage(0x5555, "MsgMonitor")
OnMessage(0x5556, "MsgMonitor")
MsgMonitor(wParam, lParam, msg)
{
; Since returning quickly is often important, it is better to use a ToolTip than
; something like MsgBox that would prevent the function from finishing:
ToolTip Message %msg% arrived:`nWPARAM: %wParam%`nLPARAM: %lParam%
}
; The following could be used inside some other script to run the function inside the above script:
SetTitleMatchMode 2
DetectHiddenWindows On
if WinExist("Name of Receiving Script.ahk ahk_class AutoHotkey")
PostMessage, 0x5555, 11, 22 ; The message is sent to the "last found window" due to WinExist() above.
DetectHiddenWindows Off ; Must not be turned off until after PostMessage.