Shaggi Posted November 15, 2011 Share Posted November 15, 2011 AutoIt does (did) keep track of variable internally of course, but the functions to work with it are not public facing: AUT_RESULT AutoIt_Script::F_Eval(VectorVariant &vParams, Variant &vResult) { bool bConst = false; if (g_oVarTable.isDeclared(vParams[0].szValue())) { Variant *pvTemp; g_oVarTable.GetRef(vParams[0].szValue(), &pvTemp, bConst); vResult = *pvTemp; return AUT_OK; } ... } the function calls an internal GetRef method: bool VariableTable::GetRef(AString sVarName, Variant **pvVariant, bool &bConst, int nReqScope) { Variant *lpVar = NULL; sVarName.toupper(); // Always use uppercase to force case insensitive operation switch (nReqScope) { case VARTABLE_ANY: if (!m_Locals.empty()) lpVar = m_Locals.top()->findvar(sVarName.c_str(), bConst); if (lpVar == NULL) lpVar = m_Globals.findvar(sVarName.c_str(), bConst); break; case VARTABLE_FORCELOCAL: if (!m_Locals.empty()) lpVar = m_Locals.top()->findvar(sVarName.c_str(), bConst); else lpVar = m_Globals.findvar(sVarName.c_str(), bConst); break; case VARTABLE_FORCEGLOBAL: lpVar = m_Globals.findvar(sVarName.c_str(), bConst); break; } *pvVariant = lpVar; return (lpVar != NULL); } // GetRef() Which calls the findvar method on the appropriate variable scope: Variant* VariableList::findvar(const char *szName, bool &bConst) { VarNode *lpTemp = findvarnode(szName); if (lpTemp) { bConst = lpTemp->bConst; return lpTemp->pvVariant; // Found! Return a pointer to it } else return NULL; } // findvar() Which in turn uses findvarnode to get the NODE pointer: VarNode* VariableList::findvarnode(const char *szName) { VarNode *lpTemp = m_lpRoot; int nRes; while (lpTemp != NULL) { nRes = strcmp(lpTemp->szName, szName); if (nRes < 0) lpTemp = lpTemp->lpLeft; // Less than (left child) else if (nRes > 0) lpTemp = lpTemp->lpRight; // Greater than (right child) else return lpTemp; // Found } // Not found return NULL; } // findvarnode() This is off the last public version of the source code. The underlaying issue is simply that there doesn't seem to be a public facing function for findvar. In "userland", the global vs public scope get messed up when you try to pass a global variable to a local function (the variable is copied by value or at least via reference, so the global variable name is not preserved in the local scope...), so I don't think it's possible to pass just a variable, it would have to be the name as a string like the examples aboves. I hope this is changed to a hash check instead of a strcmp * amount of variables.. lol Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
Gayathri Posted October 23, 2014 Share Posted October 23, 2014 Hello everyone, I am sorry i dono where to post my question. so posting it here. I just wanted to know whether we can send a variable to the AutoIT executable file from Selenium. Here is my java script to call the AutoIT String FileName = Driver.findElement(By.id( "PaycostProcess")).getAttribute("id") ; System. out.println(FileName); String FileName2 =FileName + " - " + "Australia"; System. out.println(FileName2); String[] FileName3 = new String[] {FileName2}; Runtime.getRuntime().exec( "C:Users349805DesktopDownload1 - autoit.exe", FileName3); Here is the Auto It Script: WinWaitActive("Windows Internet Explorer") WinActivate("Windows Internet Explorer") Sleep(1000) Send("!a") Sleep(1000) ControlFocus("Save As", "", "[CLASS:Edit; INSTANCE:1]") Local FileName = FileGetLongName(FileName3) Send(FileName) Sleep(1000) Send("!S") While Processing it is throughing the error No Variable given for "Dim", "Local", "Global", "Struct" or "Const" statement. in Line 7. Could you please tell me how to get the parameter in AUTOIT. Thanks in Advance. Link to comment Share on other sites More sharing options...
cheeroke Posted May 10, 2018 Share Posted May 10, 2018 Ok, I know it is a bit old, but i had same problem and found how to do it without over coding so there is my solution for the printing variable value and name, hope someone will find it useful. Func VariableChecker($VariableName, $VariableValue) SplashTextOn("Variable Checker", @CRLF &@CRLF & "Status of " & @CRLF &@CRLF & $VariableName & " is: " & $VariableValue , 300,200) Sleep(5000) SplashOff() EndFunc now just call it like so: VariableChecker("$MyVariableToBeChecked", $MyVariableToBeChecked) 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