Crash Posted November 23, 2009 Share Posted November 23, 2009 I have to write two program so that they are like this: 1. The master program can be run by all users without administrator rights, while the slave one requires admin rights. [This can be done with #RequireAdmin written in the slave one.] 2. The users interact with the master. The master then commands the slave and the slave do the job. ["Doing the job" can be done by entering the "job" script in the slave program.] But how can I write so that the master can COMMAND the slave? Not only that, how can the slave HEAR the commands? Help me! I need a virtual mouth and ear, if you know what I mean. *************More Details********************************** 1. The second autoit (slave) will have administrator rights because I want the first autoit (master) can be able to run by ALL USERS without UAC bragging, while the second one has to do jobs that requires admin rights. 2. I know how to program all but the "talking" and "hearing" part *********************************************************** Thx. JPGRAR | Mouse Lock | My website | Thanks so much for your help! ❤️ Link to comment Share on other sites More sharing options...
jvanegmond Posted November 23, 2009 Share Posted November 23, 2009 What you're trying to do is called interprocess communication. There are a few solutions: http://www.autoitscript.com/forum/index.php?showtopic=74068 http://www.autoitscript.com/forum/index.php?showtopic=22547 Alternatively, you can use TCP messages locally. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 23, 2009 Moderators Share Posted November 23, 2009 Crash, My personal favourite is this based on some code from Yashied: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; Based on code from Yashied #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 run it twice. 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...
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