0
votes

Immediately after calling:

inputbox,inv,Scan Invoice Number:

I want to take focus away from the inputbox and to another window but it does not behave as expected and waits for user input before moving on to the next line of code. Is there any way to override this behaviour?

1

1 Answers

1
votes

InputBox makes the current thread wait for user input and therefore suspends the thread. In other languages, you'd say the Thread terminates and an ActionListener starts listening. Multithreading itself cannot actively be achieved by calling a new Thread directly in AutoHotkey, you can, however, as stated in the documentation, launch one with a hotkey or a timed subroutine.

I came up with the following solution for myself a couple of times, afaik it's the cleanest way there is:

setTimer, continueAfterInputbox, -100   ; a negative period indicates "run once only", after a sleep of 100 ms in this case
inputbox, inv, Scan Invoice Number:
;; do things with %inv%

Return

continueAfterInputbox:
msgbox, do other cool things
return