Autohotkey: Save variable into forum field - variables

I am trying to write an autohotkey script to fill an online forum using COM. My problem is that the username is incremented by numbers, so ideally I want to loop the script to fill the form 5 or 6 times.
Here is the autohotkey part I am struggling with:
number := 28
username = user%number%
wb.document.all.getElementById(username).value := "username" ;HERE IS THE PROBLEM
number++
I have tried %username%, username without quotes, and with single quotes, and nothing seem to be working.
any ideas?
Thanks for your help.

First thing that popped out to me was all in you, I see Joe DF asked if you had tried without?
Second thing is you shouldn't have ""'s around your Variable.
If you are doing multiple assignments you can enclose them in ()'s like so:
:= (UserName "`n" Address "`n" PhoneNumber "`n" SocialSecurity)
If you are having problem's with a document not fully being loaded you can implement a custom loading routine like so:
wb.Navigate("Yourwebsite")
GoSub loading
.
.
.
loading:
ComObjError(false) ;turn off com errors
While value = "" {
value := wb.document.getElementsByClassname("somethingHere") [0].innerText
Continue
}
ComObjError(true)
Return
Without seeing more of your code and the website you are trying to work with, it will be difficult to help you further.

It worked... turns out it was the sleep time for the form to load. form was slower than Sleep 100 for some reason. Now, the form loads, but it is only taking 1 field. so password and email are not being filled.

Related

Protractor sendKeys issue with scripted input fields

I'm automating e2e tests with Protractor on an angular app.
However, I have an issue when sending keys on input fields.
The sendKeys would miss few characters everytime so I found a workaround :
static sendKeys(value, element){
value.split('').forEach((c) => element.sendKeys(c));
}
This works well but it takes more than 3 times the time the original sendKeys function would.
Well no problem my tests are still functionnal right ?
My app now has new fields with scripts behind them.
One of them is a datepicker input, you can either choose from the datePicker or type it manually. However, for today's date you would type 09022018 and the slashes are automatically appended at the right place (like so 09/02/2018). If you were to enter a wrong date the field is cleared.
Now back to the problem : it seems that both my implementation of sendKeys and the original one loose focus after each submitted key. This means that I can't enter a valid date in the input field as it's cleared after each simulated keypress.
I could use browser.executeScript to fix it but I wouldn't be able to test the functionnality adding slashes. Also, as you type, the datepicker is still open and refreshes after each keypress, you can select a date from it at any time and that is also a feature I want to test.
Thanks in advance
Use executeScript to set the date in backgrond, then use sendKeys to enter a space or Tab at the end to trigger the Keyborad event which will check the input and format the input with slash
function enterDate(date) {
var script = 'arguments[0].value=arguments[1]';
// input box for date
var dateBox = element(by.xxx(yyy));
browser.executeScript(script, dateBox, date);
dateBox.sendKeys(" ");
// or try send Tab
dateBox.sendKeys(protractor.Key.TAB);
}
enterDate('09022018');
You can try this solution on other fields you fixed but take 3 more time.

Octave printf does not output when followed by ginput

I am trying to make a prompt for the user to select from the figure (plot).
When I run it with the code below, the prompt doesnt display until i click on the figure, after which the prompt displays and the code continues. In fact, no call to printf (or disp) that is called before the ginput call displays until i select the figure.
printf("Select part\n"); % (disp also doesnt work properly)
[xinput,yinput] = ginput(1);
The purpose of the prompt is to alert the user to move to the figure, so naturally it needs to display before selecting the figure.
I can add an extra redundant input call between the two which forces the printf to display in the console. eg input("Press Enter"). but this is an inconvenient solution.
Strangely, if you run just the code above it does work normally. But when running in the remainder of the program it displays the issue. So it may be a difficult one to debug. Also, running it one line at a time in the full code using the debugger works properly, displaying the prompt before selecting the figure.
Just to add to the confusion. When running this part of the program in a loop, the first instance doesnt display the prompt correctly, but every other instance it works.
Thanks
EDIT:
The following code reliably fails (for me) in the same way my full program fails; (edited again to simplify)
figure(1);
input_test = input("press 1: ");
switch input_test
case 1
while true
clc;
printf("Left click to get coords or right click to finish\n");
[xinput,yinput,mouse_button] = ginput(1)
if mouse_button == 3
break
endif
endwhile
endswitch
It appears it has something to do with the line;
input_test = input("press 1: ");
If I replace this with
input_test = 1;
it works properly.
I dont know what is the reason for this, and I cannot remove the input request from this location.
Thanks Roger, you were correct, I did find a solution.
Using
fflush(stdout)
before the 'ginput' call solves the problem.
Found this in the 'input' help;
"Because there may be output waiting to be displayed by the pager,
it is a good idea to always call 'fflush (stdout)' before calling
'input'. This will ensure that all pending output is written to
the screen before your prompt."

Declaring/using variables with barcode in EPL

I am having some difficulty in using variables that I am declaring in a barcode statement using EPL (I have a zebra tlp 2844 printer).
Here is my code
N
q609
Q203,26
FK"GNLABEL"
FS"GNLABEL"
V00,3,N,"ENTER PROGRAM:"
V01,4,N,"ENTER YEAR:"
C0,6,N,+1,"-ENTER COUNTER VALUE:"
B10,10,0,3,1,3,50,B,**V00,V01"G"CO**
FE
FR"GNLABEL"
?
GNJ
2013
0
P1
When I send my file to the printer, I do not get a prompt for V00 or V01, and nothing prints out (just 1 blank label)
Looking over your code, it seems that a few things might need to be changed.
When you are recalling the form with FR, you are not specifying the form name. It will not know which form to recall without the name.
In your form, there is a ",CO" at the end of your barcode command. I believe what you are trying to do is place the counter digit at the end, C0 (I believe your code is using the capital letter O instead of the number 0). To do this, the comma should be removed.
Try using the following code:
N
q609
Q203,26
FK"GNLABEL"
FS"GNLABEL"
V00,3,N,"ENTER PROGRAM:"
V01,4,N,"ENTER YEAR:"
C0,6,N,+1,"-ENTER COUNTER VALUE:"
B10,10,0,3,1,3,50,B,"GNJ2013G"C0
FE
FR"GNLABEL"
?
GNJ
2013
0
P1
Hopefully this helps. Let me know if this solves your issue.

How to Use GuiDropFiles with GUI controls?

How can I use GuiDropFiles with GUI controls?
I have several edit fields in my form, and I want to be able to drop files onto them separately and work with them.
This is what I came up with:
First, my controls are set up like this:
WS_EX_ACCEPTFILES=0x10
Gui, add, edit, vedit1, %file_1%
WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1
And my drag-drop routine is as such:
GuiDropFiles: ; Support drag & drop.
Loop, parse, A_GuiControlEvent, `n
{
thisfile := a_loopfield ; Get the first file only (in case there's more than one).
thiscontrol := a_guicontrol
break
}
alert(thisfile . "`r" . thiscontrol)
if(thiscontrol = edit1)
guicontrol,,%edit1%, %thisfile%
if(thiscontrol = edit2)
guicontrol,,%edit2%, %thisfile%
if(thiscontrol = edit3)
guicontrol,,%edit3%, %thisfile%
return
I am using the basic example from the autohotkey documentation. I also tried the example from here, but it keep saying, "not dropped on an edit box".
Any clue would be great.
Figured it out (after a few lost hours).
First, I didn't need this: WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1
and I didn't need to set any styles on the edit controls.
All I needed was this, which works since my edit controls have the variable-name starting with "UI_file":
GuiDropFiles: ; Support drag & drop.
Loop, parse, A_GuiEvent, `n
{
thisfile := A_LoopField ; Get the first file only (in case there's more than one).
thiscontrol := a_guicontrol
break
}
;alert(thisfile . "`r" . thiscontrol)
If InStr(A_GuiControl, "UI_file")
guicontrol,,%A_GuiControl%, %thisfile%
return

Problem retrieving values from Zend_Form_SubForms - no values returned

I have a Zend_Form that has 4 or more subforms.
/**
Code Snippet
**/
$bigForm = new Zend_Form();
$littleForm1 = new Form_LittleForm1();
$littleForm1->setMethod('post');
$littleForm2 = new Form_LittleForm2();
$littleForm2->setMethod('post');
$bigForm->addSubForm($littleForm1,'littleForm1',0);
$bigForm->addSubForm($littleForm2,'littleForm2',0);
On clicking the 'submit' button, I'm trying to print out the values entered into the forms, like so:
/**
Code snippet, currently not validating, just printing
**/
if($this->_request->getPost()){
$formData = array();
foreach($bigForm->getSubForms() as $subForm){
$formData = array_merge($formData, $subForm->getValues());
}
/* Testing */
echo "<pre>";
print_r($formData);
echo "</pre>";
}
The end result is that - all the elements in the form do get printed, but the values entered before posting the form don't get printed.
Any thoughts are appreciated...I have run around circles working on this!
Thanks in advance!
This is what I did -
$bigForm->addElements($littleForm1->getElements());
Then, iterated over the form elements like so:
$displayGroup1 = array();
foreach($bigForm->getElements() as $name=>$value){
array_push($displayGroup1, $name);
}
Then, add a displayGroup to $bigForm:
$bigForm->addDisplayGroup($displayGroup1, 'test',array('legend'=>'Test'));
And repeat for multiple display groups.
I'm sure there is a better way to do it, but I'm currently unable to find one out.
This is currently one way I can think of to retrieve all the form values via $_POST, if a form is made up of one or more subforms.
If any one knows of a better solution, please post it!
A Zend_Form does not automatically retrieve values from the $_POST variable. Use:
$bigform->populate($_POST)
Or alternatively:
$bigform->populate($this->_request->getPost())
Another thing to keep in mind is that if the sub forms contain elements with the same name they will clash. To check this use the option View => Page Source in your browser and look at the HTML that is generated. When you see two <input> elements with the same name attribute, then this is the problem.
The Zend solution for this is to give the sub form elements different names using setElementsBelongTo:
$littleForm1->setElementsBelongTo('littleForm1');
$littleForm2->setElementsBelongTo('littleForm2');
Furthermore you should leave out these calls as they serve no purpose (but you should set them for the $bigForm):
$littleForm->setMethod('post');