AutoHotkey Community

It is currently May 25th, 2012, 12:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: July 22nd, 2007, 9:48 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Run many instances of the following script and spread GUIs from each other such that all are visible.
Just type a value and press "Share Variable" button. All the GUIs will reflect the value:

Code:
#SingleInstance, OFF
MsgNum := DllCall( "RegisterWindowMessage", Str,"AHK_SuperGlobal" )
OnMessage( MsgNum, "ReadVar" )

IniRead, SharedGlobal, %A_Temp%\Shared.INI, GlobalVariable, SharedGlobal, 0

Gui, +ToolWindow
Gui, Add, Edit,   w100 h25 vSharedGlobal, %SharedGlobal%
Gui, Add, Button, x+5 w85  h25 +Default gShareVar, Share Variable
Gui, Show, , Shared Global Var!
Return

ShareVar:
  GuiControlGet, SharedGlobal
  IniWrite, %SharedGlobal%, %A_Temp%\Shared.INI, GlobalVariable, SharedGlobal
  SendMessage, MsgNum, 0,0,, ahk_id 0xFFFF
Return

GuiClose:
 ExitApp
Return

ReadVar() {
  Global SharedGlobal
  IniRead, SharedGlobal, %A_Temp%\Shared.INI, GlobalVariable, SharedGlobal
  GuiControl,, SharedGlobal, %SharedGlobal%
Return True
}


The effect can be achieved without an INI, but already its too much code.

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 22nd, 2007, 9:54 pm 
Offline

Joined: October 3rd, 2005, 2:42 am
Posts: 186
Dewi Morgan wrote:
Alternatively, use something like vfd to create a virtual drive in memory to store your files - hence, no thrashing.


That was my suggestion. VFD disks are RAM images, though you can save them to file. VFD is free.

Alternatively, "AR Soft RAM Disk" is also free, though the author seems to have stopped supporting it and disappeared from the face of the net: hid site is dead, but you can still find the software mirrored around the web.

Microsoft has one too - a 32M size limit won't be a problem for you, but apparently it's a pain in the ass to set up: http://support.microsoft.com/default.as ... us;Q257405

Qsoft Ramdisk is free, has a 64M size limit, with larger sizes available for a fee (I think) http://www.ramdisk.tk/

Or google it for yourself :)

_________________
Yet another hotkeyer.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 22nd, 2007, 10:15 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Dewi Morgan wrote:


Thanks for the link. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 22nd, 2007, 10:48 pm 
Skan; That is an excellant example above! I never noticed RegisterWindowMessage, & somehow overlooked 0xFFFF (HWND_BROADCAST) in the documentation :oops:

Skan wrote:
The effect can be achieved without an INI, but already its too much code
Just out of curiosity-- how would you handle sharing var's without using externally shared file? Someone already mentioned using RegisterCallback.. but I haven't been able to get communication working there either. :(


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 22nd, 2007, 10:57 pm 
Offline

Joined: March 18th, 2005, 8:52 am
Posts: 174
Quote:
Just out of curiosity-- how would you handle sharing var's without using externally shared file?


For me this is the red-letter question. I'd also like to add the other caveats:
1. not installing any new programs (I mean, damn, this is merely for passing a variable!)
2. fast ... so that the process does not get too much in the way of measurnig milliseconds.
3. not a lot of code - for the same reason as #1 (elegance)

While none of the solutions, so far, discussed in this thread fit the bill, I certainly appreciate the in depth discussion, as I am re-learning and learning some of the more in-depth aspects of AHK ...


Last edited by cornell2 on July 24th, 2007, 7:52 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 22nd, 2007, 11:10 pm 
Skan's code above is extremely fast. Also--TCP/IP definately works.. & is fast. There is a lot of code that could be cleaned up- but from past experience this seems to be the way to go.

Also coming to mind-- perhaps you could experiment with creating Scripting.Dictionary Object & just pass the handle of the dicitionary to your sub-scripts (this might be my next experiment :D )


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 23rd, 2007, 12:00 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
daniel2 wrote:
Just out of curiosity-- how would you handle sharing var's without using externally shared file?


If it was a number, I would pass it as wParam to the other scripts.
For text I would use WM_CopyData :(, which is a mess.

    The advantage of INI is that
  • a newly loading script can initialise the Globar Var by IniRead-ing at it startup
  • Text can be easily shared without WM_CopyData


I am too tired to write/post an example right now, maybe later .. BTW, do not you have a login so that I can PM ?

Meanwhile, take a look at this: anyway to pass params to script while running ?

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 23rd, 2007, 3:52 am 
Skan,
Thanks for the links. I am still studying the COPYDATASTRUCT.. but from your example-- looks like it is exactly what is needed!! :D

I attempted to register this name.. but got
Quote:
Welcome to AutoHotkey Community Forums

In compliance with the COPPA act your account is currently inactive.

Please print this message out and have your parent or guardian sign and date it. Then fax it to...
:lol:
For now I will continue to be a guest.. & if I have any questions using that struct- I will get back to you!

Thanks for your time- & pointing me in the right direction!! :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2007, 10:38 pm 
Offline

Joined: July 23rd, 2007, 3:43 am
Posts: 47
cornell2- Not sure if your still looking for a solution to this.. but majkinetor put together an excellant example using WM_COPYDATA.

IPC - Inter Process Communication
It effectively handles instant communication between two scripts with a simple function call!! :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2007, 10:47 pm 
Offline

Joined: March 18th, 2005, 8:52 am
Posts: 174
daniel2 wrote:
cornell2- Not sure if your still looking for a solution to this.. but majkinetor put together an excellant example using WM_COPYDATA.

IPC - Inter Process Communication
It effectively handles instant communication between two scripts with a simple function call!! :D


Wow - it looks great .. can't wait to try it ... unfortunately I have no idea how to open an .rar file !


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2007, 10:53 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
download the 7-zip program or winrar. I recommend 7-zip (7-zip.org) since it is open source, opens a bunch of file types, can make a regular zip file with better compression thatn the winxp default, and has good explorer integration.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: cmikaiti, Exabot [Bot], hcx37b, KenC, Maestr0, TedStriker, tomL, Yahoo [Bot] and 45 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group