Path: blob/main/tools/neteditTestFunctions/general/contextualMenu.py
169678 views
# -*- coding: utf-8 -*-1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file contextualMenu.py14# @author Pablo Alvarez Lopez15# @date 28-05-251617# imports18import time19import pyautogui20from ..constants import DELAY_MOUSE_MOVE, DELAY_KEY_TAB21from ..input.keyboard import typeKey222324def contextualMenuOperation(referencePosition, position, contextualMenuOperation,25offsetX=0, offsetY=0):26# obtain clicked position27clickedPosition = [referencePosition[0] + position.x + offsetX,28referencePosition[1] + position.y + offsetY]29# move mouse to position30pyautogui.moveTo(clickedPosition)31# wait after move32time.sleep(DELAY_MOUSE_MOVE)33# click over position34pyautogui.click(button='right')35# place cursor over first operation36for _ in range(contextualMenuOperation.mainMenuPosition):37# wait before every down38time.sleep(DELAY_KEY_TAB)39# type down keys40pyautogui.hotkey('down')41# type space for select42typeKey('space')43# check if go to submenu A44if contextualMenuOperation.subMenuAPosition > 0:45# place cursor over second operation46for _ in range(contextualMenuOperation.subMenuAPosition):47# wait before every down48time.sleep(DELAY_KEY_TAB)49# type down keys50pyautogui.hotkey('down')51# type space for select52typeKey('space')53# check if go to submenu B54if contextualMenuOperation.subMenuBPosition > 0:55# place cursor over second operation56for _ in range(contextualMenuOperation.subMenuBPosition):57# wait before every down58time.sleep(DELAY_KEY_TAB)59# type down keys60pyautogui.hotkey('down')61# type space for select62typeKey('space')636465