Partial placeholder, I'll post code to resolve the pause issue when I've had a time to grab lunch and work it out.
Update:
Looks like you have two options. You can either include misc.au3 in your scripts and use the _IsPressed function to check for the key presses and then run the proper code. This could probably work out ok depending on the script.
The other involves setting up like a virtual keyboard and then works in the expected way. Ill update again in a bit.
Update 2:
Here's the examples I found of how to do this. First is u sing misc.au3 and its _IsPressed() function and the second sort of hooks into the keyboard. I'm not sure why hotkeys work as expected in AHK and not AutoIt.
Code:
#include <Misc.au3>
$dll = DllOpen("user32.dll")
While 1
If _IsPressed("1b", $dll) Then
MsgBox(0,"Pressed","Esc")
ExitLoop
EndIf
WEnd
DllClose($dll)
Second example.
Code:
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Global Const $VK_DELETE = 0x2E
Global Const $VK_ESCAPE = 0x1B
Global $hFunc, $pFunc
Global $hHook
Global $hMod
Global $fPauseBot = False
$hFunc = DllCallbackRegister('_KeyboardHook', 'lresult', 'int;uint;uint')
$pFunc = DllCallbackGetPtr($hFunc)
$hMod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, $pFunc, $hMod)
While 1
If $fPauseBot Then
_UnsetHotKeys()
While $fPauseBot
Sleep(20)
WEnd
_ResetHotKeys()
EndIf
Sleep(20)
WEnd
Func OnAutoItExit()
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hFunc)
EndFunc
Func _UnsetHotKeys()
HotKeySet("+!d")
EndFunc
Func _ResetHotKeys()
HotKeySet("+!d", "ShowMessage");Shift-Alt-d
EndFunc
Func ShowMessage()
MsgBox(0x40, 'Title', 'Text')
EndFunc
Func _KeyboardHook($iCode, $iwParam, $ilParam)
Local $tKBDLLHS = DllStructCreate($tagKBDLLHOOKSTRUCT, $ilParam)
Local $iVkCode
If $iCode > -1 Then
$iVkCode = DllStructGetData($tKBDLLHS, 'vkCode')
If $iwParam = $WM_KEYUP Then
Switch $iVkCode
Case $VK_ESCAPE
Exit
Case $VK_DELETE
$fPauseBot = Not $fPauseBot ; Was $fPauseBot = True.
EndSwitch
EndIf
EndIf
Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc
This code is not mine, both come from the AutoIt forums. I will probably rewrite and include a modified version of the second in my bot functions at a later date.