gps – Is it possible to track the location only during a small predefined time window?

I am looking for a way for an Android phone to record (preferably locally on the device) its GPS position (accuracy of 10 to 20 m) with a fairly high frequency (eg every 30 minutes or every 30 minutes) seconds), but ONLY during predefined periods. , for example weekdays from 19:30 to 20:00 and from 13:15 to 13:45. The rest of the time, I want nothing done and I do not use any resources.

Multiple Window – Split Screen – The split screen option no longer works. How can I make it work?

First my device information
Android version: 8.1.0
Manufacturer of the device: Alco
Model of the apparatus: RCT6A03W13

When I started using the device, I was able to use the split screen mode. Now, from one minute to the next, it was no longer working. I've been trying to long press the button for the recent application but nothing is happening. When I go to the overview screen, I do not see this little button on every open application that would allow me to select it to set the split screen mode.

Here is a picture of my overview screen
Image of the summary screen

macos – How to iterate elements of the window with a dynamic title

I'm trying to get all the lines of an application table.

set ProcName to "AppName"
tell application ProcName to activate
tell application "System Events"
    tell process ProcName
        tell tab group 1 of window 1
            set items to every row of table 1 of scroll area 1
            set itemValues to {}
            repeat with aRow in items
                set itemValue to (value of text field 1 of aRow)
                log itemValue
                set the end of itemValues to itemValue
            end repeat
        end tell

    end tell
end tell

However, when I run the script, it prints only several items because the window title changes constantly and the following error message is displayed.

 "System Events got an error: Can’t get window "App name window title"

Is it possible to tell the script to use other identifiers than title?
Or please suggest how to solve the problem.

Thank you.

kde – How to get active window control to show settings / menu bar?

I can not find the setting that allows the File menu to display in the active window control when a window is set to full screen.

I already have BorderlessMaximizedWindows=true In my KDE configuration file, I'm now trying to make the File menu appear in the top pane instead of the currently open window. Thank you!

enter the description of the image here

Applescript – How can I select all files of a type in an application window other than the Finder?

The Applescript script below examines the open search window before, finds the file type of a selected file, and then highlights all files of that type of file. In other words, if a search window contains a mix of .jpg, .png, and .webp files, the script searches for the selected file (for example, a .jpg file), and then selects all .jpg files. .

try
    tell application "Finder" to set the source_folder ¬
        to (folder of the front window) as alias
on error -- no open folder windows
    --set the source_folder to path to desktop folder as alias
    --problem is a window can be open but out of focus
    beep
end try

tell application "Finder"
    set selectionList to {} & selection as list
    set selectedCount to count items in selectionList

    if selectedCount > 0 then
        set nameExtension to name extension of item 1 in selectionList
        select (every item where name extension ¬
            is nameExtension) of (folder source_folder)
    end if
end tell

How could I change that for it to work with an application such as FTP Client Transmit? Transmit is aware of AppleScript and appears in the Applescript dictionary.

Of course, simply change tell application "Finder" at tell application "Transmit" does not work because source_folder returns an error because it looks for a search window and not an application window.

c ++ – Urho3D SDL_GetWindowWMInfo and Invalid window descriptor (help) How to correct getting HWND from SDL2

I'm using Urho3D which uses SDL2 as the window system. I want to create another window as a GUI and make it a child of the main Urho3D window.

What I did was:

// insde virtual void Start() // Urho3D app
SDL_Window * sdlw = context->GetSubsystem()->GetWindow();
int width = context->GetSubsystem()->GetWidth();
int height = context->GetSubsystem()->GetHeight();
HWND mw = SDLWindows::GetWindowHWND(sdlw);
wpfC = WPFI::CreateWPFControl(0, 0, width, height);
HWND www = SetParent(wpfC, mw); // SetParent is windows function
if (www == NULL)
{
    std::cout << "------------------------------n"
        << "www = NULLn"
        << GetLastError() << "n"
        << "------------------------------n";
}

HWND SDLWindows::GetWindowHWND(SDL_Window * wnd)
{
    SDL_SysWMinfo sysInfo;
    SDL_VERSION(&sysInfo.version);
    SDL_GetWindowWMInfo(wnd, &sysInfo);
    return sysInfo.info.win.window;
}

I had Invalid window handle (1400) Error on SetParent ().

I'm not sure I'm doing it right, but I'm sure my wpfC is ok because I have another test project where it works but instead, SDL Window uses win32 window.

I think SDL_GetWindowWMInfo () gives me a bad ID.

The question is how to get HWND correctly from SDL_Window and make sure it's HWND?

If this is not possible, is there another way to create a child window from HWND in the main SDL2 window?

directx – Resize the window in D3D12

I'm trying to implement the resize function of the d3d12 window. First of all, I delete all the buffers referenced by SwapChain, then I launch SwapChain :: ResizeBuffers. At this point, I get the error:

D3D12 ERROR: ID3D12Resource1::: CORRUPTION: An ID3D12Resource object (0x000002323B7029A0:'Unnamed Object') is referenced by GPU operations in-flight on Command Queue (0x000002323B6BFD00:'Command queue'). It is not safe to final-release objects that may have GPU operations pending. This can result in application instability. ( EXECUTION ERROR #921: OBJECT_DELETED_WHILE_STILL_IN_USE)
Exception thrown at 0x00007FF89004A839 (KernelBase.dll) in dx12_buffers_learn.exe: 0x0000087D (parameters: 0x0000000000000000, 0x000000712E99AE80, 0x0000023238E800D0).
Unhandled exception at 0x00007FF89004A839 (KernelBase.dll) in dx12_buffers_learn.exe: 0xC000041D: 

Here is the code of the procedure to change the size of the window:

bool resize(int w, int h)
{
    if (device && swapChain && commandAllocator(frameIndex))
    {
        WaitForPreviousFrame();
        if (FAILED(commandAllocator(frameIndex)->Reset())) return false;
        if (FAILED(commandList->Reset(commandAllocator(frameIndex).Get(), nullptr))) return false;
        for (int i(0); i < frameBufferCount; i++)
            renderTargets(i).Reset();
        if (FAILED(swapChain->ResizeBuffers(frameBufferCount, w, h, backBufferFormat, NULL))) return false;
        frameIndex = 0;
        if (!createBackBuffer()) return false;
        createViewport();
        createScissor();
        if (FAILED(commandList->Close())) return false;
        vector cmdsLists = { commandList.Get() };
        commandQueue->ExecuteCommandLists(cmdsLists.size(), cmdsLists.data());
    }
    return true;
}

I've put together a self-sufficient example to model the problem described above:

#include 
#include 
#include 
#include "d3dx12.h"
#include 
#include 
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d12.lib")
using namespace std;
using Microsoft::WRL::ComPtr;

void updateSize();
bool InitializeWindow(HINSTANCE hInstance);
bool resize(int w, int h);
void mainloop();
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
bool InitD3D();
void UpdatePipeline();
void Render();
void WaitForPreviousFrame();
bool createBackBuffer();
void createViewport();
void createScissor();

HWND hwnd = nullptr;
int widthClient = 900;
int heightClient = 650;
int startWidth;
int startHeight;
int widthWindow;
int heightWindow;
int frameBufferCount = 3;
ComPtr dxgiFactory;
DXGI_FORMAT backBufferFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
ComPtr < ID3D12Device> device;
ComPtr swapChain;
ComPtr < ID3D12CommandQueue> commandQueue;
ComPtr < ID3D12DescriptorHeap> rtvDescriptorHeap;
vector< ComPtr> renderTargets;
vector< ComPtr> commandAllocator;
ComPtr < ID3D12GraphicsCommandList> commandList;
vector< ComPtr> fence;
HANDLE fenceEvent = nullptr;
vector fenceValue;
int frameIndex = 0;
int rtvDescriptorSize = -1;
D3D12_VIEWPORT viewport;
D3D12_RECT scissorRect;
bool vsync = false;
float color() = { 0.53f, 0.53f, 0.53f, 1.f };

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    if (!InitializeWindow(hInstance)) return -1;
    if (!InitD3D()) return -1;
    mainloop();
    WaitForPreviousFrame();
    return 0;
}

void updateSize()
{
    RECT windowRect;
    GetClientRect(hwnd, &windowRect);
    widthClient = windowRect.right;
    heightClient = windowRect.bottom;
    startWidth = windowRect.left;
    startHeight = windowRect.top;
    GetWindowRect(hwnd, &windowRect);
    widthWindow = windowRect.right - windowRect.left;
    heightWindow = windowRect.bottom - windowRect.top;
}

bool InitializeWindow(HINSTANCE hInstance)
{
    WNDCLASSEX wc;
    ZeroMemory(&wc, sizeof(wc));
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WndProc;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
    wc.lpszClassName = L"dx12_className";
    wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    if (!RegisterClassEx(&wc)) return false;
    if(!(hwnd = CreateWindowEx(NULL, L"dx12_className", L"DX12 Render Triangles", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, widthClient, heightClient, NULL, NULL, hInstance, NULL))) return false;
    updateSize();
    ShowWindow(hwnd, SW_SHOW);
    UpdateWindow(hwnd);
    return true;
}

void mainloop()
{
    MSG msg = {};
    while (true)
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
                break;
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
            Render();
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_DESTROY: // x button on top right corner of window was pressed
        PostQuitMessage(0);
        return 0;
    case WM_SIZE:
        updateSize();
        if (!resize(widthWindow, heightWindow))
        {
            DestroyWindow(hwnd);
            return 0;
        }
        break;
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}

bool InitD3D()
{
    // init
    renderTargets.resize(frameBufferCount);
    commandAllocator.resize(frameBufferCount);
    fence.resize(frameBufferCount);
    fenceValue = { 0,0,0 };
    // debug
    ComPtr debugController;
    if (FAILED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) return false;
    debugController->EnableDebugLayer();
    // dxgi factory
    if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(dxgiFactory.GetAddressOf())))) return false;
    // device
    if (FAILED(D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(device.GetAddressOf())))) return false;
    // queue
    D3D12_COMMAND_QUEUE_DESC cqDesc = {};
    cqDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
    cqDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; 
    if (FAILED(device->CreateCommandQueue(&cqDesc, IID_PPV_ARGS(commandQueue.GetAddressOf())))) return false;
    commandQueue->SetName(L"Command queue");
    // swap chain
    DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
    swapChainDesc.Format = backBufferFormat;
    swapChainDesc.Stereo = FALSE;
    swapChainDesc.SampleDesc.Count = 1;
    swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    swapChainDesc.BufferCount = frameBufferCount;
    swapChainDesc.Scaling = DXGI_SCALING_NONE;
    swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
    swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
    ComPtr tempSwapChain;
    if (FAILED(dxgiFactory->CreateSwapChainForHwnd(commandQueue.Get(), hwnd, &swapChainDesc, nullptr, nullptr, tempSwapChain.GetAddressOf()))) return false;
    if(!(swapChain = static_cast(tempSwapChain.Get()))) return false;
    frameIndex = swapChain->GetCurrentBackBufferIndex();
    DXGI_RGBA swapChainBkColor = { color(0), color(1), color(2), color(3) };
    if (FAILED(swapChain->SetBackgroundColor(&swapChainBkColor))) return false;
    // back buffers
    if (!createBackBuffer()) return false;
    // viewport
    createViewport();
    // scissor
    createScissor();
    // allocators
    for (int i = 0; i < frameBufferCount; i++)
        if (FAILED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(commandAllocator(i).GetAddressOf())))) return false;
    // list
    if (FAILED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator(frameIndex).Get(), NULL, IID_PPV_ARGS(commandList.GetAddressOf())))) return false;
    // fence
    for (int i = 0; i < frameBufferCount; i++)
        if (FAILED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(fence(i).GetAddressOf())))) return false;
    if(!(fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr))) return false;
    // closed list
    commandList->Close();
    vector cmdsLists = { commandList.Get() };
    commandQueue->ExecuteCommandLists(cmdsLists.size(), cmdsLists.data());
    return true;
}

bool resize(int w, int h)
{
    if (device && swapChain && commandAllocator(frameIndex))
    {
        WaitForPreviousFrame();
        if (FAILED(commandAllocator(frameIndex)->Reset())) return false;
        if (FAILED(commandList->Reset(commandAllocator(frameIndex).Get(), nullptr))) return false;
        for (int i(0); i < frameBufferCount; i++)
            renderTargets(i).Reset();
        if (FAILED(swapChain->ResizeBuffers(frameBufferCount, w, h, backBufferFormat, NULL))) return false;
        frameIndex = 0;
        if (!createBackBuffer()) return false;
        createViewport();
        createScissor();
        if (FAILED(commandList->Close())) return false;
        vector cmdsLists = { commandList.Get() };
        commandQueue->ExecuteCommandLists(cmdsLists.size(), cmdsLists.data());
    }
    return true;
}

void UpdatePipeline()
{
    WaitForPreviousFrame();
    commandAllocator(frameIndex)->Reset();
    commandList->Reset(commandAllocator(frameIndex).Get(), nullptr);
    commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(renderTargets(frameIndex).Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));
    CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(rtvDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), frameIndex, rtvDescriptorSize);
    commandList->ClearRenderTargetView(rtvHandle, color, 0, nullptr);
    commandList->RSSetViewports(1, &viewport); 
    commandList->RSSetScissorRects(1, &scissorRect); 
    commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(renderTargets(frameIndex).Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
    commandList->Close();
}

void Render()
{
    UpdatePipeline();
    vector ppCommandLists = { commandList.Get() };
    commandQueue->ExecuteCommandLists(ppCommandLists.size(), ppCommandLists.data());
    commandQueue->Signal(fence(frameIndex).Get(), fenceValue(frameIndex));
    swapChain->Present(vsync ? 1 : 0, 0);
}

void WaitForPreviousFrame()
{
    frameIndex = swapChain->GetCurrentBackBufferIndex();
    if (fence(frameIndex)->GetCompletedValue() < fenceValue(frameIndex))
    {
        fence(frameIndex)->SetEventOnCompletion(fenceValue(frameIndex), fenceEvent);
        WaitForSingleObject(fenceEvent, INFINITE);
    }
    fenceValue(frameIndex)++;
}

bool createBackBuffer()
{
    D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {};
    rtvHeapDesc.NumDescriptors = frameBufferCount;
    rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
    rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
    if (FAILED(device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(rtvDescriptorHeap.GetAddressOf()))))
        return false;
    rtvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
    CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(rtvDescriptorHeap->GetCPUDescriptorHandleForHeapStart());
    for (int i = 0; i < frameBufferCount; i++)
    {
        if (FAILED(swapChain->GetBuffer(i, IID_PPV_ARGS(renderTargets(i).GetAddressOf()))))
            return false;
        device->CreateRenderTargetView(renderTargets(i).Get(), nullptr, rtvHandle);
        rtvHandle.Offset(1, rtvDescriptorSize);
    }
    return true;
}

void createViewport()
{
    viewport.TopLeftX = 0;
    viewport.TopLeftY = 0;
    viewport.Width = widthClient;
    viewport.Height = heightClient;
    viewport.MinDepth = 0.0f;
    viewport.MaxDepth = 1.0f;
}

void createScissor()
{
    scissorRect.left = 0;
    scissorRect.top = 0;
    scissorRect.right = widthClient;
    scissorRect.bottom = heightClient;
}

Tell me how to solve this problem

jquery – Multiple HTML5 audio players with playlist. Will play the first playlist but a new window will open when reading the second list

var audio;
var playlist;
var tracks;
var current;

init();

function init() {
  current = 0;
  audio = $('audio');
  playlist = $('#playlist');
  tracks = playlist.find('li a');
  len = tracks.length - 1;
  audio(0).volume = 1;
  
  playlist.find('a').click(function(e) {
    e.preventDefault();
    link = $(this);
    current = link.parent().index();
    run(link, audio(0));
  });
  
  audio(0).addEventListener('ended', function(e) {
    if ($(audio).hasClass("repeat")) {
      current++;
      if (current > len) {
        current = 0;
        link = playlist.find('a')(0);
      } else {
        link = playlist.find('a')(current);
      }
      run($(link), audio(0));
    } else if ($(audio).hasClass("repeat-trk")) {
      current++;
      if (current == len) {
        current = 0;
        link = playlist.find('a')(0);
      } else {
        link = playlist.find('a')(current);
      }
      run($(link), audio(0));
    } else {
      current++;
      if (current < len) {
        current = 0;
        link = playlist.find('a')(0);
      } else {
        link = playlist.find('a')(current);
      }
      run($(link), audio(0));
    }
  });
}

function run(link, player) {
  player.src = link.attr('href');
  par = link.parent();
  par.addClass('active').siblings().removeClass('active');
  audio(0).load();
  audio(0).play();
}


python – How to get the coordinates of the window cv2.imshow?

I use this code

import numpy as np
import cv2
from PIL import ImageGrab as ig
import time

last_time = time.time()
while(True):
    screen = ig.grab(bbox=(200, 200, 600, 600))
    print('Loop took {} seconds'.format(time.time()-last_time))
    cv2.imshow("test", np.array(screen))
    last_time = time.time()
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

this question about SO.
This is my exit:

exit

That works well. I'm looking for a solution to capture the area just below the exit window. When I move the window, the output also changes. One way would be to update this line as follows:

screen = ig.grab(bbox=(x1, y2, x2, y2))

but the thing I can not understand is how to get these parameter values. Or how to get the coordinates of the exit window?

P. I do not have enough reputation to directly embed images here, so I added the external link.

spotlight – macos does not switch to active space when the current window is in full screen

I use most of my applications in full screen, which creates individual spaces.

The problem is that the application / current space does not change focus when I try to open another application.

Example:

  1. I'm downloading a file on the chrome browser. I click on "open in the viewfinder" to open the searcher. The Finder opens in the background, but the macOS does not change the window / active space on the desktop where the Finder is open.

  2. Open an application via Alfred or under the spotlight does not bring the new aperture to the front, if I'm on the application in full screen.

NOTES:

  • All of this (placing the application in the foreground) works when I'm NOT in full screen, that is, in the workspace.
  • I mainly work in a dual display configuration
  • Here is my mission control setting <img src = "https://i.stack.imgur.com/LGztx.png" alt = "mission control setting"/>