Here is the code:
import keyboard as key
print("press enter to continue")
while True:
if key.is_pressed("Enter"):
break
answer = input("--> ")
print(answer)
I want to be able to press buttons before i press Enter without any problems. However if i press "abcdefg" for example, and then press Enter, the ouput will be:
press enter to continue
--> abcdefg
abcdefg
I want the output to be:
press enter to continue
-->
so I can type my answer
I have tried some things but I cannot seem to find any solutions on the internet. Please help
Related
Code I found on net for the same is :
driver.findElement(locator).click();
driver.findElement(locator).sendKeys(value);
driver.findElement(locator).sendKeys(Keys.TAB);
But I don't know which value I have to enter and what is Keys in 3rd line
driver.findElement(locator).click();
driver.findElement(locator).sendKeys(value);
driver.findElement(locator).sendKeys(Keys.TAB);
driver.findElement(locator).sendKeys(Keys.ENTER);
You have to enter a value to suggest from text box.
Ex: If you need to suggest your state, you can enter state name first letters.
Then the "key" mean selenium webdriver command. you can specify which key should press.
Ex: Manually you have to enter the value and press down arrow twice and press enter.Like this you can specify the keyboard keys.
I want to send an Alt combination to another window within a on-screen keyboard.
With combination I mean when you hold down Alt and enter a number or hexadecimal(registry key has to be set for hex) combination:
ALT down, Add press, 2 press, 5 press, 1 press, ALT up
I tried
SendKeys.SendWait("%{ADD}251") but it's Alt+Add 2 5 1
SendKeys.SendWait("%{ADD}%2%5%1") but it's Alt+Add Alt+2 Alt+5 Alt+1
SendKeys.SendWait("%({ADD}251)") but it's Alt and then the other keys pressed simultaneously
Ref to MSDN
Any suggestions for a solution with SendKeys or other classes?
[Edit]
Solution:
Example for CharCode (Element of enum Source): ʊ = &H28A
Dim CharCodeUnicodeStr As String = Hex(CInt([Enum].Parse(GetType(Source), CharStr))).ToString
SendKeys.SendWait("%{ADD}%" & ChrW(Convert.ToInt32(CharCodeUnicodeStr, 16)))
Put the keys within parentheses to indicate that ALT should be held down while pressing the others.
SendKeys.SendWait("%({ADD}251)")
Have you tried
SendKeys.SendWait("%{ADD}%" & ChrW(&H251))
This will convert your hexa code into a char. Then if you have control over the other application you can revert this char back to a number...
I need to clear the textbox and enter value .After that i am moving to next step.This scenario is working fine in manual but not in automation.After enter the value and trying to move next step but alert is showing with following message
"Textbox field should not be empty".But already value is in textbox which i entered.Anyone please give me suggestion.
After enter the value in the textbox just click the same textbox then alert will not show in this type of scenario
Im using vb 2013. I tried to code my delete button after adding SQL delete in my Database. I wrote code in the class (I called it userFunc) calling the SQL DeleteItYourself with the variable DeleteIt. I created button with the toolbox and double clicked it, now I'm lost. I have session in the Login button to make sure it presents the user nickname. I redirected it to the homepage when the "I want to delete my account" located. Iactually don't know what to do with the button. I want it to call the function DeleteIt, but before the function Delete I want it to ask the user with some pop up alert if he's sure. Any ideas how to code my button?
(I'm a high school student and it's my project, they don't ACTUALLY teach us Java, unfortunately... They tell us to copy paste and try to understand)
Use this as a starting point:
If MsgBox("Are you sure you want to delete your account? This cannot be undone.", _
(MsgBoxStyle.Critical + MsgBoxStyle.OkCancel), _
"Confirm Account Deletion") = MsgBoxResult.Ok Then
UserFunc(DeleteIt)
End If
MsgBox displays a message box to the user, waits for a response, and returns the value of the button pressed. In the code above, the three arguments are:
The message to display
The style of the message box. Note how these are numeric values and can be added.
The title of the window.
I am creating a document in word with buttons that the user clicks to add text into a text box.
For example - clicking button 1 will add "You've clicked button 1" to text box 1.
Clicking button 2 will add "You've clicked button 2" to the same box. (Exciting stuff I know).
I'm using TextBox1.Text = TextBox1.Text + "You've clicked button 1" within a Click event in Visual Basic.
I'd like the user to be able to click the buttons again to be able to remove (or undo?) the text. Or, indeed, click a third time to add the text back in again.
I guess I want the user to be able to toggle the text in the box or not. Maybe even change the button colour based on whether the text is on/off or in/out of the text box.
Any suggestions?
The way that I would probably do this is to have a simple IF statement that first determines the state of the text. If it's empty, then populate it. If it's not empty, then make the value equal to "".
The code would look something like this (but not exactly - this is just theoretical)
If textbox1.text = "" Then
textbox1.text = "You've clicked button 1"
Else
textbox1.text = ""
End If
Apologies if I haven't understood the requirement correctly.