Moderators SmOke_N Posted February 24, 2005 Moderators Posted February 24, 2005 (edited) I didn't know what how to spell "Variable", until 3 days ago. To say the least, I have absolutely no Idea what is right or wrong. I've written and re-written per the Novice-Instructions provided in the autoit help.Just when I think I might be on to something....poof, nada. I was wondering if you could look at my script and help me either to correct it or lead me in the right direction.What I'm attempting to do, is get the script to read text in the ControlID of one window, based up that text to take an action with mouseclick / drag in another window. Basically taking action based on the text in that window.expandcollapse popupGlobal $t1 = "untitled-1"Global $t2 = "untitled-2"WinWaitActive($t1)While WinExists($t1) Sleep(300); $action = GetAction(); if $action = 1 then #region Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait($t1) If Not WinActive($tablename) Then WinActivate($t1) WinWaitActive($t1) MouseMove(474,534) MouseDown("left") MouseUp("left") Sleep(1000) #endregion elseif $action = 2 then #region Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait($t1) If Not WinActive($tablename) Then WinActivate($t1) WinWaitActive($t1) MouseMove(574,543) MouseDown("left") MouseUp("left") Sleep(1000) #endregion elseif $action = 3 then #region Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait($t1) If Not WinActive($tablename) Then WinActivate($t1) WinWaitActive($t1) MouseMove(714,527) MouseDown("left") MouseUp("left") Sleep(1000) #endregion elseif $action = 4 then #region Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait($t1) If Not WinActive($t1) Then WinActivate($t1) WinWaitActive($t1) MouseMove(685,473) MouseDown("left") MouseMove(692,472) MouseUp("left") Sleep(1000) MouseMove(708,530) MouseDown("left") MouseUp("left") Sleep(1000) #endregion endifWEndFunc GetAction() WinActivate ($t2 & $t1); $Blah1 = ControlGetText($t2, "Blah1", "1111"); if $Fold = ("Blah1") then WinActivate($t1); return 1; endif $Blah2 = ControlGetText($t2, "Blah2", "1111"); if $Blah2 = ("Blah2") then WinActivate($t1); return 2; endif $Blah3 = ControlGetText($t2, "Blah3", "1111"); if $Blah3 = ("Blah3") then WinActivate($t1); return 2; endif $Blah4 = ControlGetText($t2, "Blah4", "1111"); if $Blah4 = ("Blah4") then WinActivate($t1); return 3; endif $Blah5 = ControlGetText($t2, "Blah5", "1111"); if $Blah5 = ("Blah5") then WinActivate($t1); return 4; endif WinActivate($t1);EndFuncI commend the tedious task that you perform daily in these types of scripts. I'll never look at a program the same again. P.S., how do you force yourself to sleep when you think you got it. I've slept 4 hrs, in 3 days.Anyway, thanks for your responses in advanced. Edited February 24, 2005 by ronsrules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. (adsbygoogle = window.adsbygoogle || []).push({}); Moderators SmOke_N Posted February 24, 2005 SmOke_N Moderators 16.3k 49 It's not what you know ... It's what you can prove! Author Moderators Posted February 24, 2005 See, I can't even get that white box that ya'll get when you post your code. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Insolence Posted February 24, 2005 Insolence Active Members 1.3k Not distastefully arrogant Posted February 24, 2005 As for the sleeping matter, it's very hard I often end up thinking about it and then after a while forcing myself back to the computer. Throw a I gotta hit the hay, let me ask a couple standard questions: 1) Are you using the Window Info Tool to grab the control ID's? 2) Does the code run fine, without errors? And last but not least, I noticed you were using some #region tags, which is good, but you should label them: #region "This is where I scan for x" #endregion Makes it a little more organized "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Moderators SmOke_N Posted February 24, 2005 Author Moderators Posted February 24, 2005 As for the sleeping matter, it's very hard I often end up thinking about it and then after a while forcing myself back to the computer.Throw a I gotta hit the hay, let me ask a couple standard questions:1) Are you using the Window Info Tool to grab the control ID's?2) Does the code run fine, without errors?And last but not least, I noticed you were using some #region tags, which is good, but you should label them:#region "This is where I scan for x" #endregionMakes it a little more organized <{POST_SNAPBACK}>I totally understand the getting up thing, layed down for 45 mins, and had to come see if someone posted this late at night.Q: 1) Are you using the Window Info Tool to grab the control ID's?A: 1) Yes. Autoinfo.Q: 2) Does the code run fine, without errors?A: 2) Yes, I've checked ctr+F5 for errors, generally every line of script because I am just learning. (Horrible isn't it, if not quite time consuming)I actually got the mouse to move, on the very last 2 lines of script, I had return 1 between them, and of course all it would do is the first Mouseclick.ThanksThanks for the #region "", I've actually done that Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Blue_Drache Posted February 24, 2005 Posted February 24, 2005 I totally understand the getting up thing, layed down for 45 mins, and had to come see if someone posted this late at night.<snip>ThanksThanks for the #region "", I've actually done that <{POST_SNAPBACK}>OK, You're re-declaring your Opt() functions waaaay too many times. They only need to be called once, usually in the initialization phase with all the #includes and Dim statements. Then only call them again if they need to change for some reason. Taking out all those initialization #regions will also make your code more readable.Func GetAction() WinActivate ($t2 & $t1); $Blah1 = ControlGetText($t2, "Blah1", "1111"); if $Fold = ("Blah1") thenIs this psuedo code? You can't have two windows active at the same time. You can activate $t1 OR $t2....not both.There are some other minor syntax errors as well, but I'll nudge you in this direction for now. Good luck. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Moderators SmOke_N Posted February 24, 2005 Author Moderators Posted February 24, 2005 OK, You're re-declaring your Opt() functions waaaay too many times. They only need to be called once, usually in the initialization phase with all the #includes and Dim statements. Then only call them again if they need to change for some reason. Taking out all those initialization #regions will also make your code more readable.Func GetAction() WinActivate ($t2 & $t1); $Blah1 = ControlGetText($t2, "Blah1", "1111"); if $Fold = ("Blah1") thenIs this psuedo code? You can't have two windows active at the same time. You can activate $t1 OR $t2....not both.There are some other minor syntax errors as well, but I'll nudge you in this direction for now. Good luck.<{POST_SNAPBACK}>Thanks, I removed the #regions, but I'm trying to get the script to read $t2 for a specific text, if that text exist, then to take action 1 in $t3, if not, go to next text, if that text exist, take action 2, but I'm so lost it's getting frustrating.I understand you can't have 2 windows active at the same time, So how do I get it to read text in $t2, and take action in $t1?Thanks again for your kindness Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
pcdestroyer Posted February 24, 2005 Posted February 24, 2005 I understand you can't have 2 windows active at the same time, So how do I get it to read text in $t2, and take action in $t1?Thanks again for your kindness<{POST_SNAPBACK}>activate the $t2 first then read the text u need .. then activate $t1 and write it ...hope that helps
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