Hi, I am using this guys code which was a great help (thanks!) http://www.autohotke...-source-dialog/
I have edited it to remove as much of the gui as possible, but i cant seem to get it to work if i remove anymore of the gui....
hModule := DllCall("LoadLibrary", "str", "avicap32.dll") ;Gui, Add, Button, x440 y120 w50 h24 gCopyToClipBoard, Copy Gui +LastFound hwndParent := WinExist() ; Show Gui, Show, w500 h400, Video For Windows for AutoHotkey - VFW4AHK GoSub, ConnectToDriver ;waits for the cam to startup Sleep, 1000 GoSub, CopyToClipBoard Return ConnectToDriver: ; --- Connect and preview capHwnd := Cap_CreateCaptureWindow(hwndParent, 10, 124, 320, 240) ;ToolTip % errorlevel WM_USER = 0x0400 WM_CAP_START := WM_USER WM_CAP_GRAB_FRAME_NOSTOP := WM_USER + 61 WM_CAP_FILE_SAVEDIB := WM_CAP_START + 25 WM_CAP := 0x400 WM_CAP_DRIVER_CONNECT := WM_CAP + 10 WM_CAP_DRIVER_DISCONNECT := WM_CAP + 11 WM_CAP_EDIT_COPY := WM_CAP + 30 WM_CAP_SET_PREVIEW := WM_CAP + 50 WM_CAP_SET_PREVIEWRATE := WM_CAP + 52 WM_CAP_SET_SCALE := WM_CAP + 53 ; Connect to driver thisInfo := Cap_GetDriverDescription(A_Index-1) SendMessage, WM_CAP_DRIVER_CONNECT, %thisInfo%, 0, , ahk_id %capHwnd% ;ToolTip % errorlevel ; Set the preview scale SendMessage, WM_CAP_SET_SCALE, 1, 0, , ahk_id %capHwnd% ;ToolTip % errorlevel ; Set the preview rate in milliseconds SendMessage, WM_CAP_SET_PREVIEWRATE, 66, 0, , ahk_id %capHwnd% ;ToolTip % errorlevel ; Start previewing the image from the camera SendMessage, WM_CAP_SET_PREVIEW, 1, 0, , ahk_id %capHwnd% ;ToolTip % errorlevel ToolTip Return CopyToClipBoard: SendMessage, WM_CAP_EDIT_COPY, 0, 0, , ahk_id %capHwnd% Return SenToFile: imagefile = C:\image.bmp SendMessage, WM_CAP_FILE_SAVEDIB, 0, &imagefile, , ahk_id %capHwnd% ToolTip % errorlevel return DisconnectDriver: SendMessage, WM_CAP_DRIVER_DISCONNECT, 1, 0, , ahk_id %capHwnd% Return Cap_CreateCaptureWindow(hWndParent, x, y, w, h) { WS_CHILD := 0x40000000 WS_VISIBLE := 0x10000000 lpszWindowName := "test" lwndC := DLLCall("avicap32.dll\capCreateCaptureWindowA" , "Str", lpszWindowName , "UInt", WS_VISIBLE | WS_CHILD ; dwStyle , "Int", x , "Int", y , "Int", w , "Int", h , "UInt", hWndParent , "Int", 0) ;msgbox % lwndC " | " errorlevel " | " lpszWindowName " | " hwndParent Return lwndC } Cap_GetDriverDescription(wDriver) { VarSetCapacity(lpszName, 100) VarSetCapacity(lpszVer, 100) res := DLLCall("avicap32.dll\capGetDriverDescriptionA" , "Short", wDriver , "Str", lpszName , "Int", 100 , "Str", lpszVer , "Int", 100) If res capInfo := lpszName ; " | " lpszVer Return capInfo } GuiClose: GoSub, DisconnectDriver DllCall("FreeLibrary", "str", hModule) ExitApp Return !r::Reload ; for debugging
If i ; out the line : ;Gui, Show, w500 h400, Video For Windows for AutoHotkey - VFW4AHK
the gui never shows but the screenshot is always black.. If i dont ; out this line it works fine.
Any ideas? I dont wana see anything.. just take a screenshot or save a jpeg.