I have revised your post to put all of your scripts in a Code Block. Please use Code Blocks in the future.
In order for us to help you, we need more information.
Please be much more specific about what "won't work".
- Exact error message
- Line where error occurred
- Expected result
- Actual result
- When UI scripting, show a screenshot of the area you are scripting.
Also, please use actual app name, rather than "My Internal app".