rawkhopper Posted March 15, 2019 Posted March 15, 2019 (edited) I am no programmer so I hate to jump to a conclusion of a bug so I thought I would ask for a some help to see if this is a bug or a problem with my script. So here is the snippet I am having trouble with. #include <GUIConstantsEx.au3> Global $MOUSE_CLICK_LEFT Local $Filtemp = 0.1 Local $Fil = 20 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send ("test") FilSend() Func FilSend() Do WinWait ("Untitled - Notepad", "", 10) WinActivate("Untitled - Notepad", "") Local $WinPos = WinGetPos("Untitled - Notepad", "") If $Filtemp < $Fil Then WinActivate("Untitled - Notepad", "") Do Sleep(100) ControlSend ("Untitled - Notepad", "", 15, "^a{BACKSPACE}") ControlSend ("Untitled - Notepad", "", 15, $Filtemp) ; \ Fil Until $Filtemp = ControlGetText ("Untitled - Notepad", "", 15) ControlClick ("Untitled - Notepad", "", 15) ControlSend("Untitled - Notepad", "", 15, "{ENTER}") ;Hit ENTER if value is correct Sleep(200) $Filtemp = $Filtemp + 0.1 Sleep (1000) EndIf Until $Filtemp = $Fil EndFunc This script should just count up in notepad changing once per second in 0.1 steps. When I do this it stops at 0.3 and hangs. If I change $Filtemp to 0.3 to start with it will count to 0.8 and hang. If I start at 0.8 it will go to 1.2 and hang. If I switch $Filtemp to 1 and change the steps to 1 instead of 0.1 it seems to work just fine. Can this be repeated by someone other than me? Sorry for some of the excess in the code but this is for the main script I am working on. Oh BTW Windows 10 Home 64bit and AutoIt V3.3.14.5 Edited March 15, 2019 by rawkhopper added info
Developers Jos Posted March 15, 2019 Developers Posted March 15, 2019 Change this line to force it to do a string comparison: Until $Filtemp == ControlGetText("Untitled - Notepad", "", 15) Jos 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.
rawkhopper Posted March 15, 2019 Author Posted March 15, 2019 (edited) Ok awesome this works! I have a question though I originally had the until statement as a while like this: While $Filtemp <> ControlGetText("Untitled - Notepad", "", 15) Is there an equivalent to == in the until statement to fix this? Edited March 15, 2019 by rawkhopper entered too earlier
rawkhopper Posted March 15, 2019 Author Posted March 15, 2019 Like this #include <GUIConstantsEx.au3> Global $MOUSE_CLICK_LEFT Local $Filtemp = 0.3 Local $Fil = 20 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send ("test") FilSend() Func FilSend() Do WinWait ("Untitled - Notepad", "", 10) WinActivate("Untitled - Notepad", "") Local $WinPos = WinGetPos("Untitled - Notepad", "") If $Filtemp < $Fil Then WinActivate("Untitled - Notepad", "") While $Filtemp <> ControlGetText("Untitled - Notepad", "", 15) Sleep(100) ControlSend ("Untitled - Notepad", "", 15, "^a{BACKSPACE}") ControlSend ("Untitled - Notepad", "", 15, $Filtemp) ; \ Fil WEnd ControlClick ("Untitled - Notepad", "", 15) ControlSend("Untitled - Notepad", "", 15, "{ENTER}") ;Hit ENTER if value is correct Sleep(200) $Filtemp = $Filtemp + 0.1 Sleep (1000) EndIf Until $Filtemp = $Fil EndFunc
rawkhopper Posted March 15, 2019 Author Posted March 15, 2019 I get the same results with this script as I do with the original one. A why might be helpful so I don't make this mistake anymore.
Developers Jos Posted March 15, 2019 Developers Posted March 15, 2019 Because you made the exact same mistake not forcing compare to string? Jos 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.
rawkhopper Posted March 15, 2019 Author Posted March 15, 2019 I guess I don't understand. I will try to look more into it. At least I have a working way of doing it. Thanks for the help!
Developers Jos Posted March 15, 2019 Developers Posted March 15, 2019 Use the == comparison instead of = Check the helpfile for the full explanation. Jos 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.
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