Ka36ek Posted June 30, 2009 Share Posted June 30, 2009 I wrote a few modules and managing script, which has GUI with settings for all modules, reruns them after errors and makes logs Now I need some Universal method to create Scripts' Interaction or changing strings between them Earlier I have only practice of programming on VBS for MS IIS, and often have used there Global Strings Are there something like SuperGlobal Strings in AI, which can be used by all running scripts? I've search Help and Forum found a lot of difficult methods but it's hard to implement them If smb advises to use common line or console, I kill him Sorry, for bad grammar Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 30, 2009 Moderators Share Posted June 30, 2009 Ka36ek, This question has been asked and answered many, many times, so searching will get you lots of idesa! My favourite to date is this one:expandcollapse popup; Based on code from Yasheid #include <GUIConstantsEx.au3> Opt("WinTitleMatchMode", 3) Global Const $WM_COPYDATA = 0x004A Global $sThis_Win_Title, $sThat_Win_Title Global $iY, $hInput, $hButton, $hLabel Global $sMsg_To_Send, $sMsg_Rcvd, $sMsg_Set = "" ; Set GUI title If WinExists("First Instance") Then If WinExists("Second Instance") Then Exit $sThis_Win_Title = "Second Instance" $sThat_Win_Title = "First Instance" $iY = 300 Else $sThis_Win_Title = "First Instance" $sThat_Win_Title = "Second Instance" $iY = 100 EndIf ; Create GUI GUICreate($sThis_Win_Title, 400, 150, 100, $iY) $hInput = GUICtrlCreateInput("", 20, 20, 360, 20) $hButton = GUICtrlCreateButton("Send", 160, 60, 80, 30) $hLabel = GUICtrlCreateLabel("", 20, 100, 360, 20) GUIRegisterMsg($WM_COPYDATA, "_WM_COPYDATA") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Send close message to other window _SendData(WinGetHandle($sThat_Win_Title), "@exit") Exit Case $hButton ; Send message to other window $sMsg_To_Send = GUICtrlRead($hInput) $hWnd = WinGetHandle($sThat_Win_Title) If (Not @error) And ($sMsg_To_Send <> "") Then _SendData($hWnd, $sMsg_To_Send) EndSwitch ; Check messages received If $sMsg_Rcvd = "@exit" Then Exit If $sMsg_Rcvd <> $sMsg_Set Then GUICtrlSetData($hLabel, $sMsg_Rcvd) $sMsg_Set = $sMsg_Rcvd EndIf WEnd Func _SendData($hWnd, $sData) Local $tCOPYDATA, $tMsg $tMsg = DllStructCreate("char[" & StringLen($sData) + 1 & "]") DllStructSetData($tMsg, 1, $sData) $tCOPYDATA = DllStructCreate("dword;dword;ptr") DllStructSetData($tCOPYDATA, 2, StringLen($sData) + 1) DllStructSetData($tCOPYDATA, 3, DllStructGetPtr($tMsg)) $Ret = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hWnd, "int", $WM_COPYDATA, "wparam", 0, "lparam", DllStructGetPtr($tCOPYDATA)) If (@error) Or ($Ret[0] = -1) Then Return 0 Return 1 EndFunc ;==>_SendData Func _WM_COPYDATA($hWnd, $msgID, $wParam, $lParam) Local $tCOPYDATA = DllStructCreate("dword;dword;ptr", $lParam) Local $tMsg = DllStructCreate("char[" & DllStructGetData($tCOPYDATA, 2) & "]", DllStructGetData($tCOPYDATA, 3)) $sMsg_Rcvd = DllStructGetData($tMsg, 1) Return 0 EndFunc ;==>_WM_COPYDATA Just compile it and then start 2 instances. You can then pass messages back and forth between the GUIs. M23 colc1 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Yashied Posted June 30, 2009 Share Posted June 30, 2009 If you need to send only numeric values, it can be simpler.Receiver#Include <Misc.au3> #Include <WinApi.au3> Global Const $WM_MYMSG = _WinAPI_RegisterWindowMessage('WM_MYMSG') Global $iData = Default GUIRegisterMsg($WM_MYMSG, 'WM_MYMSG') GUICreate('') Do If $iData <> Default Then MsgBox(0, '', Number($iData)) $iData = Default EndIf Sleep(10) Until _IsPressed('1B') ; ESC Func WM_MYMSG($hWnd, $iMsg, $wParam, $lParam) $iData = $wParam EndFunc ;==>WM_MYMSGoÝ÷ ÚæÒzw^¯öÿ¹«¢+Ø%¹±Õ±Ðí]¥¹Á¤¹ÔÌÐì()±½° ½¹ÍÐÀÌØí]5}5e5Mô}]¥¹A%}I¥ÍÑÉ]¥¹½Ý5ÍÍ Ìäí]5}5e5MÌäì¤)±½° ½¹ÍÐÀÌØí!]9} I= MPôÁá()¼($ÀÌØí¥Ñô%¹ÁÕÑ ½à ÌäìÌäì°ÌäìÌäì¤(%%ÉɽÈQ¡¸($%á¥Ð(%¹%(%}]¥¹A%}A½ÍÑ5ÍÍ ÀÌØí!]9} I= MP°ÀÌØí]5}5e5M°9ÕµÈ ÀÌØí¥Ñ¤°À¤)U¹Ñ¥°±Í 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...
ChrisL Posted June 30, 2009 Share Posted June 30, 2009 http://www.autoitscript.com/forum/index.php?showtopic=77979 [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Paulmito Posted July 2, 2009 Share Posted July 2, 2009 Ka36ek, This question has been asked and answered many, many times, so searching will get you lots of idesa! My favourite to date is this one:expandcollapse popup; Based on code from Yasheid #include <GUIConstantsEx.au3> Opt("WinTitleMatchMode", 3) Global Const $WM_COPYDATA = 0x004A Global $sThis_Win_Title, $sThat_Win_Title Global $iY, $hInput, $hButton, $hLabel Global $sMsg_To_Send, $sMsg_Rcvd, $sMsg_Set = "" ; Set GUI title If WinExists("First Instance") Then If WinExists("Second Instance") Then Exit $sThis_Win_Title = "Second Instance" $sThat_Win_Title = "First Instance" $iY = 300 Else $sThis_Win_Title = "First Instance" $sThat_Win_Title = "Second Instance" $iY = 100 EndIf ; Create GUI GUICreate($sThis_Win_Title, 400, 150, 100, $iY) $hInput = GUICtrlCreateInput("", 20, 20, 360, 20) $hButton = GUICtrlCreateButton("Send", 160, 60, 80, 30) $hLabel = GUICtrlCreateLabel("", 20, 100, 360, 20) GUIRegisterMsg($WM_COPYDATA, "_WM_COPYDATA") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Send close message to other window _SendData(WinGetHandle($sThat_Win_Title), "@exit") Exit Case $hButton ; Send message to other window $sMsg_To_Send = GUICtrlRead($hInput) $hWnd = WinGetHandle($sThat_Win_Title) If (Not @error) And ($sMsg_To_Send <> "") Then _SendData($hWnd, $sMsg_To_Send) EndSwitch ; Check messages received If $sMsg_Rcvd = "@exit" Then Exit If $sMsg_Rcvd <> $sMsg_Set Then GUICtrlSetData($hLabel, $sMsg_Rcvd) $sMsg_Set = $sMsg_Rcvd EndIf WEnd Func _SendData($hWnd, $sData) Local $tCOPYDATA, $tMsg $tMsg = DllStructCreate("char[" & StringLen($sData) + 1 & "]") DllStructSetData($tMsg, 1, $sData) $tCOPYDATA = DllStructCreate("dword;dword;ptr") DllStructSetData($tCOPYDATA, 2, StringLen($sData) + 1) DllStructSetData($tCOPYDATA, 3, DllStructGetPtr($tMsg)) $Ret = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hWnd, "int", $WM_COPYDATA, "wparam", 0, "lparam", DllStructGetPtr($tCOPYDATA)) If (@error) Or ($Ret[0] = -1) Then Return 0 Return 1 EndFunc ;==>_SendData Func _WM_COPYDATA($hWnd, $msgID, $wParam, $lParam) Local $tCOPYDATA = DllStructCreate("dword;dword;ptr", $lParam) Local $tMsg = DllStructCreate("char[" & DllStructGetData($tCOPYDATA, 2) & "]", DllStructGetData($tCOPYDATA, 3)) $sMsg_Rcvd = DllStructGetData($tMsg, 1) Return 0 EndFunc ;==>_WM_COPYDATA Just compile it and then start 2 instances. You can then pass messages back and forth between the GUIs. M23 i try but dont works. Any trouble if its autoit-v3.2.4.9 ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2009 Moderators Share Posted July 2, 2009 Paulmito, Given the phenomenal amount of improvements that the Devs have put into AutoIt (thanks guys!) since that version was released on 25 May 2007, I am not very surprised that the script does not work for you. I seem to remember Valik suggesting that being 2 upgrades or more behind was a good enough reason to refuse support (or something along those lines). Your installation is now over 2 years old - why not upgrade? You get a whole lot more with the newer versions, honest! ;-) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Paulmito Posted July 2, 2009 Share Posted July 2, 2009 (edited) Thanks for reply... I cant update because autoit-v3.2.4.9 is the ONLY ONE who send keys to my desired application ! ;-) I create another topic asking how that version sends they keys... Edited July 2, 2009 by Paulmito 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