Jump to content

After Launching Excel, the GUI doesn't close anymore


realtebo
 Share

Go to solution Solved by realtebo,

Recommended Posts

 
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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

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