Script to extract data from Excel and paste in App. App begins to act v strange

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ahk_noob
Posts: 2
Joined: 15 Jan 2018, 16:04

Script to extract data from Excel and paste in App. App begins to act v strange

17 Jan 2018, 02:51

Made my first script and it runs great, until *something* happens.

A brief description of the script and error:
For each row in excel, data is pasted into 3 boxes on a company java app. The 3rd paste is followed with an {Enter} which prompts the app to search for the information in the database, and if there's a result then a dialogue box for entering a new filename appears. If instead the database query returns empty, a dialog box appears with some words and an "ok" box.

Now this is where I start crying, because whether or not the database finds something ^v and then {Enter} should close either dialog box with no issues, except that after the "ok" box closes an identical box opens. I tried simply pressing enter twice, but the second enter is ignored. A MouseClick appears incorrectly on the taskbar. I think even a MsgBox command got ignored, but it was late at that point...

This script runs perfectly fine on my non-work laptop, or if all entries result with a saved file.

Can anyone please enlighten me on what might possibly be going on here?

Work laptop runs with windows 7 and 4GB of ram, though it seems like AHK uses hardly any resources.


Code: Select all

FileSelectFile, Path

Xl := ComObjCreate("Excel.Application")
Xl.Visible := false
oWorkbook := Xl.Workbooks.Open(Path) ;open an existing file
oSheet := oWorkbook.Sheets(1)
current_row := 2
Array := []
MsgBox % "pray"

while oSheet.Range("A" . current_row).Value != ""
{
    addressFull := oSheet.Range("A" . current_row).value
    address := oSheet.Range("B" . current_row).value
    if address is number
        address := Floor(address)
    street := oSheet.Range("C" . current_row).value
    zip := oSheet.Range("D" . current_row).value
    zip := Format("{:05}", Floor(zip))
    Array.Push([addressFull, address, street, zip])
    current_row++
}

Xl.Quit
Xl := ""
Sleep 2000

For k, v in Array
{
    submit_row(v[1], v[2], v[3], v[4])
}

MsgBox % "all done :)"
ExitApp


Escape::
Xl.Quit
Xl := ""
ExitApp
Return

;===Functions===========================================================================
submit_row(addressFull, address, street, zip) 
{
    MouseClick, Left, 1140, 250 ; address
    Send, ^a
    Send % address
    Sleep 1500
    MouseClick, Left, 1220, 250 ; street name
    Send, ^a
    Send % street
    Sleep 1500
    MouseClick, Left, 1304, 250 ; zip
    Send, ^a
    Send % zip
    Send, {Enter}
    Sleep 5000
    MouseClick, Left, 554, 188 ; submit
    Sleep 1500
    MouseClick, Left, 600, 350 ; export
    Sleep 2500
    Send % addressFull
    Sleep 2000
    Send, {Enter} ; confirm
    Sleep 3000
}
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Script to extract data from Excel and paste in App. App begins to act v strange

17 Jan 2018, 03:28

You could check Send {Raw}, or in the newer versions of AHK, Send {Text}.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
ahk_noob
Posts: 2
Joined: 15 Jan 2018, 16:04

Re: Script to extract data from Excel and paste in App. App begins to act v strange

17 Jan 2018, 04:10

I think I'm misunderstanding something. When the "ok" box is up there isn't a place for text to go.

I should have said that the box reappearing like it does can't be replicated by hand. I see some flickers from the menu button (like it's being highlighted with a mouse, i.e. MouseClick, Left, 554, 188) which can be clicked to access the sub menu option opens that dialog box, but the sub menus never actually appear. The flickering occurs much faster than the code goes, and only after the "ok" box reappears.

I'm not much of a programmer, so it's hard to know what to ask here. Apologies for the lengthy explanations.

It's the latest version though, so I can Send {Text} all night.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Script to extract data from Excel and paste in App. App begins to act v strange

17 Jan 2018, 09:00

does the windowsspy return any info about the java apps dialog box's? this can be of help as it can let you use winwait or other windows commands like maybe even controlsend, other thing that may be giving you issues is that the second box may need admin rights to intract with...
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: NinjoOnline and 230 guests