Jump to content

Turan Can

Members
  • Content Count

    63
  • Joined

  • Last visited

Posts posted by Turan Can


  1. Mouse, Detection of mouse click
    I need a sample code to post mosu as x, y.
    Important: I want to click outside the form globally, not on the form.

    So even if the form is running in the background, I want to click on a point I want.

     

    function MousePos: TPointF;
    var
    MouseService: IFMXMouseService;
    begin
    if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService, IInterface(MouseService)) then
    Exit(MouseService.GetMousePos);
    Result := PointF(0, 0);
    end;


  2. Hi All,

    Does anyone know the equivalent of these 2 features in android?

    I want to click on the X, Y coordinates I sent.

     

    Windows vcl;

    I've been using these on windows with no problems.

    SetCursorPos

    Mouse_Event

     

    Android ??

    event: JMotionEvent;


    Form1.MouseMove([], Mouse.Left, Mouse.Top); 

     

     


  3. I realized that no one is developing with video or audio features in Delphi android.
    Display, sound, keyboard, socket etc. features are priority concepts.
    I converted it from java to delphi with great effort, but I couldn't even find an answer to it. It's a very sad scene.

     

    Android Screenshot not working on new phones >= 10 - Cross-platform - Delphi-PRAXiS [en] (delphipraxis.net)

    :classic_wacko::classic_wacko::classic_wacko::classic_wacko:


  4. You have to design it yourself, 

     

    On click form properties...

    BorderStyle : bsNone

     

    OnPaint

    procedure TForm1.FormPaint(Sender: TObject);
    begin
      OnBasePaint(ClientWidth, ClientHeight, Canvas);
    end;

     

    procedure TfmMain1.OnBasePaint(ClientWidth, ClientHeight: Integer; Canvas: TCanvas);
    var
      Rect: TRect;
    begin
      Rect.Left := 0;
      Rect.Top := 0;
      Rect.Bottom := ClientHeight;
      Rect.Right := ClientWidth;
      with Canvas do
      begin
        // Pen.Width := 2;
        // Brush.Color := $00000000;
        // Pen.Color := $006B6B6B;
        // Rectangle(0, 0, ClientWidth, ClientHeight);
      end;
    end;


  5. Hi All,

     

    I was capturing android screenshot but it doesn't work on newer versions.

     

    Return error code;
    Project AndroidTest.apk raised exception class EJNIException with message 'java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION'.

     

    Permission add on: Foreground Service

    I gave the "AndroidManifest" in authorization.

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

     

    Another weird problem is the service I added "AndroidManifest".

    TJManifest_permission.JavaClass... is not in "FOREGROUND_SERVICE" the service, INSTANT_APP_FOREGROUND_SERVICE

     

    Attached is a sample project.

    Delphi 11 build project

     

    function TForm1.OnActivity(RequestCode, ResultCode: integer; Itt: JIntent): Boolean;
    var
      MPro: JMediaProjection;
    begin
      Result := false;
      if RequestCode = REQUEST_CODE_SCREEN_CAPTURE then
      begin
        if ResultCode = TJActivity.JavaClass.RESULT_OK then
        begin

     

    ///Return error code;
    ///Project AndroidTest.apk raised exception class EJNIException with message 'java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION'.


          MPro := FMedia.getMediaProjection(ResultCode, Itt);
          if MPro <> nil then
          begin
            // ...
            Result := true;
            ShowMessage('Ok')
          end;
        end;
      end;
    end;

     

    AndroidTest_Screenshot.zip


  6. Hi All,

     

    When I want to download a page on the website, it downloads a maximum of 4095 bytes. How can I remove this limit?

     

    function TDownloadFile.WebGetData(const UserAgent: string; const Url: string): string;
    var
      hInet: HINTERNET;
      hURL: HINTERNET;
      Buffer: array [0 .. 10] of AnsiChar;
      BufferLen: Cardinal;
      dwTimeOut: DWORD;
    begin
      Result := '';

      hInet := InternetOpen(PChar(UserAgent), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
      if hInet = nil then
        RaiseLastOSError;
      try
    //    dwTimeOut := 2000; // Timeout in milliseconds
    //    InternetSetOption(hInet, INTERNET_OPTION_CONNECT_TIMEOUT, @dwTimeOut, SizeOf(dwTimeOut));

        hURL := InternetOpenUrl(hInet, PChar(Url), nil, 0, INTERNET_FLAG_PRAGMA_NOCACHE or INTERNET_FLAG_NO_CACHE_WRITE or INTERNET_FLAG_RELOAD, 0);
        if hURL = nil then
          RaiseLastOSError;
        try
          repeat
            if not InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen) then
              RaiseLastOSError;
            Result := Result + UTF8Decode(Copy(Buffer, 1, BufferLen))
          until BufferLen = 0;
        finally
          InternetCloseHandle(hURL);
        end;
      finally
        InternetCloseHandle(hInet);
      end;
    end;


  7. Hi All,

     

    FMX Project.

    "TBitmapCodecManager" doesn't support bitmap on Android?

    These are the only ones that come when I enter this "TBitmapCodecManager.SaveToStream(" method.

    POSIX

    jpg, tif, png

     

    WINDOWS

    jpg, tif, png, bmp ...

     

     

    for Descriptor in FBitmapCodecClassDescriptors do

    if (SameText(Extension, Descriptor.Extension, loUserLocale) or SameText('.' + Extension, Descriptor.Extension,  loUserLocale)) and Descriptor.CanSave then

     

    --------------------------------------------------------------------

    uses FMX.Graphics, FMX.Surfaces;

     

    var

      Stream: TMemoryStream;
      Surf: TBitmapSurface;

    begin

                    Stream := TMemoryStream.Create;
                    try
                      Surf := TBitmapSurface.Create;
                      try
                        Surf.Assign(FBmpNew);
                        //TBitmapCodecManager.RegisterBitmapCodecClass('.bmp', 'bmp', True, ......??? 
                        TBitmapCodecManager.SaveToStream(Stream, Surf, '.bmp');
                      finally
                        Surf.Free;
                      end;
                      Stream.Position := 0;
                      Stream.SaveToStream(FStream);
                    finally
                      Stream.Free;
                    end;


  8. Limelect, 

     

    There is no code language issue for me. I am reviewing what you sent.

    Thanks a lot for the information.

    There are several api used in the code you sent, I'll review them.

    • Like 1

  9. In the Java example, it did not capture the entire screen, but took a screenshot of the form it was attached to.
    so it is no different from the sample code I made.

     

    I think I need to take a screenshot with a handle from a plugin or api. but I could not find any examples android.

     

    Delphi, Java, C# xamarin

    I could not find an example of a full screenshot for android in these 3 languages.

     

    1- Java sample

    2- java sample


  10. Hello everyone,

     

    Full screenshot.

    How do I capture the entire screen?

     

    In this example, I can take a screenshot of the open form.

    Sample;

     

    function MakeScaleScreenshot(Sender: TObject): TBitmap;
    var
      fScreenScale: Single;
      function GetScreenScale: Single;
      var
        ScreenService: IFMXScreenService;
      begin
        Result := 1;
        if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenService)) then
        begin
          Result := ScreenService.GetScreenScale;
        end;
      end;

    begin
      fScreenScale := GetScreenScale;
      Result := TBitmap.Create(Round(TfmText1(Sender).Width * fScreenScale), Round(TfmText1(Sender).Height * fScreenScale));
      Result.Clear(0);
      if Result.Canvas.BeginScene then
        try
          TfmText1(Sender).PaintTo(Result.Canvas);
          // Sender.PaintTo( Result.Canvas); //, RectF(0, 0, Result.Width, Result.Height));
        finally
          Result.Canvas.EndScene;
        end;
    end;

     

    procedure TfmText1.btnScreenClick(Sender: TObject);
    var
      B: TBitmap;
    begin

      B := MakeScaleScreenshot(Self);

      // MakeScreenshot(Image1);
      Image1.Bitmap.Assign(B);
      B.DisposeOf;
    end;

     

     

     

    Screenshot_20210128-090432_One UI Home.jpg


  11. Lars,

     

    Thanks for information

    I will investigate a little more. Because I only have problems with renewal refresh explorer icon cache. I hope I will find a method 🙂 

     

    https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-settings-app

    ms-settings:taskbar

    "explorer shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}" 

     

    Shell execute list

    https://winaero.com/blog/clsid-guid-shell-list-windows-10/


  12. Hallo David,

    Ik heb een simpel probleem.

     

    This method you sent has worked.

    https://stackoverflow.com/questions/7877435/set-tray-icon-to-always-show

     

    I added the software to the trayicon section without the need for Windows settings.

    I have to do this for the icon to appear. Turn "Explorer.exe" on / off.
    Opening and closing the "Explorer.exe" file bothers the user.
    How can I renew "Explorer.exe" without closing / opening it?


  13. Hi All,

     

    What to do to reload the tray icon?


    I haven't tried 3 different methods, is there any different idea?
    The icon is inactive because my application started late.


    If I do this, the problem will be fixed. However, this is frustrating at every opening.
    taskkill /f /im explorer.exe
    start explorer.exe

     

    The methods I tried.

     

    ie4uinit.exe -ClearIconCache
    ie4uinit.exe -show


    CD /d %userprofile%\AppData\Local
    DEL IconCache.db /a
    EXIT
     

    https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shchangenotify

     

      SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, 100000, nil);

      SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);

     

     

    https://superuser.com/questions/499078/refresh-icon-cache-without-rebooting

     

    https://github.com/crazy-max/IconsRefresh

     

     

×