montyali Posted October 18, 2021 Posted October 18, 2021 (edited) Hi everyone, need some help...trying to move certain windows to a poistion/size. Not sure if this is possible, but can part of script be copied from a text file while already running? HotKeySet("+^k", "_SetWinPosition") While 1 Sleep(1) WEnd Func _SetWinPosition() ??? EndFunc And lets say I am reading ??? from a text file called TEST.txt, and content of file is as follows... WinActivate("New tab - Internet Explorer") WinMove("New tab - Internet Explorer", "", 676, 22, 1023, 853) WinActivate("Test - Notepad") WinMove("Test - Notepad", "", 645, 316, 688, 707) Edited October 18, 2021 by montyali correction
Danp2 Posted October 18, 2021 Posted October 18, 2021 Have a look at Execute in the help file Latest Webdriver UDF Release Webdriver Wiki FAQs
montyali Posted October 18, 2021 Author Posted October 18, 2021 (edited) HotKeySet("+^l", "_SetWinPosition") While 1 Sleep(1) WEnd Func _SetWinPosition() $setposdata = FileRead(@ScriptDir & "\TEST.txt") Execute($setposdata) EndFunc WinActivate("New tab - Internet Explorer") WinMove("New tab - Internet Explorer", "", 676, 22, 1023, 853) WinActivate("Test - Notepad") WinMove("Test - Notepad", "", 645, 316, 688, 707) and where TEST.txt contained above text...sorry this did not work for me ...also, it's reading the file properly though, but not executing. Edited October 18, 2021 by montyali
Danp2 Posted October 18, 2021 Posted October 18, 2021 "Did not work" isn't helpful. Did you happen to check @error after calling Execute? Chances are that you need to read the file to an array and the execute each command separately. Latest Webdriver UDF Release Webdriver Wiki FAQs
Developers Jos Posted October 18, 2021 Developers Posted October 18, 2021 (edited) Execute() needs a single valid statement... not a multiline script so I am sure you are getting @error = 1. This will work: $myexecute = 'WinActivate("Test - Notepad") + WinMove("Test - Notepad", "", 645, 316, 688, 707)' $myexecute = 'WinActivate("Test - Notepad") + WinMove("Test - Notepad", "", 645, 316, 688, 707)' ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Execute($myexecute) = ' & Execute($myexecute) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Jos Edited October 18, 2021 by 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.
JockoDundee Posted October 18, 2021 Posted October 18, 2021 2 hours ago, Jos said: This will work: $myexecute = 'WinActivate("Test - Notepad") + WinMove("Test - Notepad", "", 645, 316, 688, 707)' What about using & instead of + $myexecute = 'WinActivate("Test - Notepad") &" "& WinMove("Test - Notepad", "", 645, 316, 688, 707)' so as to capture the individual return codes? Code hard, but don’t hard code...
Zedna Posted October 18, 2021 Posted October 18, 2021 (edited) In this case would be better to run such external script by Run(): AutoIt3.exe /AutoIt3ExecuteScript filename EDIT: as AutoIt3.exe you can use your compiled script EXE Edited October 18, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
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