How to use enumChildProc method in fMBT

Best Python code snippet using fMBT_python

human.py

Source:human.py Github

copy

Full Screen

1#!/​usr/​bin/​env python2# Copyright (C) 2010-2013 Cuckoo Sandbox Developers.3# This file is part of Cuckoo Sandbox - http:/​/​www.cuckoosandbox.org4# See the file 'docs/​LICENSE' for copying permission.5import random6import logging7from threading import Thread8from ctypes import *9from lib.common.abstracts import Auxiliary10from lib.common.defines import KERNEL32, USER32, WM_GETTEXT, WM_GETTEXTLENGTH, BM_CLICK11log = logging.getLogger(__name__)12EnumWindowsProc = WINFUNCTYPE(c_bool, POINTER(c_int), POINTER(c_int))13EnumChildProc = WINFUNCTYPE(c_bool, POINTER(c_int), POINTER(c_int))14RESOLUTION = {15 "x" : USER32.GetSystemMetrics(0),16 "y" : USER32.GetSystemMetrics(1)17}18def foreach_child(hwnd, lparam):19 buttons = [20 "&yes",21 "&ok",22 "&accept",23 "&next",24 "&install",25 "&run",26 "&agree"27 ]28 classname = create_unicode_buffer(50)29 USER32.GetClassNameW(hwnd, classname, 50)30 # Check if the class of the child is button.31 if classname.value == "Button":32 # Get the text of the button.33 length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)34 text = create_unicode_buffer(length + 1)35 USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)36 # Check if the button is "positive".37 for button in buttons:38 if text.value.lower().startswith(button):39 log.info("Found button \"%s\", clicking it" % text.value)40 USER32.SetForegroundWindow(hwnd)41 KERNEL32.Sleep(1000)42 USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)43# Callback procedure invoked for every enumerated window.44def foreach_window(hwnd, lparam):45 # If the window is visible, enumerate its child objects, looking46 # for buttons.47 if USER32.IsWindowVisible(hwnd):48 USER32.EnumChildWindows(hwnd, EnumChildProc(foreach_child), 0)49def move_mouse():50 x = random.randint(0, RESOLUTION["x"])51 y = random.randint(0, RESOLUTION["y"])52 USER32.mouse_event(1, x, y, 0, None)53def click_mouse():54 # mouse down55 USER32.mouse_event(2, 0, 0, 0, None)56 KERNEL32.Sleep(50)57 # mouse up58 USER32.mouse_event(4, 0, 0, 0, None)59class Human(Auxiliary, Thread):60 """Human after all"""61 def __init__(self):62 Thread.__init__(self)63 self.do_run = True64 def stop(self):65 self.do_run = False66 def run(self):67 while self.do_run:68 move_mouse()69 click_mouse()70 USER32.EnumWindows(EnumWindowsProc(foreach_window), 0)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

[LambdaTest Spartans Panel Discussion]: What Changed For Testing & QA Community And What Lies Ahead

The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.

How to Recognize and Hire Top QA / DevOps Engineers

With the rising demand for new services and technologies in the IT, manufacturing, healthcare, and financial sector, QA/ DevOps engineering has become the most important part of software companies. Below is a list of some characteristics to look for when interviewing a potential candidate.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

How To Get Started With Cypress Debugging

One of the most important tasks of a software developer is not just writing code fast; it is the ability to find what causes errors and bugs whenever you encounter one and the ability to solve them quickly.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful