I am currently working with one application that requires to press Numpad Enter (Keycode 13 Location: 3) in specific situations. Regular Enter (Keycode 13 Location 0) does not work.
I have tried to use:
Global Send Keys: with {ENTER}
Global Send Keys Event: with {ENTER}, ~, {RETURN}
VB code stage with
My.Computer.Keyboard.SendKeys("{ENTER}", True)
They all seems to Press KeyCode 13 Location 0. And I need to press Keycode 13 Location 3 specifically.
Does anyone have an idea how to create in BluePrism functionality to press KeyCode 13 location 3 button?
Allright I managed to solve it!
Thanks to: https://www.ibm.com/support/knowledgecenter/en/SSEQ5Y_5.9.0/com.ibm.pcomm.doc/books/html/host_access08.htm
Dim autECLPSObj As Object
autECLPSObj = CreateObject("PCOMM.autECLPS")
autECLPSObj.SetConnectionByName ("A")
autECLPSObj.SendKeys ("[enter]")
Basically for PCOMM there is a list of mnemonic keys, you can send with this method.
Fun part is, there no need for any PCOMM dll. The only thing you need is a namespace: Microsoft.VisualBasic.Interaction
It works without any issue and you can use all of the other autECLPS type of object!
Related
I am simulating the button press using keyboard module.
I have following code:
keyboard.press('num lock')# switching on the num lock key
##do some operation##
keyboard.press('num lock')# num lock key is still On
On second statement num lock key is not pressed down.
Please help me to get it resolved.
I have tried with pyautogui,still its not resolved.
pyautogui.press("num lock")
Thanks
Simun
The string you need to pass is 'numlock', not 'num lock':
>>> pyautogui.press("numlock")
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)
I want to map windows/super keyboard key in my xboxdrv config but KEY_SUPER or KEY_WINDOWS doesn't work. what is the EV_KEY name of the "super" key? (I mean key with windows logo on many keyboards)
Either KEY_LEFTMETA or KEY_RIGHTMETA.
You can find it out using evtest, for example:
$ evtest /dev/input/event1
Once you press the button you are looking for, you should see something like this:
Event: time 1477389229.423141, type 1 (EV_KEY), code 126 (KEY_RIGHTMETA), value 1
I have a problem, that is similar to a lot of other's before me, but different in a way that makes it much more difficult. :)
I'm writing a text editor for the Linux console. There is no X11 running, so forget about any toolkit for that. I want to capture key down and key-up events as I want to be able to mark sections of text by holding down shift and using the arrow keys (much like you would in an X-based or Windows-based editor).
I've previously managed to write an application that uses raw mode to access key scancodes, but it is unable to handle detecting shift key and arrow keys at the same time.
Does anyone have an example code that is able to detect any key combinations (or at least all combinations with shift, ctrl and alt).
How about using ncurses, which does all that for you? It also helps you with figuring out how to format text for the particular terminal type you're connected with and so on.
Using the getkey() function the python binding provide, I am able to find out modifiers for different keys. I also found out that for Shift+Arrow keys, there is a separate key code, abbreviated with KEY_SR, KEY_SF for up and down and KEY_SLEFT and KEY_SRIGHT.
import curses
import curses.textpad
import curses.ascii
def decodeSuffix(i):
return {
0b110: ( True, True, False),
0b100: ( True, False, True),
0b111: (False, True, True),
0b101: (False, True, False),
0b011: (False, False, True),
}[i]
def test(stdscr):
while True:
k = stdscr.getkey()
if k == "\n":
return
elif k[0] == "k" and len(k) > 1:
i = int(k[-1])
shift, ctrl, alt = decodeSuffix(i)
s = ""
if shift:
s += "shift "
if ctrl:
s += "ctrl "
if alt:
s += "alt "
s += k[1:-1]
stdscr.addstr("{0:40s} {1:08b}\n".format(s, i))
else:
stdscr.addstr("{0}\n".format(k))
pass
curses.wrapper(test)
You may play around with that. Looking at the source of getkey(), we find that it's basically a combination of getch and keyname curses functions.
I have sort of managed to do what I set out to do. The only problem is it requires that I connect directly to the keyboard driver. Right now I do not know how to do that without root privileges, so my editor requires root. This could be awkward.
In short, I open the /dev/input/event? stream, where ? is the number of the keyboard driver (most often 0) and capture the key-presses from there. This is really only useful for checking the state of a key (by building a key-state from the down and up-press events) since the events are delivered from all applications (this is after all the keyboard driver).
It is better to get all other key-presses from a more conventional source and just use the keyboard driver for CTRL, SHIFT and so on.
I'll post code later if I get it to work together. :)
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.