So i'm busy with AutoIt, i am now using this code
_IEPropertySet($passwordnew, "innertext", "12345678910")
This will paste the text "12345678910" into the Textbox of the webpage, is it possible to let it type it letter for letter? Not that it paste the whole concept. I already tried several stuff but it resulted in many errors.
Why? You can try something like this:
Global $passwordnew = StringSplit(12345678910, '', 2)
Global $valueOfPasswortField = ''
For $i = 0 To UBound($passwordnew) - 1
;~ $valueOfPasswortField &= $passwordnew[$i]
;~ ConsoleWrite($valueOfPasswortField & #CRLF)
_IEPropertySet($passwordnew, "innertext", _IEPropertyGet($passwordnew, "innertext") & $passwordnew[$i])
Sleep(400)
Next
It seems to me that you need a OnKeyUp event fired
$password = "1234567890"
_IEPropertySet($passwordnew, "innertext", "12345678910")
BlockInput(1)
_IEAction($passwordnew, "focus")
Send($password, 1)
BlockInput(0)
or
_IEPropertySet($passwordnew, "innertext", "12345678910")
$passwordnew.fireEvent("onkeyup")
Related
Dears,
How to get character's equivalent from another TextInput using PySimpleGUI?
Let me explain: Suppose I have those sets of data , set A and Set B, my query is once I write one characters in TextInput 1 from Set A I'll get automatically it's equivalent in Set B;
For example Set A : A, B, C, D, ........, Z
Set B : 1, 2, 3,4, ..........,26
So if I write ABC in TextInut A --> I'll get : 123 in TextInput B
Thanks in advance
import PySimpleGUI as sg
enter image description here
My apologies if I misunderstand your question.
First, special characters, like ☯, ∫, β, etc., are just Unicode characters. You can type them directly into your editor or use the Unicode escape codes. You might see this question for more help.
Second, it is unclear when you want to make this mapping. It is easiest if you type characters and then map at the end. If you want to do interactively that is harder. You can get each individual keyboard event; see (this answer)[https://stackoverflow.com/a/74214510/1320510] for an example. Because I know of no way of the exact position, you might be better getting the events, and writing the display to a second label. I would need to more a bit more about what you are doing.
Keep hacking! Keep notes.
Charles
Set option enable_events=True to A, map each char in values[A] by dictionary {'A':'1', ...}, then update B with the result when event A.
Demo Code
import string
import PySimpleGUI as sg
table = {char:str(i+1) for i, char in enumerate(string.ascii_uppercase)}
layout = [
[sg.Input(enable_events=True, key='-IN1-')],
[sg.Input(key='-IN2-')],
]
window = sg.Window('Main Window', layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
elif event == '-IN1-':
text1 = values['-IN1-']
text2 = ''.join([table[char] if char in string.ascii_uppercase else char for char in text1])
window['-IN2-'].update(text2)
window.close()
For different case, like table = {'a':'apple', 'b':'banana', 'c':'orange'}
import string
import PySimpleGUI as sg
table = {'a':'apple', 'b':'banana', 'c':'orange'}
layout = [
[sg.Input(enable_events=True, key='-IN1-')],
[sg.Input(key='-IN2-')],
]
window = sg.Window('Main Window', layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
elif event == '-IN1-':
text1 = values['-IN1-']
text2 = ''.join([table[char] if char in table else char for char in text1])
window['-IN2-'].update(text2)
window.close()
I working on a language similar to ruby called gaiman and I'm using PEG.js to generate the parser.
Do you know if there is a way to implement heredocs with proper indentation?
xxx = <<<END
hello
world
END
the output should be:
"hello
world"
I need this because this code doesn't look very nice:
def foo(arg) {
if arg == "here" then
return <<<END
xxx
xxx
END
end
end
this is a function where the user wants to return:
"xxx
xxx"
I would prefer the code to look like this:
def foo(arg) {
if arg == "here" then
return <<<END
xxx
xxx
END
end
end
If I trim all the lines user will not be able to use a string with leading spaces when he wants. Does anyone know if PEG.js allows this?
I don't have any code yet for heredocs, just want to be sure if something that I want is possible.
EDIT:
So I've tried to implement heredocs and the problem is that PEG doesn't allow back-references.
heredoc = "<<<" marker:[\w]+ "\n" text:[\s\S]+ marker {
return text.join('');
}
It says that the marker is not defined. As for trimming I think I can use location() function
I don't think that's a reasonable expectation for a parser generator; few if any would be equal to the challenge.
For a start, recognising the here-string syntax is inherently context-sensitive, since the end-delimiter must be a precise copy of the delimiter provided after the <<< token. So you would need a custom lexical analyser, and that means that you need a parser generator which allows you to use a custom lexical analyser. (So a parser generator which assumes you want a scannerless parser might not be the optimal choice.)
Recognising the end of the here-string token shouldn't be too difficult, although you can't do it with a single regular expression. My approach would be to use a custom scanning function which breaks the here-string into a series of lines, concatenating them as it goes until it reaches a line containing only the end-delimiter.
Once you've recognised the text of the literal, all you need to normalise the spaces in the way you want is the column number at which the <<< starts. With that, you can trim each line in the string literal. So you only need a lexical scanner which accurately reports token position. Trimming wouldn't normally be done inside the generated lexical scanner; rather, it would be the associated semantic action. (Equally, it could be a semantic action in the grammar. But it's always going to be code that you write.)
When you trim the literal, you'll need to deal with the cases in which it is impossible, because the user has not respected the indentation requirement. And you'll need to do something with tab characters; getting those right probably means that you'll want a lexical scanner which computes visible column positions rather than character offsets.
I don't know if peg.js corresponds with those requirements, since I don't use it. (I did look at the documentation, and failed to see any indication as to how you might incorporate a custom scanner function. But that doesn't mean there isn't a way to do it.) I hope that the discussion above at least lets you check the detailed documentation for the parser generator you want to use, and otherwise find a different parser generator which will work for you in this use case.
Here is the implementation of heredocs in Peggy successor to PEG.js that is not maintained anymore. This code was based on the GitHub issue.
heredoc = "<<<" begin:marker "\n" text:($any_char+ "\n")+ _ end:marker (
&{ return begin === end; }
/ '' { error(`Expected matched marker "${begin}", but marker "${end}" was found`); }
) {
const loc = location();
const min = loc.start.column - 1;
const re = new RegExp(`\\s{${min}}`);
return text.map(line => {
return line[0].replace(re, '');
}).join('\n');
}
any_char = (!"\n" .)
marker_char = (!" " !"\n" .)
marker "Marker" = $marker_char+
_ "whitespace"
= [ \t\n\r]* { return []; }
EDIT: above didn't work with another piece of code after heredoc, here is better grammar:
{ let heredoc_begin = null; }
heredoc = "<<<" beginMarker "\n" text:content endMarker {
const loc = location();
const min = loc.start.column - 1;
const re = new RegExp(`^\\s{${min}}`, 'mg');
return {
type: 'Literal',
value: text.replace(re, '')
};
}
__ = (!"\n" !" " .)
marker 'Marker' = $__+
beginMarker = m:marker { heredoc_begin = m; }
endMarker = "\n" " "* end:marker &{ return heredoc_begin === end; }
content = $(!endMarker .)*
I'm using the Perl6 Terminal::Print module for a console based application.
It's working well - however, now I need to prompt the user for a string of text.
What's a good way to do this?
Here is an example of using Terminal::Print::RawInput to get a filename as user input:
use v6;
use Terminal::Print;
use Terminal::Print::RawInput;
my $screen = Terminal::Print.new;
# saves current screen state, blanks screen, and hides cursor
$screen.initialize-screen;
$screen.print-string(9, 23, "Enter filename: ");
my $in-supply = raw-input-supply;
my $filename;
react {
whenever $in-supply -> $c {
done if $c.ord ~~ 3|13; # Enter pressed or CTRL-C pressed
my $char = $c.ord < 32 ?? '' !! $c;
$filename ~= $char;
print $char;
}
}
sleep .1;
$screen.shutdown-screen;
say "Filename entered: '$filename'";
Hi all I am haveing a problem geting a formula into google sheet using script editor. I can get one in that doesn´t work but not one that does.
This one will put the formula in but the formula doesn´t work
function x1() {
var ss3 = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss3.getRange("AF2").setFormula("=IF((AND(OR(I2='YOUR TRIP DWL',I2='MEGA PACK DWL (YT + AA + BONUS)'),L2<=0,AD2<>'')),'Send Email', 'Wait')")
var lr3 = ss3. getLastRow();
var filldownrange3 = ss3.getRange(2, 32, lr3-1);
ss3. getRange("AF2").copyTo(filldownrange3);
}
This one shows an Error in script editor but the furmula work in the cells i manually placed in.
function x1() {
var ss3 = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss3.getRange("AF2").setFormula("=IF(((AND(OR(I2="YOUR TRIP DWL",I2="MEGA PACK DWL (YT + AA + BONUS)"),M2<=0,AA2<>"",AE2<>""))), "Send Email", "Wait")")
var lr3 = ss3. getLastRow();
var filldownrange3 = ss3.getRange(2, 32, lr3-1);
ss3. getRange("AF2").copyTo(filldownrange3);
The problem is Line 3 with the formula itself as other fumulas are ok, can anyone shed some light on this, Thanks in advance,
I suggest you try your second version with escaping of the internal double quotes.
IF this hels anyone else with the same problem, I have finally solved this problem by changing the double quotes surounding the formula with single quptes and leaving the double quotes inside the formula, so line 4 reads:
ss3.getRange("AF2").setFormula('=IF(((AND(OR(I2="YOUR TRIP DWL",I2="MEGA PACK DWL (YT + AA + BONUS)"),M2<=0,AA2<>"",AE2<>""))), "Send Email", "Wait")');
I would like to get efficient way of working with Strings in Qt. Since I am new in Qt environment.
So What I am doing:
I am loading a text file, and getting each lines.
Each line has text with comma separated.
Line schema:
Fname{limit:list:option}, Lname{limit:list:option} ... etc.
Example:
John{0:0:0}, Lname{0:0:0}
Notes:limit can be 1 or 0 and the same as others.
So I would like to get Fname and get limit,list,option values from {}.
I am thinking to write a code with find { and takes what is inside, by reading symbol by symbol.
What is the efficient way to parse that?
Thanks.
The following snippet will give you Fname and limit,list,option from the first set of brackets. It could be easily updated if you are interested in the Lname set as well.
QFile file("input.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
qDebug() << "Failed to open input file.";
QRegularExpression re("(?<name>\\w+)\\{(?<limit>[0-1]):(?<list>[0-1]):(?<option>[0-1])}");
while (!file.atEnd())
{
QString line = file.readLine();
QRegularExpressionMatch match = re.match(line);
QString name = match.captured("name");
int limit = match.captured("limit").toInt();
int list = match.captured("list").toInt();
int option = match.captured("option").toInt();
// Do something with values ...
}