In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use Python to develop game running scripts to achieve simulation clicks, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
First, the selection of Android simulator
At present, there are many Android simulators on the market, such as Night God Simulator, Lightning Simulator, Tencent Mobile Game Assistant, and NetEase's Wood Simulator. These simulators have their own advantages and disadvantages in terms of the compatibility of mobile games and the support of plug-ins in the desert. You can make your own decisions according to the specific mobile games.
Here I choose the Night God simulator, of course, it is no problem to choose other ones, because the principle is the same. After selecting the simulator, download and install it. After the installation is successful, open the Night God Simulator, and you will see the main page of the Night God Simulator. Here I have modified the resolution of the Night God Simulator to [640,360 / dpi = 240].
Second, use the desert plug-in to bind specific windows
For Windows systems, everything you can see on the desktop is actually one Windows window after another, and the Android simulator is no exception. According to the API documentation, the first step to simulate mouse clicks and keyboard buttons is to call the API of the Desert plug-in to bind specific windows. Some API of the Desert plug-in is used in the process (for specific API introduction, please check the API document of the Desert plug-in). The following is the code for window binding:
Import win32com.client# create desert instance object def createDMInstance (): dm = win32com.client.Dispatch ('dm.dmsoft') # call desert plug-in to get desert object print ("desert plug-in version number:" + dm.ver ()) # output version number return dm# search window Return the found window handle def findWindow (dm, windowClass, windowTitle): windowHandle = dm.FindWindow (windowClass, windowTitle) print ("found window handle =" + str (windowHandle)) # output window handle ID return windowHandle# bind window def bindWindow (dm, windowHandle): isBindSuccess = dm.BindWindow (windowHandle, "normal", "normal", "normal" 0) print ("bind successfully =" + str (isBindSuccess)) # whether bind successfully return isBindSuccess # whether bind successfully if _ _ name__ = ='_ main__': dm = createDMInstance () windowHandle = findWindow (dm, "," Night God Simulator ") isBindSuccess = bindWindow (dm, windowHandle)
Call the API [FindWindow] of the Desert plugin to find the window handle of the Night God simulator and output the number of the window handle.
Call API [BindWindow] of the Desert plug-in to bind the found window handle and output the binding result
Third, carry out mouse simulation
After successfully binding the window, we can do whatever we want to the window, that is, the Night God simulator!
Here, call the API [Moveto (x, y)] of the Desert plug-in to move the mouse to a specific coordinate point (the entire coordinate system is based on the upper left corner of the Android simulator and expand downward to the right), and then call [LeftClick ()], which successfully realizes the simulation click.
You can see the moment when python runs, the mouse moves to the location of Xero136MagneyPhone161, and triggers the click to open the application, so we initially realize the function of mouse simulation click.
The above is all the contents of the article "how to use Python to develop game running scripts to achieve simulation clicks". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.