Personally I always use either GUI input OR DBP key input, however, I can see your need. There will be a RESET INPUT command in the next version, however, you can do the same in DB code by putting this at the top of your code (where "test" is the title of your window):
global dbpwin
load dll "user32.dll",1
dbpwin = call dll(1,"FindWindowA","test","test")
Putting this function in somewhere:
function ResetInput()
if dbpwin <> 0 then call dll 1,"SetFocus",dbpwin
endfunction
You then call ResetInput() whenever you want to restore key input to the DBP window, eg at the end of a loop if current <> 0.
So your completed code for the example you posted would be:
setup gui "test",""
create gadget panel 1,1
position gadget 1,300,0
resize gadget 1,100,300
create with parent 1
create gadget button 2,"Test 1"
position gadget 2,10,10
resize gadget 2,75,25
create gadget button 3,"Test 2"
position gadget 3,10,45
resize gadget 3,75,25
create without parent
global dbpwin
load dll "user32.dll",1
dbpwin = call dll(1,"FindWindowA","test","test")
do
current = gadget clicked()
if current = 2
set cursor 0,0
print "Test 1"
wait 100
endif
if current = 3
set cursor 0,0
print "Test 2"
wait 100
endif
if current <> 0 then ResetInput()
sync
loop
function ResetInput()
if dbpwin <> 0 then call dll 1,"SetFocus",dbpwin
endfunction
Sorry I left that command out.