Here's my script:
import pyautogui
import subprocess
import time
#notepad is in the file path
programma = "Notepad"
#opening notepad
subprocess.Popen(programma)
#gives time to open notepad, ie I've also tried with higher numbers
time.sleep(1)
pyautogui.keyDown('NumLock')
#I've also tried with
pyautogui.hotkey('alt', 'num3')
I've tried and the Numpad works: if I comment the take out 'alt' and just write
pyautogui.press('num3')
it types the number 3.
Although if I put alt in the code, it gives an error, as if I were typing without having the cursor set.
I've also tried
pyautogui.keyDown('alt')
pyautogui.keyDown('num3')
pyautogui.keyUp('num3')
pyautogui.keyUp('alt')
Does anyone know what to do?
Thanks in advance
Working for me:
pyautogui.keyDown('alt')
pyautogui.press("num3")
pyautogui.keyUp('alt')
If you try to .keyDown('num3') pyautogui will think you want to use a third key in your combination.
Related
coin = input("coin: ")
pyautogui.click(button='right')
pyautogui.press('enter')
print(coin)
after the input came out, pyautogui cant run the next line which is right click to paste the code in terminal. Is there any other solution to paste my code and save it in a var?
First of all, you would be better of using the shortcut "ctrl + v" to paste it, like so:
pyautogui.hotkey('ctrl', 'v')
However if your end goal is too get what is in your clipboard into a variable you could use this:
import win32clipboard
def getclipdata():
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
return data
To use the function do this whenever you want the clipboard data in a variable:
clipdata = getclipdata()
I hope this helped, feel free to ask me any questions.
Python 3, functions.
There is the following exercise:
In this exercise, we will write code that allows us to
download an image from the web! We will use an external module and understand how to read the documentation of the functions and use them.
We want to write a function that accepts a photo Url and
downloads the photo to your computer.
You can choose any picture you want from the Internet by clicking the right button and selecting "Copy Image Url”.
the image I chose:
https://images.theconversation.com/files/377569/original/file-20210107-17-q20ja9.jpg?ixlib=rb-1.1.0&rect=278%2C340%2C4644%2C3098&q=45&auto=format&w=926&fit=clip
the wanted name:
"4.jpg"
the given instructions:
Write code that selects a random number between 1 and 1000. The number will be the file name (search how to select a random number in python).
The image name has to have the right suffix, so concat“.png" to the end of the number you selected (You can also use .jpg, .bmp, etc).
For example: if the selected number was 2T0, you should have a variable that holds the string: “270.png”.
Import module urllib.request: https://docs.python.org/3/library/urllib.request.html#module-urllib.request
Read "how to use the urlretrieve function":
http://shecodesconnect.com/shecodes_python_blog/urlretrieve_en.php?lang=%27en%27
Use the function you read about in order to
download the image and save it under the name
you prepared.
Run the code you wrote and check the folder where your code is saved if the image was downloaded!
my code that doesn't work:
import urllib.request
local_filename, headers = urllib.request.urlretrieve(https://images.theconversation.com/files/377569/original/file-20210107-17-q20ja9.jpg?ixlib=rb-1.1.0&rect=278%2C340%2C4644%2C3098&q=45&auto=format&w=926&fit=clip)
html = open(local_filename)
html.close()
headers.items()
headers["content-type"]
image_url="https://images.theconversation.com/files/377569/original/file-20210107-17-q20ja9.jpg?ixlib=rb-1.1.0&rect=278%2C340%2C4644%2C3098&q=45&auto=format&w=926&fit=clip.jpg"urllib.request.urlretrieve(url=image_url, filename="4.jpg")
import random()
a=random.randint(1,1000)
print(4)
Hope you could help, my code doesn't work, thank you in advance!
After fixing the errors, looks like you end up with the below:
import urllib.request
local_filename, headers = urllib.request.urlretrieve('https://images.theconversation.com/files/377569/original/file-20210107-17-q20ja9.jpg?ixlib=rb-1.1.0&rect=278%2C340%2C4644%2C3098&q=45&auto=format&w=926&fit=clip')
html = open(local_filename)
html.close()
headers.items()
headers["content-type"]
image_url="https://images.theconversation.com/files/377569/original/file-20210107-17-q20ja9.jpg?ixlib=rb-1.1.0&rect=278%2C340%2C4644%2C3098&q=45&auto=format&w=926&fit=clip.jpg"
urllib.request.urlretrieve(url=image_url, filename="4.jpg")
import random
a=random.randint(1,1000)
print(4)
Assuming the code in the question is what were you were able to come up with, that is.
Im new to python and wondering if there is a way for it to open a webpage depending on whats been inputted. EG
Market=input("market")
ticker=input("Ticket")
would take you to this part of the website.
https://www.tradingview.com/symbols/'market'-'ticker'/technicals
Thanks
Looks like you were pretty much there, but it python you can use the + sign to concatenate strings and then cause it to open that link using webbrowser library
import webbrowser
market=input("market")
ticker=input("Ticket")
webbrowser.open('https://www.tradingview.com/symbols/'+market+'-'+ticker+'/technicals')
Its cleaner to use format string like this:
import webbrowser
market=input("market")
ticker=input("Ticket")
webbrowser.open(f'https://www.tradingview.com/symbols/{market}-{ticker}/technicals')
Like mentioned on this post, I would like to just import a skin weightmap (a .weightMap file) into a scene without having to open a dialogue box. Trying to reverse - engineer the script mentioned in the reply didn't get me anywhere.
When I do it manually thru maya's ui - the script history shows...
ImportSkinWeightMaps;
...as a command. But my searches on this keep leading me to the deformerWeights command.
Thing is, there is no example on the documentation as to how to correctly write the syntax. Writing the flags, the path thru trial and error with it didn't work out, plus additional searches keep giving me the hint that I need to use a .xml file for some reason? when all I want to do is import a .weightMap file.
I even ended up looking at weight importer scripts in highend3d.com in hopes at looking at what a proper importing syntax should look like.
All I need is the correct syntax (or command) for something like:
mel.eval("ImportSkinWeightMaps;")
or
cmds.deformerWeights (p = "path to my .weightMap file", im=True, )
or
from pymel.core import *
pymel.core.runtime.ImportSkinWeightMaps ( 'targetOject', 'path to .weightMap file' )
Any help would be greatly appreciated.
Thanks!
why not using some cmds.skinPercent ?
It is more reliable.
http://tech-artists.org/forum/showthread.php?5490-Faster-way-to-find-number-of-influences-Maya&p=27598#post27598
I want to be able to grab the File description string from the details tab on a .dll or a .sys file. I've tried to do this in a number of methods, but can't get them to click. Is there anyway to do this through the command line to get it to produce an output to the screen. I've had no joy with FileVersion.description that is available using VB.
Any direction or help would be much appreciated here.
Thanks
langs = win32api.GetFileVersionInfo(ExecutablePath, r'\VarFileInfo\Translation')
key = r'StringFileInfo\%04x%04x\FileDescription' %(langs[0][0], langs[0][1])
print (win32api.GetFileVersionInfo(ExecutablePath, key))
As a starting point it looks like some of this stuff can be retrieved using win32api. You can find documentation here, and of course using python's built-in help().
I edited to add some code to show how some of the information can be retrieved. I've used win32api as well as os.stat Hope this is enough to get you started. Shouldn't be too hard to find the rest of it with what I've given so far.
import os
import time
import stat
from win32api import GetFullPathName
def get_details(file_name):
time_format = "%m/%d/%Y %I:%M:%S %p"
file_stats = os.stat(file_name)
return {
'folder_path': GetFullPathName(file_name),
'size': file_stats[stat.ST_SIZE],
'date_modified':time.strftime(time_format,time.localtime(file_stats[stat.ST_MTIME])),
'access_time': time.strftime(time_format,time.localtime(file_stats[stat.ST_ATIME])),
}
print get_details("myfilename")