
Zoldex
Active Members-
Posts
39 -
Joined
-
Last visited
Everything posted by Zoldex
-
I need some more help on this. Running the following example I do have strange behaviour: #include <AutoItConstants.au3> Example("user01") Example("user02") Example("user03") Func Example($uname) Local $sUserName = $uname Local $sPassword = "pw_is_always_the_same" ; Run chrome with the window maximized. chrome is run under the user previously specified. Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", @SW_SHOWMAXIMIZED) ; Wait 10 seconds for the Chrome window to appear. WinWait("[CLASS:Chrome_WidgetWin_1]", "", 10) MouseMove(579,278,40) MouseClick($MOUSE_CLICK_LEFT) Sleep(2000) ; Close the Chrome process using the PID returned by RunAs. ProcessClose($iPID) EndFunc ;==>Example I would like to run Chrome 3 times (or more) as a different user, moving the mouse, closing the app, then do it again with different user. User01 runs fine: the mouse does the job and the process closes. user02 and user03 won't launch chrome anymore but the mouse keeps on moving and clicking, as programmed. It doesn't care if the window is open or not. Also, when I try to run chrome manually as user01, most of the times it says that chrome did not close well, and asks me to restore previous state. Why don't let me run chrome as other users? Why it only seems to work with first user? Thanks in advance for any help
-
OMG you're right, of course. I've completely forgot Runas... Thanks!
-
Hello, It's loooong time I'm missing from this forum and my Autoit knowledge is heavily rusted. I'm looking for a way to run (launch) an application as other user. I do know that if I right-click an application icon while keeping Shift key pressed, i could select "run as other user", but i was looking for a more "elegant" way so I think it may be a way to do it with Autoit. If I know username and password of the other user there must be a way to do it automatically... Any help would be appreciated
-
-
Thanks mate! You saved my day!
-
I'm experiencing the very same problem: CTRL key keeps "hooked" and I need to press it alone to let it unlock. Anyways I'm having the problem also with original HotKeySet function... Hope someone can help...
-
-
Hi, it does not seem to work anymore on SAP740... _SAPSessAttach("SAP Easy Access") returns this: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Cancellabili\SAP Test\_SAPSessAttach.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Unable to find the window with title "SAP Easy Access" to attach to. "C:\Cancellabili\SAP Test\SAP.au3" (446) : ==> Variable must be of type "Object".: $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).text = $object_value $sap_session^ ERROR ->14:58:30 AutoIt3.exe ended.rc:1 Of course, the SaAP Easy Access window is open.. Any hint?
-
Just discovered your project, and I'm simply... amused! Great job, and PLEASE keep on working on it!
- 995 replies
-
- isn autoit studio
- isn
-
(and 3 more)
Tagged with:
-
Yes, it does. But the crop function does not...
-
This is my attempt on loading and let the user select only a portion of an image. I found some samples by Melba23 and UEZ and tried to glue things together. I think I've almost done it but still have some problems: Resizing and displaying image is not always proportional (just try the script with different resolution images, expecially big ones) The rectangle selection to crop is wrong: it actually selects a different region of the screen Function _GUICtrlStatic_SetImage does not work. Temporarily fixed using _WinAPI_DeleteObject instead...Any hint would be greatly appreciated! #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> #include <StaticConstants.au3> Global $iX1, $iY1, $iX2, $iY2, $aPos, $sMsg, $sBMP_Path Global Const $IMAGE_BITMAP = 0 ; Needed for GUICtrlSendMsg. Global Const $STM_SETIMAGE = 0x0172 ; Needed for GUICtrlSendMsg. Local $GUIimg_title,$GUIwidth,$GUIheight,$GUILeft,$GUITop Local $filename = FileOpenDialog("Select image", @ScriptDir, "Image (*.jpg;*.bmp)", 3) $GUIimg_title = $filename _GDIPlus_Startup() Local $imagefromfile = _GDIPlus_ImageLoadFromFile($filename) ;Create an image object based on a file [OK] **NOTA PER LA ROTAZIONE VEDI HELP FILE!** Local $GUIwidth = _GDIPlus_ImageGetWidth ($imagefromfile) Local $GUIheight = _GDIPlus_ImageGetHeight ($imagefromfile) ;try to create a smaller window if the pictures is bigger than Desktop If $GUIwidth > @DesktopWidth Then $GUIwidth = @DesktopWidth - 6 EndIf If $GUIheight > @DesktopHeight Then $GUIheight = @DesktopHeight - 73 ; rought attempt to show the window bar... EndIf $GUILeft = (@DesktopWidth - $GUIwidth) / 2 $GUITop = (@DesktopHeight - $GUIheight) / 2 $hBitmap_resized = _GDIPlus_ScaleImage($imagefromfile, $GUIwidth, $GUIheight); attempts to scale the image but it not always proportional.. _GDIPlus_ImageDispose($imagefromfile) ; Display image $hBitmap_GUI = GUICreate($GUIimg_title & " [" & $GUIwidth & "x" & $GUIheight & "]", $GUIwidth, $GUIheight,$GUILeft,$GUITop) $hPic = GUICtrlCreatePic("", 0, 0, $GUIwidth, $GUIheight) GUISetState() Local $hHBitmap_resized = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_resized); creates an handle _WinAPI_DeleteObject(GUICtrlSendMsg($hPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_resized)) ; Updates the GUI - It works instead of _GDIPlus_ImageDispose($hHBitmap_resized) [OK] _WinAPI_DeleteObject($hHBitmap_resized) ;~ _GUICtrlStatic_SetImage($hPic, $hBitmap_resized); does not seems to work... using _WinAPI_DeleteObject above _GDIPlus_Shutdown() ; Create GUI ;~ Local $GUITop = $hMain_GUI = GUICreate("Select a function", 480, 50) $hRect_Button = GUICtrlCreateButton("Crop", 10, 10, 80, 30) $hRot_90_plus_Button = GUICtrlCreateButton("+90°", 95, 10, 50, 30) $hRot_90_minus_Button = GUICtrlCreateButton("-90°", 150, 10, 50, 30) $hOK_Button = GUICtrlCreateButton("OK", 305, 10, 50, 30) $hCancel_Button = GUICtrlCreateButton("Cancel", 360, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $hCancel_Button FileDelete(@ScriptDir & "Rect.bmp") Exit Case $hRect_Button GUISetState(@SW_HIDE, $hMain_GUI) Mark_Rect($GUIwidth,$GUIheight,$GUILeft,$GUITop);selects wrong area!! ; Capture selected area $sBMP_Path = @ScriptDir & "Rect.bmp" ;~ _ScreenCapture_Capture($sBMP_Path, $iX1, $iY1, $iX2, $iY2, False) _ScreenCapture_CaptureWnd($sBMP_Path, $hBitmap_GUI,$iX1, $iY1, $iX2, $iY2, False) GUISetState(@SW_SHOW, $hMain_GUI) GUIDelete($hBitmap_GUI) ; Display image $hBitmap_GUI = GUICreate("Selected Rectangle", $iX2 - $iX1 + 1, $iY2 - $iY1 + 1, 100, 100) $hPic = GUICtrlCreatePic(@ScriptDir & "Rect.bmp", 0, 0, $iX2 - $iX1 + 1, $iY2 - $iY1 + 1) GUISetState() case $hRot_90_plus_Button ; Rotate +90 case $hRot_90_minus_Button ;Rotate -90 case $hOK_Button ;should return the resulting picture object EndSwitch WEnd ; ------------- Func Mark_Rect($width = @DesktopWidth, $height = @DesktopHeight, $Left = 0, $Top = 0);Made by Melba23 - Arguments added by me Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp Local $UserDLL = DllOpen("user32.dll") Global $hRectangle_GUI = GUICreate("", $width, $height, $Left, $Top, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST);create fading _GUICreateInvRect($hRectangle_GUI, 0, 0, 1, 1) GUISetBkColor(0) WinSetTrans($hRectangle_GUI, "", 95) GUISetState(@SW_SHOW, $hRectangle_GUI) GUISetCursor(3, 1, $hRectangle_GUI) ; Wait until mouse button pressed While Not _IsPressed("01", $UserDLL) Sleep(10) WEnd ; Get first mouse position $aMouse_Pos = MouseGetPos() $iX1 = $aMouse_Pos[0] $iY1 = $aMouse_Pos[1] ; Draw rectangle while mouse button pressed While _IsPressed("01", $UserDLL) $aMouse_Pos = MouseGetPos() ; Set in correct order if required If $aMouse_Pos[0] < $iX1 Then $iX_Pos = $aMouse_Pos[0] $iWidth = $iX1 - $aMouse_Pos[0] Else $iX_Pos = $iX1 $iWidth = $aMouse_Pos[0] - $iX1 EndIf If $aMouse_Pos[1] < $iY1 Then $iY_Pos = $aMouse_Pos[1] $iHeight = $iY1 - $aMouse_Pos[1] Else $iY_Pos = $iY1 $iHeight = $aMouse_Pos[1] - $iY1 EndIf _GUICreateInvRect($hRectangle_GUI, $iX_Pos, $iY_Pos, $iWidth, $iHeight) Sleep(10) WEnd ; Get second mouse position $iX2 = $aMouse_Pos[0] $iY2 = $aMouse_Pos[1] ; Set in correct order if required If $iX2 < $iX1 Then $iTemp = $iX1 $iX1 = $iX2 $iX2 = $iTemp EndIf If $iY2 < $iY1 Then $iTemp = $iY1 $iY1 = $iY2 $iY2 = $iTemp EndIf GUIDelete($hRectangle_GUI) DllClose($UserDLL) EndFunc ;==>Mark_Rect Func _GUICreateInvRect($hWnd, $iX, $iY, $iW, $iH) $hMask_1 = _WinAPI_CreateRectRgn(0, 0, @DesktopWidth, $iY) $hMask_2 = _WinAPI_CreateRectRgn(0, 0, $iX, @DesktopHeight) $hMask_3 = _WinAPI_CreateRectRgn($iX + $iW, 0, @DesktopWidth, @DesktopHeight) $hMask_4 = _WinAPI_CreateRectRgn(0, $iY + $iH, @DesktopWidth, @DesktopHeight) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_2, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_3, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_4, 2) _WinAPI_DeleteObject($hMask_2) _WinAPI_DeleteObject($hMask_3) _WinAPI_DeleteObject($hMask_4) _WinAPI_SetWindowRgn($hWnd, $hMask_1, 1) EndFunc Func _GDIPlus_ScaleImage($hImage, $iW, $iH, $iInterpolationMode = 7) ;coded by UEZ 2012 Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) If @error Then Return SetError(3, 0, 0) $hBitmap = $hBitmap[6] Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode) _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 If IsHWnd($iCtrlId) Then If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0) Else $iCtrlId = GUICtrlGetHandle($iCtrlId) If Not $iCtrlId Then Return SetError(2,0,0) EndIf ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE) If @error Then Return SetError(3, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(4, 0, 0) Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap) If @error Then Return SetError(5, 0, 0) If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc
-
I'm trying to displaya picture on a gui but it doesn't work if I make some GDI+ operations just before creating the gui: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> #include <StaticConstants.au3> Local $GUIimg_title,$GUIwidth,$GUIheight,$GUILeft,$GUITop Local $filename = FileOpenDialog("Select image", @ScriptDir, "Image (*.jpg;*.bmp)", 3) _GDIPlus_Startup() Local $imagefromfile = _GDIPlus_ImageLoadFromFile($filename) ;Create an image object based on a file Local $GUIwidth = _GDIPlus_ImageGetWidth($imagefromfile) Local $GUIheight = _GDIPlus_ImageGetHeight($imagefromfile) ; Display image $hBitmap_GUI = GUICreate("", $GUIwidth, $GUIheight) $hPic = GUICtrlCreatePic($filename, 0, 0) GUISetState() _GDIPlus_Shutdown() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE;, $hCancel_Button Exit ;~ EndSwitch WEnd Instead it works if I remove GDI+ ... Can't understand why! #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> #include <StaticConstants.au3> Local $GUIimg_title,$GUIwidth,$GUIheight,$GUILeft,$GUITop Local $filename = FileOpenDialog("Select image", @ScriptDir, "Image (*.jpg;*.bmp)", 3) ;~ _GDIPlus_Startup() ;~ Local $imagefromfile = _GDIPlus_ImageLoadFromFile($filename) ;Create an image object based on a file ;~ Local $GUIwidth = _GDIPlus_ImageGetWidth($imagefromfile) ;~ Local $GUIheight = _GDIPlus_ImageGetHeight($imagefromfile) ;~ _GDIPlus_Shutdown() ; Display image ;$hBitmap_GUI = GUICreate("", $GUIwidth, $GUIheight) $hBitmap_GUI = GUICreate("", 800, 800); <---- had to use fixed size... $hPic = GUICtrlCreatePic($filename, 1, 1) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE;, $hCancel_Button Exit ;~ EndSwitch WEnd Any hints?
- 2 replies
-
- guictrlcreatepic
- gdi+
-
(and 1 more)
Tagged with:
-
Sorry I can't get it working on win7 x64...
-
Thanks! It looks useful.
-
Thanks for sharing this!
-
Load a picture, resize, show in a gui and store in SQLite
Zoldex replied to Zoldex's topic in AutoIt General Help and Support
I'm delighted. Really. I wouldn't abuse of your time, but I would love to let the user choose an (rectangular) area of the selected picture to crop, but I really don't have idea where to begin... -
Load a picture, resize, show in a gui and store in SQLite
Zoldex replied to Zoldex's topic in AutoIt General Help and Support
GREAT! That shows my knowledge level about GDI+ and WinAPI: near ZERO Thanks to you guys now I can: Resize the image (by UEZ) Global $hBitmap = _GDIPlus_ScaleImage($filename, $x, $y) Update the pic control (by UEZ / Andy) Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($GUIImage, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) Convert the image in binary to store in SQLite (by UEZ) Global $bImage = _GDIPlus_SaveImage2Binary($hBitmap) Now I miss a way to convert the image back from binary to update the pic control after fetching DB How could I do? -
Load a picture, resize, show in a gui and store in SQLite
Zoldex replied to Zoldex's topic in AutoIt General Help and Support
I do prefer to store images in DB because there will be a relatively small number of records (Max 1000) and need a single .db file. So I need to retrieve the image from DB, eventually resize it, and show in the pic control Anyways, still I can't display the image in the pic control... What am I wrong in? #include <SQLite.au3> #include <SQLite.dll.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Memory.au3> Global Const $IMAGE_BITMAP = 0 ; Needed for GUICtrlSendMsg. Global Const $STM_SETIMAGE = 0x0172 ; Needed for GUICtrlSendMsg. Local $hGUI, $hBMP, $hBitmap, $hGraphic Local $hQuery, $item Local $filename Local $x = 100, $y = 100 _SQLite_Startup() _SQLite_Open() ; open Database in Memory If @error Then MsgBox(16, "SQLite Error", "Can't Load Database!") Exit -1 EndIf _SQLite_Exec(-1, "CREATE TABLE IF NOT EXISTS DBTest (IMAGE BLOB);") $hGUI = GUICreate("GUI", 400, 300) $GUIImage = GUICtrlCreatePic("", 40, 40, $x, $y, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE, $SS_SUNKEN, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) ;$button1 = GUICtrlCreateButton("1",10,10) ;$button2 = GUICtrlCreateButton("2",50,10) ;GUISetState() GUISetState(@SW_SHOW) Local $filename = FileOpenDialog("Select image", @ScriptDir, "Image (*.jpg;*.bmp)", 3) _GDIPlus_Startup() Global $hBitmap = _GDIPlus_ScaleImage($filename, $x, $y) Global $bImage = _GDIPlus_SaveImage2Binary($hBitmap) MsgBox(0, "Binary", $bImage) _WinAPI_DeleteObject(GUICtrlSendMsg($GUIImage, $STM_SETIMAGE, $IMAGE_BITMAP, $bImage)) ; Does not seems to work ;_WinAPI_DeleteObject(GUICtrlSendMsg($GUIImage, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) ; Also tried this with no luck _GDIPlus_Shutdown() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd _SQLite_Close() _SQLite_Shutdown() Exit Func _GDIPlus_SaveImage2Binary($hBitmap, $iQuality = 50) ;coded by Andreik, modified by UEZ Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Local $pEncoder = DllStructGetPtr($tGUID) Local $tParams = _GDIPlus_ParamInit (1) Local $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100 Local $pData = DllStructGetPtr($tData) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Local $pParams = DllStructGetPtr($tParams) Local $hStream = DllCall("ole32.dll", "uint", "CreateStreamOnHGlobal", "ptr", 0, "bool", True, "ptr*", 0) ;http://msdn.microsoft.com/en-us/library/ms864401.aspx $hStream = $hStream[3] DllCall($ghGDIPDll, "uint", "GdipSaveImageToStream", "ptr", $hBitmap, "ptr", $hStream, "ptr", $pEncoder, "ptr", $pParams) _GDIPlus_BitmapDispose($hBitmap) Local $hMemory = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $hStream, "ptr*", 0) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx $hMemory = $hMemory[2] Local $iMemSize = _MemGlobalSize($hMemory) Local $pMem = _MemGlobalLock($hMemory) $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data;ptr") Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473(v=vs.85).aspx _MemGlobalFree($hMemory) Return $bData EndFunc Func _GDIPlus_ScaleImage($sFile, $iW, $iH, $iInterpolationMode = 7) ;coded by UEZ 2012 If Not FileExists($sFile) Then Return SetError(1, 0, 0) Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) If @error Then Return SetError(2, 0, 0) Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) If @error Then Return SetError(3, 0, 0) $hBitmap = $hBitmap[6] Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode) _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc -
As the title says, I'm trying to show a thumbnail in a gui, selected by the user, which must be resized to fit the Gui Control and store the image itself in SQLite as a blob. Thanks to some useful examples found on the forum, I managed to load, show and store an image but I'm experiencing some problems in resizing the picture. This is what i made until now: #include <SQLite.au3> #include <SQLite.dll.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $hGUI, $hBMP, $hBitmap, $hGraphic Local $hQuery, $item Local $filename Local $x = 100, $y = 100 _SQLite_Startup() _SQLite_Open() ; open Database in Memory If @error Then MsgBox(16, "SQLite Error", "Can't Load Database!") Exit -1 EndIf _SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS DBTest (IMAGE BLOB);") $hGUI = GUICreate("GUI", 400, 300) $GUIImage = GUICtrlCreatePic("", 10, 10, $x, $y, BitOR($GUI_SS_DEFAULT_PIC,$SS_CENTERIMAGE,$SS_SUNKEN,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) GUISetState() GUISetState(@SW_SHOW) Local $filename = FileOpenDialog("Select image",@ScriptDir,"Image (*.jpg;*.bmp)",3) ; I could show the image in the gui here: ; GUICtrlSetImage($GUIImage,$ImageFileName) ; But I want to resize it, store it in a DB, then show the resized image in the GUI ; This is what I am trying to do for resize (taken from an example made by UEZ): _GDIPlus_Startup() Local $hImageFromFile = _GDIPlus_ImageLoadFromFile($filename) Local $Thumbnail = DllCall($ghGDIPDll, "uint", "GdipGetImageThumbnail", "handle", $hImageFromFile, "uint", $x, "uint", $y, "int*", 0, "ptr", 0, "ptr", 0) $Thumbnail = $Thumbnail[4] $object_bitmap = _GDIPlus_BitmapCreateFromHBITMAP($Thumbnail); Create a Bitmap object from a bitmap handle (?) _GDIPlus_Shutdown() ;********** How could I show the resized pic in the GUI? Dunno :( ***** ;preparing resized image for storing in SQLite Local $binary_bitmap = Binary($object_bitmap) Local $encoded_bitmap = _SQLite_FastEncode($binary_bitmap) ;insert the blob If Not _SQLite_Exec(-1, "SELECT IMAGE FROM DBTest") = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) If Not _SQLite_Exec(-1, "INSERT INTO DBTest (IMAGE) VALUES (" & $encoded_bitmap & ");") = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) ;Retrieve from database If Not _SQLite_Query(-1, "SELECT * FROM DBTest;", $hQuery) = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) If Not _SQLite_FetchData($hQuery, $item, False, False) = $SQLITE_OK Then MsgBox(16, "SQLite Error", _SQLite_ErrMsg()) Local $retrieve_pic = $item[0] ;NOW *I THINK* I SHOULD HAVE THE RESIZED PICTURE IN $retrieve_pic BUT I CAN'T SHOW IT IN THE GUI..... ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd _SQLite_Close() _SQLite_Shutdown() Exit I'm not very good at GDI coding and quite a newbie with SQLite, too... Any help would be very appreciated!
-
AutoIt Windows Screenshooter v1.84 Build 2019-08-18
Zoldex replied to UEZ's topic in AutoIt Example Scripts
Download link is dead! Please repost. It seems really a great & useful job!- 129 replies
-
- screencapture
- gdi+
-
(and 3 more)
Tagged with:
-
_GUICtrlListView_Create inside a TabItem is it possible?
Zoldex replied to Gianni's topic in AutoIt General Help and Support
GREAT! That's what I was looking for! Anyways, it looks that listview borders are missing ! I've tried with _GUICtrlListView_SetExtendedListViewStyle() without luck... -
SQLite and Listview problem. Help needed!
Zoldex replied to Zoldex's topic in AutoIt GUI Help and Support
NiVZ, thanks for your answer. If I understand what you say, I should read again the whole table from database to update listview, each time I delete a record? That's what I thought when I had the problem but don't know what would happen with very large databases. I mean that it would become a slow process if I need to delete several rows... My KEY value is not displayed on the listview and is used only as a progressive counter, that would serve me to identify the row in the database. Anyways, even if not displayed on listview, when I delete the row from the database it's really gone forever and creates a "hole" in the counter. The listview, instead, updates itself all the index rows... I would need a way to tell SQLite to "reorganize" the rows when a KEY in the middle is missing... like Listview does. -
Hi everybody! I'm trying to use SQLite for the first time into an app with a listview. I've already succesful managed to create a database, insert and update items, also on the listview! My problem is about deleting records. I mean i can easily delete a record from a database with _SQLite_Exec(-1, "DELETE FROM Database WHERE KEY = " & $selected_row_on_listview & ";") and also from listview with _GUICtrlListView_DeleteItemsSelected($listview) but the difference is that if I have 5 records into the Database and I delete 1 in the middle (say KEY=3) I will have KEY values 0,1,2,4 BUT Listview updates its rows 0,1,2,3 so I couldn't use $selected_row_on_listview anymore, since if I click on row 3 it would try to delete a missing record. Sorry if my question sounds silly but I'm really stuck now. Thanks for any hints and forgive my poor english. Also, any good example with SQLite and listview would be greatly appreciated.
-
Another thing, but it could be my mistake, should be the syntax: Syntax: _Insert_Update_Delete($sAction,$sData,$sWhere,$Table_Name='Database') ...but in the example you've written ; Inserting into column id,parameters the value 1 and Hello If $_Just_Created Then _Insert_Update_Delete(0, 'id,parameters', "'1','Hello'") id,parameters looks like a $sWhere and 1,Hello looks as $sData I'm a bit confused about that
- 21 replies
-
- database udf sq sqlite
- udf
-
(and 3 more)
Tagged with: