SendInput problem with win gadget [SOLVED]
Posted: Wed Sep 24, 2025 6:07 am
Hi,
In below code, if I comment out line ";MessageRequester("Wait","Wait Capture screen to complete")" , the progam does not work, I cannot replace it with a delay() command such that no user inout is required. Any suggestion? Without the CreateWin(), the capture screen also works.
Win 11 pro 24H2, PB 6.21.
Thanks
Allen
In below code, if I comment out line ";MessageRequester("Wait","Wait Capture screen to complete")" , the progam does not work, I cannot replace it with a delay() command such that no user inout is required. Any suggestion? Without the CreateWin(), the capture screen also works.
Code: Select all
UseJPEGImageDecoder()
UseJPEGImageEncoder()
Procedure CaptureScreen()
Protected.INPUT InputKey
; Print screen Key down
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk =#VK_SNAPSHOT
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;Key Release
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = #VK_SNAPSHOT
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
EndProcedure ;CaptureScreen()
Procedure CreateWin()
OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu)
ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left)
ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right)
ButtonGadget(3, 10,100, 200, 60, "Multiline Button (longer text gets automatically wrapped)", #PB_Button_MultiLine)
ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle)
;MessageRequester("Wait","Wait window to complete")
EndProcedure
Global.i ImageID
CreateWin()
ClearClipboard()
CaptureScreen()
;MessageRequester("Wait","Wait Capture screen to complete")
ImageID=GetClipboardImage(#PB_Any)
If ImageID
MessageRequester("Capture Success",Str(ImageID))
Else
MessageRequester("Capture Fail",Str(ImageID))
EndIf
Thanks
Allen