Skip to content

Commit

Permalink
The keypress interval is taken as input from the user, a new row is a…
Browse files Browse the repository at this point in the history
…dded, the default value of this keypress interval is 0.5s
  • Loading branch information
khadija1114 committed Dec 10, 2024
1 parent 48d5f77 commit 43685b4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Framework/Built_In_Automation/Desktop/Windows/BuiltInFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2086,13 +2086,25 @@ def _open_inspector(inspector, args):

@logger
def Run_Application(data_set):
"""
size | optional parameter | ** Example: 1920,1080 **
location | optional parameter | ** Example: 0,0 **
maximize | optional parameter | ** yes/no **
relaunch/launch another | optional parameter | ** yes/no **
keypress interval | optional parameter | ** It will by default wait 0.5 sec for the keypress interval. Example: 0.2 **
wait for launch | optional parameter | ** It will by default wait 10 sec for the app to launch. Example: 20 **
open app | windows action | Example:
>> Outlook
>> ~/Desktop/server.exe
"""
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
global current_pid_list
current_pid_list = []
try:
args = {"shell": True, "stdin": None, "stdout": None, "stderr": None}
launch_cond = ""
Desktop_app = ""
keypress_interval = 0.5
size, top_left, maximize = None, None, False
wait = Shared_Resources.Get_Shared_Variables("element_wait")
for left, mid, right in data_set:
Expand All @@ -2117,7 +2129,9 @@ def Run_Application(data_set):
launch_cond = "relaunch"
elif "launchagain" in left and yes_cond:
launch_cond = "launchagain"
elif "wait" == left:
elif "keypressinterval" in left and r != None:
keypress_interval = float(r)
elif left == "wait" or left == "waitforlaunch":
wait = float(r)

if not launch_cond and len(pygetwindow.getWindowsWithTitle(Desktop_app)) > 0:
Expand All @@ -2133,13 +2147,13 @@ def Run_Application(data_set):
cmd = f'''{Desktop_app[:2]} && cd "{os.path.dirname(Desktop_app)}" && start cmd.exe /K "{Desktop_app}\"'''
CommonUtil.ExecLog(sModuleInfo, "Running following cmd:\n" + cmd, 1)
subprocess.Popen(cmd, **args)
# Desktop_app = os.path.basename(Desktop_app)
# Desktop_app = os.path.basename(Desktop_app)Notepad
else:
#last_start_time = time.time()
autoit.send("^{ESC}")
time.sleep(0.5)
time.sleep(keypress_interval)
autoit.send(Desktop_app)
time.sleep(0.5)
time.sleep(keypress_interval)
autoit.send("{ENTER}")
CommonUtil.ExecLog(sModuleInfo, "Successfully launched your app", 1)
time.sleep(2)
Expand Down

0 comments on commit 43685b4

Please sign in to comment.