Jump to content

Pause for input


Docfxit
 Share

Go to solution Solved by ioa747,

Recommended Posts

I'm working with Quickbooks.  I start a Journal Entry, Enter the date, put the cursor in the first account field then I run this script.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
#include <MsgBoxConstants.au3>

; Press Esc to terminate script, Pause/Break to "pause"
Opt("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

Global $g_bPaused = False

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
HotKeySet("{+!2}", "_HotKeyPressed") ;If you press Alt-2, the script will Pause
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
HotKeySet("{ESC}", "_HotKeyPressed")
HotKeySet("+!d", "_HotKeyPressed") ; Shift-Alt-d

WinWait("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal")
If Not WinActive("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal") Then WinActivate("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal")
WinWaitActive("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal")
Send("dcu{TAB}")
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
Send("{+!2}")    ; I would like it to pause here and it is
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
WinWait("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal")
If Not WinActive("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal") Then WinActivate("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal")
WinWaitActive("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal")
Send("{TAB}{TAB}{SHIFTDOWN}i{SHIFTUP}nterest{TAB}digital{TAB}tes{ALTDOWN}n{ALTUP}")


Func _HotKeyPressed()
        Switch @HotKeyPressed ; The last hotkey pressed.
                Case "{+!2}" ; String is the {PAUSE} hotkey.
                        $g_bPaused = Not $g_bPaused
                        While $g_bPaused
                                Sleep(100)
                                ToolTip('Script is "Paused"', 0, 0)
                        WEnd
                        ToolTip("")

                Case "{ESC}" ; String is the {ESC} hotkey.
                        Exit

                Case "+!d" ; String is the Shift-Alt-d hotkey.
                        MsgBox($MB_SYSTEMMODAL, "", "This is a message.")

        EndSwitch
EndFunc   ;==>_HotKeyPressed

I would like the script to enter the account (which it does) and then go to the debit column (which it does) and pause to let me enter the amount.

I'm doing something wrong in the script because I can't un-pause it.

I also don't have a pause or a break key on my keyboard. (That I know of)  Can I change it to a alt-2 key?

Edited by Docfxit
Link to comment
Share on other sites

Changing it to Send("{PAUSE}")

Worked great.  It does pause now.

I changed the

HotKeySet("{+!2}", "_HotKeyPressed")

In the code on the first post to pause it.  I'm trying to get the pause to Alt-2.  It doesn't un-pause it when I press that key combination.

Do you have any suggestions as to an easy key to use?

Link to comment
Share on other sites

this line is wrong
HotKeySet("{+!2}", "_HotKeyPressed") ;If you press Alt-2, the script will Pause

replace with
HotKeySet("+!2", "_HotKeyPressed") ;If you press shift+Alt+2, the script will Pause

or you can direct set
$g_bPaused = true

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

  • Solution

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <MsgBoxConstants.au3>

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)

; Press Esc to terminate script, Pause/Break to "pause"
Opt("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

Global $g_bPaused = False

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
HotKeySet("+!2", "_Paused") ;If you press Shift-Alt-2, the script will Pause\UnPause
HotKeySet("{ESC}", "_Exit")
HotKeySet("+!d", "_Msg") ; Shift-Alt-d
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

Global $hDocfxit = WinWait("Docfxit, Inc.  - QuickBooks Desktop Pro 2021","Make General Journal")

If Not WinActive($hDocfxit) Then WinActivate($hDocfxit)
WinWaitActive($hDocfxit)
Send("dcu{TAB}")

_Paused()

WinWait($hDocfxit)
If Not WinActive($hDocfxit) Then WinActivate($hDocfxit)
WinWaitActive($hDocfxit)
Send("{TAB}{TAB}{SHIFTDOWN}i{SHIFTUP}nterest{TAB}digital{TAB}tes{ALTDOWN}n{ALTUP}")


;----------------------------------------------------------------------------------------
Func _Paused()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>_HotKey_Paused
;----------------------------------------------------------------------------------------
Func _Exit()
    Exit
EndFunc
;----------------------------------------------------------------------------------------
Func _Msg()
    MsgBox($MB_SYSTEMMODAL, "", "This is a message.")
EndFunc
;----------------------------------------------------------------------------------------

 

Edited by ioa747
UpDate

I know that I know nothing

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