Jump to content

Issue with Getmsg function


sravan
 Share

Recommended Posts

Hello,

Need help to "exit" from the Test.exe (got it from Test.au3 ) when wrong button is selected .

I am new to autoit,as part of my project im trying to automate the installation of windows executable setup.

I did the automation using autoit script and name of script is test.au3 ,converted the test.au3 script in to test.exe and it is working fyn.

But the problem while running this exe is ," whenever i cancel or close the window installation screen in middle of installation ,test.exe is still running in background (in taskmanager able to see the test.exe running)".

To avoid that used GUIGetMsg() expecting will receive  "GUI_EVENT_CLOSE" event whenever i select wrong button ("cancel " or "x" button in my case,attached screen shot) and 

Below is the part of script test.au3 ,please let me know whether this approach is correct or is there any other way to "exit" the .exe running in background whenver wrong button is selected.

code snippet of Test.exe:

--------------------------------------------------------------------------------------------------------------------

Func Conf_Bonj()
Run("C:\Program Files\Bonjour Print Services\PrinterWizard.exe")
Local $iMsg = 0
While 1
    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            MsgBox($MB_SYSTEMMODAL, "GUI Event", "You selected the Close button. Exiting...")
            Exit
    EndSwitch

WEnd

WinWaitActive("Bonjour Printer Wizard", "Have Disk")
ControlClick("Bonjour Printer Wizard", "", "[CLASS:Button; INSTANCE:2]")
WinWaitActive("Open", "Setup Information")

Endfunc

Conf_Bonj()

-------------------------------------------------------------------------------------------------------------------------

 

Here PrinterWizard.exe is my windows setup file which im trying to automate the installation steps.

Instead of 'cancel' or 'x' button if i select "Next " button ,my scrip will take care to install the next steps of PrinterWizard.exe .

 

 

image.png.490e2fd3ebaaa64f4c747761b0c3378d.png

 

image.png

Link to comment
Share on other sites

GUIGetMsg only works on the GUIs you create in AutoIt, it won't respond to messages from another program. You can use ProcessExists to monitor whether the program you started is still running or not.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi Brew,

 

Thanks a lot for info.

Yes ProcessExists can kill the process ,but it doesnt suits for my problem i think, because i have to kill/exit from  the process only

if user presses "cancel/X "( buttons  highlighted in screenshot attached ) ,else process should continue execution (if "Next" is selected).

so here i have to wait for the user input ,then depending on it i should perform actions.

so please help me how to wait for the user input.

 

Thanks in advance.

Link to comment
Share on other sites

You should be reading the text from the window, and if it says no printers are available, your script should click the Cancel button, and not rely on the user to do it. You should also be monitoring the process to see which dialog window is currently active, and your script should take that into account, in the case of the user pushing Cancel before your script can.

ProcessExists will not kill the process, it merely checks to see if there's a process with the name you're looking for. You should look into some of the automation scripts, of which there are thousands on here, to see how to automate a process.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...