EmkioA Posted May 14, 2009 Share Posted May 14, 2009 Is there a way to share a variable between 2 instaces of the same script? I need to detect if a script is run twice and the seconds time i need to make something defined by the first instance of the script #include <Misc.au3> Global $Running If _Singleton( "TestScript", 1 ) = 0 Then msgbox( 0, "", $Running ) Else $Running = 4 msgbox( 0, "Test", "TestScript" ) EndIf i would like to have a message box with 4 into the seconde instance of this script, how can i do this? Stéphane Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 14, 2009 Share Posted May 14, 2009 You could create a window with a hidden style and send it a window message. I've used that before. Link to comment Share on other sites More sharing options...
trancexx Posted May 14, 2009 Share Posted May 14, 2009 I don't think this is possible. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 14, 2009 Share Posted May 14, 2009 It is possible. The way I listed is just one way. Link to comment Share on other sites More sharing options...
trancexx Posted May 14, 2009 Share Posted May 14, 2009 Is there anything I could do to make you elaborate on that? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
toonboon Posted May 14, 2009 Share Posted May 14, 2009 How about asking the question, 'Could you help me on my way to solving this problem?' [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
muncherw Posted May 14, 2009 Share Posted May 14, 2009 What I've done in the past is made a text file that the script can write your variable into and the second time it's run it checks to see if the variable is written there, if it is, do what you need to do otherwise write it. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 14, 2009 Share Posted May 14, 2009 File writing isn't the best way to share data between processes because of the internal caching of the OS. I don't know what more there is to elaborate. You create a hidden window. You watch for a message that you create. You have the second process find your hidden window and send it a message. That's not hard. Link to comment Share on other sites More sharing options...
trancexx Posted May 14, 2009 Share Posted May 14, 2009 What is the point of sending messages in that case? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 14, 2009 Share Posted May 14, 2009 The whole purpose of the thread is interprocess communication. Sending a message from one program to another using window messages is a simple example of how to do that. Link to comment Share on other sites More sharing options...
Yashied Posted May 14, 2009 Share Posted May 14, 2009 http://www.autoitscript.com/forum/index.php?s=&showtopic=94887&view=findpost&p=681941 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 14, 2009 Share Posted May 14, 2009 Yes, that is exactly what I was talking about. Link to comment Share on other sites More sharing options...
trancexx Posted May 15, 2009 Share Posted May 15, 2009 Ok. Could communication be in both ways? Yashied's (nice work) is not example of intercommunication. He is practicing one-way communication. (I was under impression you were talking about two-way communication) ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Yashied Posted May 15, 2009 Share Posted May 15, 2009 Ok. Could communication be in both ways? Yashied's (nice work) is not example of intercommunication. He is practicing one-way communication.(I was under impression you were talking about two-way communication)If you look more closely, then you will understand that the message is sent in both directions. The button "Send" is blocked until receiving a reply message. See also this example. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
trancexx Posted May 15, 2009 Share Posted May 15, 2009 If you look more closely, then you will understand that the message is sent in both directions. The button "Send" is blocked until receiving a reply message. See also this example.Very nice Yashied. Thanks. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now