Jump to content

Error: Can not redeclare a constant?


Recommended Posts

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 post
Share on other sites

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.

Link to post
Share on other sites
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 post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...