Jump to content

After Launching Excel, the GUI doesn't close anymore


Go to solution Solved by realtebo,

Recommended Posts

Posted

 
Func ImportIntoExcel()
   Run ("C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE", @UserProfileDir & "\Downloads")
   WinWaitActive ("Microsoft Excel");
   Send("!AFT") ; // Dati -> Importa da testo
   WinWaitActive ("Importa fle di testo");
   Sleep(1200)
   Send("^N")
   Send("..\Downloads\")
   Send("{ENTER}")
EndFunc
 
Func CreateConfirmedPoGui()

   Local $hGUI                     = GUICreate("Ordini Amazon in stato 'confermato'",450 , 200, -1, -1, BitOR(0, $WS_SIZEBOX))
   Local $po_count                 = UBound($confirmed_po_links, $UBOUND_ROWS );
   Local $po_button[$po_count]

   For $row = 0 To ($po_count -1)
      Local $po_number = $confirmed_po_links[$row][0]
      $po_button[$row] = GUICtrlCreateButton($po_number, 5, $row*30+5)
   Next

   $import_into_excel_button = GUICtrlCreateButton("Importa CSV in Excel", 100, 5)

   GUISetState(@SW_SHOW, $hGUI)

   While 1
      Local $source = GUIGetMsg()

      If $source == $GUI_EVENT_CLOSE Then
         ExitLoop
      EndIf

      If $source == $import_into_excel_button Then
         ImportIntoExcel()
      EndIf

      For $btn = 0 to ($po_count -1)
         If ($source) == $po_button[$btn] Then
            ConsoleWrite ("Devo aprire l'ordine n. " & $confirmed_po_links[$btn][0] & @CRLF)
            OpenPo($confirmed_po_links[$btn][0])
         EndIf
      Next

   WEnd

   ; Delete the previous GUI and all controls.
   GUIDelete($hGUI)

EndFunc

 

After user click import button, I launch Ms Excel 2010 and start import procedure.

I close excel

My autoit GUI react to import button, but doesn't more react to close button (the top-right 'X', i've not  a custom close button)

What!!?!?

I must terminate the windows process to kill my gui

Posted

Why don't you use the Excel UDF that comes with AutoIt. Much better than automating the Excel GUI.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I didnt' know that Excel UDF exists...  i' looking at the help files now.

Anyway, I need to import a CSV (previously downloaded from a vendor portal) into excel. I didn't see any usefull function in this situation.

Thanks anyway, but please, help me to understand what is blocking the GUI in my code.

  • Solution
Posted

Solved !

I was supposing that WinWaitActive could work with open file dialog (which has a custom italian title in Excel 2010).

WinWaitActive ("Importa file di testo");

 

Removed it, all it's working well !

Posted

But I still suggest to use the Exel UDF. It is far more reliable compared to using Send. Send always goes to the active window. So fi the user or another program steals the focus you are lost and your script hangs.

To open a CSV file is a simple 3 line task.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I understand, but there are complex task not doable with UDF, so, instead of do some task with udf an some other with automation, and restart, I choosed to use only automation.

Actually, users are happy, so my chef is happy, so I'm happy.

Posted (edited)

The UDF uses the COM interface. Only the most used functions are covered by the UDF. The UDF just makes using COM a bit easier.

Means:

What isn't covered by the UDF still can be coded by you by using the required methods, objects, collections and properties of the Excel object Model.

Best way to learn how to use COM is to have a look at MSDN and/or ask here ;)

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

This is interesting. I know really well Excel doc because I'm used to Office macros. I'll give it a study in a week or two.

But, anyway, i'm confident that in this specific case this is the better way, please, accept it.

Posted

No problem with accepting how you solve your problems :)

Just wanted to show you a more reliable way.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...