from pywinauto.application import Application
app = Application().Start(cmd_line=u'"path to program" ')
afx = app[u'Afx:01360000:0']
afx.Wait('ready')
afxtoolbar = afx[u'1']
toolbar_button = afxtoolbar.Button(3)
toolbar_button.Click()
window = app.Dialog
window.Wait('ready')
edit = window.Edit4
edit.Click()
app.typekeys ("Success")
So at this point, I've gotten the application to open, the correct window to pop up and also a mouse click on the box that I want to populate with a short string. I cannot for the life of me, figure out how to pass keyboard input to this field. I have read all the docs for PyWinAuto, and nothing is helping...
Basically all I need to do is figure out how to send a string, and then how to send the TAB key six times. I can then finish my program to automate this application.
I am also using Swapy64bit to help. The program uses a win32 backend. I'm using Python 3.6.
Am I not prefixing typekeys correctly? The PyWinAuto documentation leaves much to be desired.
First the correct name of the method is type_keys, but assume you use it correctly.
The reason might be losing focus at the edit control because type_keys tries to set focus automatically. The solution is:
app.type_keys("Success{TAB 6}", set_foreground=True)
Related
Soo, How can I have text display after an input()?
I'll explain with an example:
import os
docname = input(f"Where do you wanna save your document? {os.path.dirname(os.path.realpath(__file__))\\images\\")
As user is typing, the .pdf extension is after what they typed (am not native English)
Where do you wanna save your document? C:\Users\Public\Downloads\project\(here user can type).pdf
(I don't worry about the extention; docname = docname + ".pdf"
I saw this question, but that doesnt answer my question (This isn't a duplicate of that, because that doesnt appear as I type). Here's how far i've came:
text = f"File destination: {os.path.dirname(os.path.realpath(__file__))}\\images\\"
while True:
answer = input(text)
fileExtension = ".pdf"
while not answer:
pass
# print(f"\33[1A\33[{len(fileExtension)}C {fileExtension}")
# print("\033[A\033[A")
else:
break
The main problems are that:
This doesnt run lol
I can't (or don't know how to) identify the length of characters as user is typing. Also, I dunno if I would need it, but it's probably needed to determine if it has to print(f"\33[1A\33[{len(input)}]C)
The while loop doesn't appear as the input is running. If I would do more research, I maybe will figure out how to run 2 lines at the same time, but then there's gonna be a way more simple answer.
Even if I had all of these together, would it run at all? Or is the cursor jumping left and right without any possible input
I'm currently trying to develop an Anki addon that changes the note type of a card when in the card browser.
To accomplish this, I'm initially hooking into the editor shortcuts via aqt.gui_hooks.editor_did_init_shortcuts.append(), then adding a shortcut that sends a callback to another function, passing in aqt.editor.Editor into a function
the problem is I'm now having a hard time changing the note type of the card.
I've tried editor.note.note_type = mw.col.models.by_name(note_type), but it doesn't seem to change anything.
I've looked at other anki extensions, but it seems they change the note_type by modifying the notetype_chooser.selected_note_type_id field of aqt.addcards, which is not found in aqt.editor.Editor
here's the code I have so far:
def editor_switch_note_card_type(editor: aqt.editor.Editor, note_type: str):
# doesn't do anything
editor.note.note_type = mw.col.models.by_name(note_type)
# does something
editor.note['Front'] += 'hello world'
# not sure if this does anything
mw.col.update_note(editor.note)
# editor_init_shortcuts binds editor_switch_note_card_type to a shortcut key when editor is focused
aqt.gui_hooks.editor_did_init_shortcuts.append(editor_init_shortcuts)
In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
You've set a rather tall order for TI-Basic to fill. user3932000 is correct; there is no built in function to create an input form of the type you request.
However, there is nothing stopping you from creating an interactive interface yourself. Creating it from scratch will be a time consuming and, it will consume a significant amount of memory on your calculator. There is no boilerplate code you plug your variables into to get the results you want, but you might have some luck modeling it after this quadratic solver I wrote.
ClrHome
a+bi
Output(1,1," QUADRATIC
Output(2,1," AX²+BX+C
Output(3,1,"ZEROS:
Output(6,1,"A=
Output(7,1,"B=
Output(8,1,"C=
DelVar YDelVar D
" →Str1
While Y≠105
getKey→Y
If Ans
Then
Output(X,4,Str1
Output(3,7,Str1+Str1+Str1+"
End
X+(Ans=34)-(Ans=25
If Ans<6:8
If Ans>8:6
Ans→X
Output(Ans,16,"◄
D(Y≠45→D
If Y=25 or Y=34
sum({A,B,C}(X={6,7,8→D
If Y=104:⁻D→D
10not(Y)+Y(102≠Y)-13int(Y/13(2>abs(5-abs(5-abs(Y-83
If Ans≤9
D10+Ans-2Ans(D<0→D
If X=6:D→A
If X=7:D→B
If X=8:D→C
If A
Then
2ˉ¹Aˉ¹(⁻B+{1,⁻1}√(B²-4AC
Else
If B
Then
⁻C/B
Else
If C
Then
"No Zeros
Else
"All Numbers
End
End
End
Output(3,7,Ans
Output(6,3,A
Output(7,3,B
Output(8,3,C
End
ClrHome
Ans
Here's a GIF of what it does for you.
With a little more work. This code could be used on the Graph screen instead of the home screen, giving more option in terms of layout and design.
In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
There are many ways to ask for input in your program:
Prompt: Asks for input and stores it in a variable. For example, Prompt A. Simplest way to ask for input, but not very visually appealing.
Input: Similar to the Prompt command, except that now you can include text within the input. For example, Input "What is your name?",A.
Menu(: Multiple choice input, and each choice is connected to a Lbl marker somewhere else in the script. Much like the error screen with the quit/goto choices that you've probably seen. For example, Menu("Are you a boy or a girl?","Boy",B,"Girl",G).
getKey: Checks if a certain key is pressed, and will output True (1) if that key is pressed. For example, getKey 105. See here for which numbers each key corresponds to.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function http://imgur.com/ulthDRV
I'm afraid that's not possible in programs. You can either put in multiple inputs, or you might be interested in looking into making apps instead.
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
If you're talking about the text on top of the screenshot, yes you can; just put a Disp command or something after each line of Input, so that it continuously overwrites the text above with new text after you input a variable.
In RPGLE I'm try to get the SFLSCROLL from a DSPF with multiple formats displaying. I used a read of the SFLCTL to get the SFLSCROLL but the screen is waiting for a response.
How can get it to return to the program without the wait?
You can't.
From the manual: 'You use this field-level keyword in the subfile-control record format to return the relative record number of the subfile record that is at the top of the subfile when control is given back to your program.'
You could use WAITRCD() on CRTDSPF to cause a timeout, but you still need to wait for the timeout to expire.
Thank You I did see that solution but here it was a an order issue on the display.
There is a detail screen on the top of the screen then a subfile on the bottom.
(do not ask why the detail was not in the subfile control I think they had planned for multiple details in the header area)
They were doing a write of the sflctl then exfmt for the detail.
That was not giving me the SFLRRN to check new prompt in the subfile.
I changed it to do a write of the detail exfmt of the sflctl read of detail and that got all the data for me to process with them only hitting enter once after the display occurred so I could check the prompt in the subflctl:
C write dtl2
C exfmt sflctl1
C read dtl2
This feels like it should be pretty easy but I can't find documentation on how to do this:
I just want Sikuli to type Ctrl+C to copy text to the clipboard.
type(KEY_CTRL+'c') doesn't work and neither does type(KEY_CTRL,'c').
Any suggestions?
Try using type("c",KEY_CTRL) instead.
I wrote a simple script which types a line in notepad, double clicks it to mark it and then ctrl+x ctrl+v it into the document again. Works great.
openApp("notepad.exe")
find("textfield.png" )
type("Some text")
doubleClick("theText.png")
type("x", KEY_CTRL)
click("theTextField.png" )
type("v",KEY_CTRL)
The following works in 0.9 and newer versions of sikuli
type('x', KeyModifier.CTRL)
Key objects are defined for pretty much all the modifier keys and num pad keys. Anyways, it should look something like this
keyDown(Key.CTRL)
type('c')
keyUp(Key.CTRL)
The usage of type() and the possible key names are documented here:
http://doc.sikuli.org/region.html#Region.type
http://doc.sikuli.org/keys.html#key-constants
As others have mentioned, use the following:
type('c', Key.CTRL) # Copy command
One point worth mentioning - do not use upper-case characters, i.e.:
type('C', Key.CTRL) # Does not copy, avoid this
I haven't looked into the Sikuli source code, but my best guess is that it implicitly sends this as Shift+C, which results in a different command entirely.
type('x', Key.CTRL) also works.
Also, make sure that NUM_LOCK is off. If NUM_LOCK is on, it can make anything with KeyModifier.CTRL or KeyModifier.SHIFT misbehave.
You can try next code:
keyDown(Key.CTRL)
type("c")
keyUp(Key.CTRL)
I had a requirement to automate a flash content. The following code worked for me.
These were the following steps I ahd to perform as a part of the automation:
Enter Username and Password
Click on Login Button
Click on the button which will navigate to the application
The challenge I faced was to focus on the Username and password which had no placeholders . Hence the focusing was difficult. So I used the CTRL keys to do this .
Pattern appLogo = new Pattern("C:\\images\\appLogo.png");
StringSelection userNameText = new StringSelection("username");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(userNameText, null);//Copy the text into the memory
Screen s = new Screen();
s.find(appLogo);
s.click(appLogo);
s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
s.type(Key.TAB);
s.type("V",KeyModifier.CTRL);
StringSelection password = new StringSelection("password");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(password, null);
s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
s.type("V",KeyModifier.CTRL);
Pattern loginButton = new Pattern("C:\\images\\Login.png");
s.find(loginButton);
s.doubleClick(loginButton);
The scenario is like i need to press say key E in my keyboard after finishing the test how to add this in the script in Sikuli IDE.