Sign in to follow this  
Followers 0
silverhawk184

autoit access quickbooks controls

1 post in this topic

Hello,

I have been working on a project for work, to automatically print out our monthly forms on the first of the month. I have tried controlling quickbooks (Enterprise 9 update: 11) via sending controlsend and controlclick commands, but they are very unreliable.

I have tried accessing the controls via ID, CLASSID, and CLASS-Instance, nothing really works, although sending keystrokes works perfect.

Can someone please try this on their system and see what I am doing wrong? (with modification first of course)

#include "array.au3"

global $club[1]=["example"]
global $pages[1][7][2]=[ _
  [ _  
    [120, "Balance Sheet"], _
    [198, "Profit & Loss Budget Performance"], _
    [133, "Consolidated - Profit & Loss Budget vs. Actual"], _
    [146, "Department - Profit & Loss Budget vs. Actual"], _
    [158, "Food and Beverage - Profit & Loss Budget vs. Actual"], _
    [172, "Maintenance Department - Profit & Loss Budget vs. Actual"], _
    [186, "Administration - Profit & Loss Budget vs. Actual"] _
  ], _
]




ShellExecute("s:\blah blah blah.QBW")

$hndl = WinGetHandle("blah blah blah  - QuickBooks Enterprise Solutions: Retail Edition 9.0", "")

; start login (has issues: username and password go in same box, and the OK command clicks the change password button)
ConsoleWrite(WinWaitActive("QuickBooks Login","OK") &@LF)
ConsoleWrite(controlsend("QuickBooks Login","OK","[CLASS:Edit; INSTANCE:1]","{del 100}username") &@LF)
ConsoleWrite(controlsend("QuickBooks Login","OK","[CLASS:Edit; INSTANCE:2]","{del 100}password") &@LF)
ConsoleWrite(ControlClick("QuickBooks Login","OK","[CLASS:MauiPushButton; INSTANCE:2]") &@LF)

; close popup if it comes within 2 sec
ConsoleWrite(WinWaitActive("QuickBooks Information","OK","2") &@LF)
if WinExists("QuickBooks Information","OK")Then
  ControlClick("QuickBooks Information","OK","[CLASS:MauiPushButton; INSTANCE:1]")
EndIf


ConsoleWrite(WinWaitActive($hndl) &@LF)

; navigate to memorized reports
send ("!rzl")
WinWaitActive($hndl,"Memorized Report List")

;start running pages
For $i = 0 to 6
  ;double click on the required memorized report (has issues, and clicks on wrong report)
  consolewrite(ControlClick($hndl,"Memorized Report List","[CLASS:MauiPopUp; INSTANCE:1]","left",2,25, $pages[0][$i][0]))
  ConsoleWrite(WinWaitActive($hndl,$pages[1][$i][1]) & @LF)

  ;click print button (never happens, use send("!t") as a work around)
  ControlClick($hndl,$pages[0][$i][1],"[CLASS:MauiPushButton; INSTANCE:3]")
  ConsoleWrite(WinWaitActive("Print Reports") &@LF)
  ConsoleWrite(ControlClick("Print Reports","","[CLASS:MauiRadioButton; INSTANCE:3]") & @LF)
  ConsoleWrite(ControlCommand("Print Reports","","[CLASS:MauiCheckBox; INSTANCE:5]","Check") & @LF)
  
  ;click final print button (never happens)
  ConsoleWrite(ControlClick("Print Reports","","[CLASS:MauiPushButton; INSTANCE:5]") & @LF)

  ;this is as far as I got for troubleshooting for the day  
  ConsoleWrite(WinWaitActive("Save PDF File As") & @LF)
  ConsoleWrite(ControlSend("Save PDF File As","","[CLASS:Edit; INSTANCE:1]","C:\reports\"&$club[$i]&"\"&$i&".pdf") & @LF)
  ConsoleWrite(ControlClick("Save PDF File As") & @LF)
  ConsoleWrite(WinWaitActive("[CLASS:AdobeAcrobat]") & @LF)
  WinClose("[CLASS:AdobeAcrobat]")
  WinActivate($hndl,$pages[0][$i][1])
  send("{esc}")
Next

Share this post


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
Sign in to follow this  
Followers 0