How to add emotion to telegram markup keyboard - api

I create a markup keyboard for my telegram bot, anybody know how I can add emotion in the options look like the below link ?
Thanks

salam seyed. the problem is not limit to keyboard. in the message also you have same problem for sending emoji. you must pack the emoji unicode bytes before send:
$message .= iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F453));
and in this link you can see the list of emoji code that you need enter in the above code.

Steps to perform:
copy the emotion from your telegram client;
paste it into your IDE as String variable;
Use the variable as Inline button's label
Here is a java example:
public InlineKeyboardMarkup getBtn() {
String label = "\uD83D\uDE04Laughing button";
String label2 = "\uD83D\uDE21Angry button";
InlineKeyboardMarkup markup = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> keyboard = new ArrayList<>();
List<InlineKeyboardButton> row_1 = new ArrayList<>();
List<InlineKeyboardButton> row_2 = new ArrayList<>();
row_1.add(new InlineKeyboardButton(label).setCallbackData("1"));
row_2.add(new InlineKeyboardButton(label2).setCallbackData("2"));
keyboard.add(row_1);
keyboard.add(row_2);
markup.setKeyboard(keyboard);
return markup;
}

Related

How do you style a substring in a PDF (in Adobe Acrobat)?

Editing a PDF (specifically a user-editable form) using Adobe Acrobat, and using the PDF JavaScript API, is it possible to style separate substrings within a field value? Is there a markup language used, for example?
A bit of pseudocode for what I’m talking about:
This word is <red>red</red>, this word is <bold>bold</bold>. I have spoken.
The answer is to:
a) Make sure the field type is rich text, and
b) Use Adobe's JavaScript methods to set spans within the field's richValue property with the formatting desired, for example:
var field = this.getField("MyRichTextField");
var spans = new Array();
spans[0] = new Object();
spans[0].text = "This word is ";
spans[1] = new Object();
spans[1].text = "red";
spans[1].textColor = color.red;
field.richValue = spans;
Further details and a list of span properties can be found in Acrobat JavaScript Scripting Reference (https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/Acro6JS.pdf)

PdfFormField simply does not hide when setting the visibility to HIDDEN

I'm setting the visibility of a PdfFormField to HIDDEN using the setVisibility() method with parameter PdfFormField.HIDDEN. Still, on flattening it, the field does not hide. Below is the code to do so.
File file = new File("path to PDF file");
baos = new ByteArrayOutputStream();
pdfDoc = new PdfDocument(new PdfReader(file.getAbsolutePath()), new PdfWriter("path to flattened PDF file"));
//This function removes all the permissions.
removePdfPermissions();
form = PdfAcroForm.getAcroForm(pdfDoc, true);
fields = form.getFormFields();
fields.get("HumanSubjectsText").setVisibility(PdfFormField.HIDDEN);
fields.get("HumanSubjects").setVisibility(PdfFormField.HIDDEN);
form.flattenFields();
pdfDoc.close();
Setting the values of the fields to empty string "" is a workaround, but not the proper way.
The fields "HumanSubjects" and "HumanSubjectsText" correspond to a checkbox and its correspond text on page 2. (Human Subjects)
Link to PDF file
The fields could not be hidden using iText library. In contrast to Bruno's comment, one of the methods from iText library worked well, the setValue(). I'm not quite sure why the setVisibility() fails.
However, I was able to hide the field using Master PDF editor tool. I've attached a screenshot of this tool, where you can change the visibility for a form field from the General tab.
An observation: In the com.itextpdf.forms.fields.PdfFormField some of the constants defined are as follows:
public static final int HIDDEN = 1;
public static final int VISIBLE_BUT_DOES_NOT_PRINT = 2;
public static final int HIDDEN_BUT_PRINTABLE = 3;
public static final int VISIBLE = 4;
The Master PDF editor also has similar options to hide a field. Please refer to the attached screenshot.
NOTE: My requirement was just to simply hide the field. It could be achieved programmatically by using a library like iText or with some PDF editor tool.

How do you automate DevExpress Combo Boxes with Selenuim/Watir?

DevExpress builds combo boxes in a very odd way. The standard identification built in to Selenuim and Watir (including Page Objects) does not see it as a Select List.
So how can you automate these successfully?
So as it turns out, DevExpress builds combo boxes as a text box with several layered tables associated with it but not under the text box in the HTML tree.
interactions are all done via embedded scripts.
I found the simplest way to automate this object is to identify the text box and the lowest table containing the list of items (3rd table down).
for example (using Watir and Page Objects)
table(:list,:id => 'ComboBoxValue_DDD_L_LBT')
text_field(:state, :id => 'ComboBoxValue_I') #:name => 'State')
I have not found a way to get better IDs at these levels, but we are working that issue.
Then your select code looks like this:
self.state_element.click
row = list_element.find { |row| row[0].text == value }
row.click
Note that with Selenium, you can execute arbitrary javascript in the client to query and set the control's state (if the client-side is enabled for the control). Here's how I did so to extract (and set) the selected text from a combobox named localeSelectList:
// unit test code, c#
[TestMethod]
public void SomeTestMethod()
{
IWebDriver ff = new FirefoxDriver();
ff.Navigate().GoToUrl(homeUrl);
// find the element as an iWebElement
IWebElement localeBox = ff.FindElement(By.CssSelector("#localeSelectList"));
Assert.IsTrue(localeBox.Enabled);
// get the text from the control via javascript
var locale = Util.GetControlText(ff, localeSelectList);
Assert.IsTrue(locale == "English");
// set the text in the control via javascript
Util.SetControlText(ff, localeSelectList, "German");
// verify the text was set
locale = Util.GetControlText(ff, localeSelectList);
Assert.IsTrue(locale == "German");
}
// helper methods, Util class
static public string GetControlText(IWebDriver driver, string controlName)
{
string script = string.Format("return {0}.GetText();", controlName);
var controlText = ((IJavaScriptExecutor)driver).ExecuteScript(script);
return controlText.ToString();
}
static public void SetControlText(IWebDriver driver, string controlName, string controlText)
{
string script = string.Format("{0}.SetValue('{1}');", controlName, controlText);
((IJavaScriptExecutor)driver).ExecuteScript(script);
}
It's not quite the same thing as interacting with the extensions via primitives (clicks, keystrokes, etc) as it won't fire the event handlers for these events, but if your extension uses 'valueChanged' events instead of primitive handlers it's pretty close to the same.
Also note: you can use client-side javascript to find and return elements using jquery/css selectors and ids, as follows:
IWebElement element = (IWebElement) ((IJavaScriptExecutor)driver).ExecuteScript("return $('#.myElementId');")
That's right with several layered tables, but I would like to add that they are only visible when combobox is clicked. First
var cmbParameterGruppen = webDriver.FindElement(By.Id("phContent_ParameterGruppenComboBox_I"));
cmbParameterGruppen.Click();
and then
var tblItems = webDriver.FindElement(By.Id("phContent_ParameterGruppenComboBox_DDD_L_LBT"));
var parameterGruppen = tblItems.FindElements(By.XPath(".//*"));
var count = parameterGruppen.Count;
Debug.WriteLine($"Count = {count}");
if(count > 0)
parameterGruppen[count - 1].Click();
I select hier last row.

How to send capital alphabet using keyboard?

Using below code, it sends key in browser URL not in google search text box.
i want to enter text in google search text field using keyboard event in caps.
driver.get(https://www.google.co.in/);
Actions builder = new Actions(driver);
Action enterText = builder.click(driver.findElement(By.
cssSelector("input[type=text]"))).
keyDown(Keys.SHIFT).
sendKeys("my gmail").
keyUp(Keys.SHIFT).
build();
enterText.perform();
You can use
driver.findelement("YOURELEMENTLOCATOR").sendKeys(Keys.SHIFT,"yourtexttobetyped")
Example,
driver.findElement(By.cssSelector("input[type=text]")).sendKeys(Keys.SHIFT,"stackoverflow")
will send you 'STACKOVERFLOW'. or else you can send the CAPITAL letters directly in the send keys as
driver.findElement(By.cssSelector("input[type=text]")).sendKeys("STACKOVERFLOW")
:)
Below code is to uppercase the first letter of password. It worked perfect for me. Kindly suggest to others too.
String password = "Done123!";
password = password.substring(0, 1).toUpperCase() + password.substring(1);
driver.findElement(By.cssSelector("input[type=text]")).sendKeys(password);
Thanks.
Simple helper function
def capitalized(driver, string):
for char in string:
if char.isUpper():
driver.send_keys(Keys.SHIFT, char)
else:
driver.send_keys(char)

Is there a way to Edit the TextColor of the text inside Toasts in Windows8

Is there a way to Edit the TextColor of the text inside Toasts in Windows8 ?
Created like this.
var toastXml = new XmlDocument();
var title = toastXml.CreateElement("toast");
var visual = toastXml.CreateElement("visual");
visual.SetAttribute("version", "1");
visual.SetAttribute("lang", "en-US");
var binding = toastXml.CreateElement("binding");
binding.SetAttribute("template", "ToastImageAndText02");
image.SetAttribute("src", ActualPathToSet);
//Here the Text is assigned
var heading = toastXml.CreateElement("text");
heading.SetAttribute("id", "1");
heading.InnerText = R.GetResourceString("Hello World");
title.AppendChild(visual);
visual.AppendChild(binding);
binding.AppendChild(image);
binding.AppendChild(heading);
var toast = new ToastNotification(toastXml);
I have created a toast like above and want to change the TextColor property.
using C# +XAML + Win8
Change foreground color in manifest file.
I think this is not possible because the Toast Notification is a system internal function and the color is given by the user setting background color.