USSSR Posted March 12, 2021 Share Posted March 12, 2021 This code should always run the script when I press button_2 to execute. It runs the script only once and then it shuts down? Where is the problem? Another thing is that after script is done, I would like to bring the GUI window active. How is this done? Many thanks in advance Starting my AutoIt career.. Quote #include <GuiConstants.au3>;Functions needed for most GUI Code GuiCreate("Your GUI", 472, 188);Create GUI Window with the width of 472 and height of 188 $Button_1 = GuiCtrlCreateButton("Exit", 10, 130, 130, 50);Button_1 is the Exit Button $Button_2 = GuiCtrlCreateButton("Run script", 250, 100, 210, 80); Button_2 is the Execute Script function GuiSetState() While 1;your LOOP $msg = GuiGetMsg();retrieves the button or control that was pressed Select; starts a case statement Case $msg = $GUI_EVENT_CLOSE;case statement, its like an if statement but better when you have alot of statements ExitLoop; If the program is exited it will exit the loop. Case $msg = $Button_1 ExitLoop;Exits the Loop Case $msg = $Button_2 ExecuteScript(); goes to the Execute Script function EndSelect; ends the case statements WEnd Func ExecuteScript();Creats the Execute Script Function ;Your Code #include <Constants.au3> Opt("WinTitleMatchMode", 2) Local $hWnd = WinGetHandle("- Information -") ConsoleWrite ($hWnd & @CRLF) WinActivate($hWnd) WinWaitActive($hWnd) ;Send forward MouseClick($MOUSE_CLICK_PRIMARY, 293, 388, 1) Sleep(500) MouseClick($MOUSE_CLICK_PRIMARY, 293, 421, 1) Sleep(500) ;Make it happen MouseClick($MOUSE_CLICK_PRIMARY, 740, 52, 1) Sleep(1000) ;Save as -> yes Send("{ENTER}") Sleep(5000) ;Do you want to open it -> no Send("{TAB}") Sleep(1000) Send("{ENTER}") Sleep(3000) ;Next one Send("^{INSERT}") EndFunc Link to comment Share on other sites More sharing options...
USSSR Posted March 12, 2021 Author Share Posted March 12, 2021 Error looks like this Link to comment Share on other sites More sharing options...
Nine Posted March 12, 2021 Share Posted March 12, 2021 Do not put #include inside a func, you will get all sort of problems. Always gather them at the very beginning of a script. When you post code, please use this tool. USSSR 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
USSSR Posted March 12, 2021 Author Share Posted March 12, 2021 Thanks for these. This advice fixed my problem. Link to comment Share on other sites More sharing options...
USSSR Posted March 12, 2021 Author Share Posted March 12, 2021 24 minutes ago, Nine said: Do not put #include inside a func, you will get all sort of problems. Always gather them at the very beginning of a script. When you post code, please use this tool. Do you know how to bring the GUI window active always after script has run? How is this done? Link to comment Share on other sites More sharing options...
Nine Posted March 12, 2021 Share Posted March 12, 2021 Give a handle to your GUI like : Local $hGUI = GUICreate(....) And use the WinActivate($hGUI) at the appropriate place. USSSR 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
USSSR Posted March 12, 2021 Author Share Posted March 12, 2021 Yes thanks that helped. 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