devtester Posted April 19, 2007 Share Posted April 19, 2007 Greetings,I am placing my control ID definitions in an external .vbs file. They are defined using the SetEnv global environmental function. However, after loading all my variables into memory, I can read the values in the calling code, but the values aren't affecting the ControlClick functionality. The project is using MS Calculator. Here's my code:Calc_Obj.vbs>>>>> MS Calculator Control IDs <<<<<EnvSet("seven", 131)EnvSet("plus ", 92)EnvSet("three", 127)EnvSet("equals", 112)Calc_Code.au3>>>>> Begin Calculator Code <<<<<#include "C:\Calc_Obj.vbs"; sample script to demonstrate using the contols within Window's Calculator applicationrun("calc.exe")WinWait("Calculator"); perform: 7+3=ControlClick ( "Calculator", "", EnvGet("seven")) ; sevenControlClick ( "Calculator", "", EnvGet("plus")) ; plusControlClick ( "Calculator", "", EnvGet("three")) ; threeControlClick ( "Calculator", "", EnvGet("equals")) ; equals---------------------------------The above code doesn't run. I can do a message box on EnvGet("seven") within the Calc_Code.au3 file and it displayes 131. One interesting thing to note, I can have a variable assignment such as $var = EnvGet("seven")+0 and use ControlClick ( "Calculator", "", $var). This code will work! Very strange behavior.Any suggestions appreciated. Link to comment Share on other sites More sharing options...
evilertoaster Posted April 19, 2007 Share Posted April 19, 2007 What's the reason for using VB in this case? Also sometimes the control ID's can change watch for that. Finally, you may want to add soe debugging to see if the script does read the control ID's correctly and if doing so matches the action you get when you hardcode them. Link to comment Share on other sites More sharing options...
devtester Posted April 19, 2007 Author Share Posted April 19, 2007 I am looking for a solution as to why this code doesn't work...not to redesign the script. With regard to debugging...I used msgbox and the control ID is being read in the au3 file. Much thanks for your consideration. Link to comment Share on other sites More sharing options...
evilertoaster Posted April 19, 2007 Share Posted April 19, 2007 (edited) I am looking for a solution as to why this code doesn't work...not to redesign the script.I said nothign of redesign...Obviously somthing WILL have to be chaned as it isn't working atm though... Can you verify, like i said above, that the control ID's are staying the same and match up with what you want them to be? And can you send these controlclick's ok if you hardcode the controlIDs in?Another thing to try is coding the first part in autoit also if the situation allows and see if that helps any... does it require VB in this case? Edited April 19, 2007 by evilertoaster Link to comment Share on other sites More sharing options...
Developers Jos Posted April 19, 2007 Developers Share Posted April 19, 2007 (edited) I am looking for a solution as to why this code doesn't work...not to redesign the script. With regard to debugging...I used msgbox and the control ID is being read in the au3 file. Much thanks for your consideration.RemarksA environment variable set in this way will only be accessible to programs that AutoIt spawns (Run, RunWait). Once AutoIt closes, the variables will cease to exist.the environment changes made in the VBS CMD session will only exist in the CMD program and no other program. Edited April 19, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
evilertoaster Posted April 19, 2007 Share Posted April 19, 2007 (edited) I had suspected such a problem between AU and VB, however he is SETTING the variables in VB, unless it had the same restriction on it as the AutoIt version it should work in thoery. Also he has already said he is able to read the variables in the end. However i am still wary of mixing the two seemingly unnecessarily... Edit: saw your edit.... perhaps he was wrong about being able to read the variables in the end then... Edited April 19, 2007 by evilertoaster Link to comment Share on other sites More sharing options...
Developers Jos Posted April 19, 2007 Developers Share Posted April 19, 2007 I had suspected such a problem between AU and VB, however he is SETTING the variables in VB, unless it had the same restriction on it as the AutoIt version it should work in thoery. Also he has already said he is able to read the variables in the end. However i am still wary of mixing the two seemingly unnecessarily... Edit: saw your edit.... perhaps he was wrong about being able to read the variables in the end then... Here is a simple demo of what i stated: Run(@ComSpec & " /k Set test=something") Sleep(2000) ConsoleWrite(EnvGet("test") & @LF) The Env changes are not for other running programs... only for the shelled commandprompt. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
devtester Posted April 20, 2007 Author Share Posted April 20, 2007 AutoIT sees my global assignments as strings in my script. You must cast the string variables using the int method. Works fine now. Interesting that no one caught this... 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