Skip to content

Commit 4f7d87a

Browse files
Add files via upload
Controlling The Computer With Some Parameters
1 parent 08de6fe commit 4f7d87a

File tree

1 file changed

+293
-0
lines changed

1 file changed

+293
-0
lines changed

Machine Mastermind.ipynb

+293
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "351144d9",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"Requirement already satisfied: pyautogui in c:\\users\\student\\anaconda3\\lib\\site-packages (0.9.53)\n",
14+
"Requirement already satisfied: mouseinfo in c:\\users\\student\\anaconda3\\lib\\site-packages (from pyautogui) (0.1.3)\n",
15+
"Requirement already satisfied: PyTweening>=1.0.1 in c:\\users\\student\\anaconda3\\lib\\site-packages (from pyautogui) (1.0.3)\n",
16+
"Requirement already satisfied: pygetwindow>=0.0.5 in c:\\users\\student\\anaconda3\\lib\\site-packages (from pyautogui) (0.0.9)\n",
17+
"Requirement already satisfied: pymsgbox in c:\\users\\student\\anaconda3\\lib\\site-packages (from pyautogui) (1.0.9)\n",
18+
"Requirement already satisfied: pyscreeze>=0.1.21 in c:\\users\\student\\anaconda3\\lib\\site-packages (from pyautogui) (0.1.27)\n",
19+
"Requirement already satisfied: pyrect in c:\\users\\student\\anaconda3\\lib\\site-packages (from pygetwindow>=0.0.5->pyautogui) (0.1.4)\n",
20+
"Requirement already satisfied: Pillow>=6.2.1 in c:\\users\\student\\anaconda3\\lib\\site-packages (from pyscreeze>=0.1.21->pyautogui) (8.2.0)\n",
21+
"Requirement already satisfied: pyperclip in c:\\users\\student\\anaconda3\\lib\\site-packages (from mouseinfo->pyautogui) (1.8.2)\n"
22+
]
23+
}
24+
],
25+
"source": [
26+
"!pip install pyautogui "
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 49,
32+
"id": "fa1699bf",
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"import pyautogui as mousePosition\n",
37+
"\n",
38+
"# Time to wait for the computer to process\n",
39+
"mousePosition.sleep(2)\n",
40+
"\n",
41+
"# Move the mouse\n",
42+
"mousePosition.moveTo(x=27, y=749)\n",
43+
"\n",
44+
"# Click the Start button (Windows button)\n",
45+
"mousePosition.click(x=27, y=749)\n",
46+
"\n",
47+
"# Time to wait for the computer to process\n",
48+
"mousePosition.sleep(4)\n",
49+
"\n",
50+
"# Move the mouse\n",
51+
"mousePosition.moveTo(x=159, y=366)\n",
52+
"\n",
53+
"# Click the calculator button to open it\n",
54+
"mousePosition.click(x=159, y=366)\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": 50,
60+
"id": "577f2708",
61+
"metadata": {},
62+
"outputs": [],
63+
"source": [
64+
"import pyautogui as openGooglePosition\n",
65+
"\n",
66+
"# Time to wait for the computer to process\n",
67+
"openGooglePosition.sleep(4)\n",
68+
"\n",
69+
"# Double-click the Start button (Windows button)\n",
70+
"openGooglePosition.doubleClick(x=111, y=39)\n",
71+
"\n",
72+
"# Time to wait for the computer to process\n",
73+
"openGooglePosition.sleep(6)\n",
74+
"\n",
75+
"# Type the Google website\n",
76+
"openGooglePosition.typewrite('https://www.google.com/')\n",
77+
"\n",
78+
"# Time to wait for the computer to process\n",
79+
"openGooglePosition.sleep(3)\n",
80+
"\n",
81+
"# Press the Enter key\n",
82+
"openGooglePosition.press('enter')\n",
83+
"\n",
84+
"# Time to wait for the computer to process\n",
85+
"openGooglePosition.sleep(7)\n",
86+
"\n",
87+
"# Type the search term 'Dollar today'\n",
88+
"openGooglePosition.typewrite('Dollar today')\n",
89+
"\n",
90+
"# Time to wait for the computer to process\n",
91+
"openGooglePosition.sleep(3)\n",
92+
"\n",
93+
"# Press the Enter key\n",
94+
"openGooglePosition.press('enter')\n"
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": 51,
100+
"id": "b0f6dc94",
101+
"metadata": {},
102+
"outputs": [],
103+
"source": [
104+
"import pyautogui as openFilesPosition\n",
105+
"\n",
106+
"# The hotkey method allows us to execute multiple keyboard shortcuts\n",
107+
"# This is the same as pressing Windows + R\n",
108+
"openFilesPosition.hotkey('win', 'r')\n",
109+
"\n",
110+
"# Time to wait for the computer to process\n",
111+
"openFilesPosition.sleep(2)\n",
112+
"\n",
113+
"# Type 'Notepad'\n",
114+
"openFilesPosition.typewrite('notepad')\n",
115+
"\n",
116+
"# Time to wait for the computer to process\n",
117+
"openFilesPosition.sleep(2)\n",
118+
"\n",
119+
"# Press the Enter key\n",
120+
"openFilesPosition.press('enter')\n",
121+
"\n",
122+
"# Time to wait for the computer to process\n",
123+
"openFilesPosition.sleep(3)\n",
124+
"\n",
125+
"# Type a message in Notepad\n",
126+
"openFilesPosition.typewrite('We opened Notepad with a robot or script')\n",
127+
"\n",
128+
"# Time to wait for the computer to process\n",
129+
"openFilesPosition.sleep(2)\n",
130+
"\n",
131+
"# Get the active window\n",
132+
"closeNotepadWindow = openFilesPosition.getActiveWindow()\n",
133+
"\n",
134+
"# Time to wait for the computer to process\n",
135+
"openFilesPosition.sleep(2)\n",
136+
"\n",
137+
"# Close the active window\n",
138+
"closeNotepadWindow.close()\n",
139+
"\n",
140+
"# Time to wait for the computer to process\n",
141+
"openFilesPosition.sleep(2)\n",
142+
"\n",
143+
"# Press the TAB key\n",
144+
"openFilesPosition.press('tab')\n",
145+
"\n",
146+
"# Time to wait for the computer to process\n",
147+
"openFilesPosition.sleep(2)\n",
148+
"\n",
149+
"# Press the Enter key\n",
150+
"openFilesPosition.press('enter')"
151+
]
152+
},
153+
{
154+
"cell_type": "code",
155+
"execution_count": 54,
156+
"id": "95b818de",
157+
"metadata": {},
158+
"outputs": [],
159+
"source": [
160+
"import pyautogui\n",
161+
"import pyautogui as chooseOption\n",
162+
"\n",
163+
"option = pyautogui.confirm('Click the desired button', buttons = ['Excel', 'Word', 'Notepad'])\n",
164+
"\n",
165+
"if option == 'Excel':\n",
166+
" \n",
167+
" # The hotkey method allows us to execute multiple keyboard shortcuts\n",
168+
" # This is the same as pressing Windows + R\n",
169+
" chooseOption.hotkey('win', 'r')\n",
170+
" \n",
171+
" # Time to wait for the computer to process\n",
172+
" chooseOption.sleep(2)\n",
173+
" \n",
174+
" # Type 'Excel'\n",
175+
" chooseOption.typewrite('Excel')\n",
176+
" \n",
177+
" # Time to wait for the computer to process\n",
178+
" chooseOption.sleep(2)\n",
179+
" \n",
180+
" # Press the Enter key\n",
181+
" chooseOption.press('Enter')\n",
182+
" \n",
183+
" # Time to wait for the computer to process\n",
184+
" chooseOption.sleep(4)\n",
185+
" \n",
186+
" # Click the option to open a blank Excel workbook\n",
187+
" chooseOption.click(x=600, y=241)\n",
188+
" \n",
189+
" # Time to wait for the computer to process\n",
190+
" chooseOption.sleep(3)\n",
191+
" \n",
192+
" chooseOption.typewrite('I chose to open Excel')\n",
193+
" \n",
194+
"elif option == 'Word':\n",
195+
" \n",
196+
" # The hotkey method allows us to execute multiple keyboard shortcuts\n",
197+
" # This is the same as pressing Windows + R\n",
198+
" chooseOption.hotkey('win', 'r')\n",
199+
" \n",
200+
" # Time to wait for the computer to process\n",
201+
" chooseOption.sleep(2)\n",
202+
" \n",
203+
" # Type 'winword'\n",
204+
" chooseOption.typewrite('winword')\n",
205+
" \n",
206+
" # Time to wait for the computer to process\n",
207+
" chooseOption.sleep(2)\n",
208+
" \n",
209+
" # Press the Enter key\n",
210+
" chooseOption.press('Enter')\n",
211+
" \n",
212+
" # Time to wait for the computer to process\n",
213+
" chooseOption.sleep(6)\n",
214+
" \n",
215+
" # Click the option to open a blank Word document\n",
216+
" chooseOption.click(x=447, y=334)\n",
217+
" \n",
218+
" # Time to wait for the computer to process\n",
219+
" chooseOption.sleep(5)\n",
220+
" \n",
221+
" chooseOption.typewrite('I chose to open Word')\n",
222+
" \n",
223+
"elif option == 'Notepad':\n",
224+
" \n",
225+
" # The hotkey method allows us to execute multiple keyboard shortcuts\n",
226+
" # This is the same as pressing Windows + R\n",
227+
" chooseOption.hotkey('win', 'r')\n",
228+
" \n",
229+
" # Time to wait for the computer to process\n",
230+
" chooseOption.sleep(2)\n",
231+
" \n",
232+
" # Type 'Notepad'\n",
233+
" chooseOption.typewrite('Notepad')\n",
234+
" \n",
235+
" # Time to wait for the computer to process\n",
236+
" chooseOption.sleep(2)\n",
237+
" \n",
238+
" # Press the Enter key\n",
239+
" chooseOption.press('Enter')\n",
240+
" \n",
241+
" # Time to wait for the computer to process\n",
242+
" chooseOption.sleep(4)\n",
243+
" \n",
244+
" chooseOption.typewrite('I chose to open Notepad')\n"
245+
]
246+
},
247+
{
248+
"cell_type": "code",
249+
"execution_count": null,
250+
"id": "0929a512",
251+
"metadata": {},
252+
"outputs": [],
253+
"source": []
254+
},
255+
{
256+
"cell_type": "code",
257+
"execution_count": null,
258+
"id": "1379b854",
259+
"metadata": {},
260+
"outputs": [],
261+
"source": []
262+
},
263+
{
264+
"cell_type": "code",
265+
"execution_count": null,
266+
"id": "6e59b5d5",
267+
"metadata": {},
268+
"outputs": [],
269+
"source": []
270+
}
271+
],
272+
"metadata": {
273+
"kernelspec": {
274+
"display_name": "Python 3",
275+
"language": "python",
276+
"name": "python3"
277+
},
278+
"language_info": {
279+
"codemirror_mode": {
280+
"name": "ipython",
281+
"version": 3
282+
},
283+
"file_extension": ".py",
284+
"mimetype": "text/x-python",
285+
"name": "python",
286+
"nbconvert_exporter": "python",
287+
"pygments_lexer": "ipython3",
288+
"version": "3.8.8"
289+
}
290+
},
291+
"nbformat": 4,
292+
"nbformat_minor": 5
293+
}

0 commit comments

Comments
 (0)