Auto-incrementing variable on iMacros without loop - auto-increment

Here's my current iMacro code I need help with:
`VERSION BUILD=8961227 RECORDER=FX
SET !LOOP 1
SET !var1
add !var1 {{!loop}}
TAB T=1
URL GOTO=https://www.google.com/?gws_rd=ssl
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!var1}}`
This code works fine with loop mode,but i want to auto-increment the var1 in each manual execution
Test1 :
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=1
Test 2: TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=2
I hope to be clear, thanks for helping me

You can try EVAL:
SET !VAR1 1
TAB T=1
URL GOTO=https://www.google.com/?gws_rd=ssl
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!VAR1}}
SET !VAR1 EVAL("var s=\"{{!VAR1}}\"; parseInt(s)+1;")
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!VAR1}}

VERSION BUILD=8961227 RECORDER=FX
SET !DATASOURCE NUM.csv
SET !VAR1 {{!COL1}}
TAB T=1
URL GOTO=https://www.google.com/?gws_rd=ssl
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!VAR1}}
**FILEDELETE NAME=C:\Users\Th3\Documents\iMacros\Datasources\NUM.CSV**
ADD !VAR1 1
SET !EXTRACT {{!VAR1}}
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Th3\Documents\iMacros\Datasources FILE=NUM.CSV

Related

Group by column and find the min and max date by group

I have the following data set:
Time Title
00:00:00 Title #one
00:12:38 Title #one
00:13:39 Title #one
00:33:14 Title #one
00:33:44 Title #two
00:49:27 Title #two
00:49:57 Title #two
00:59:43 Title #two
00:59:51 Title #three
00:59:59 Title #three
01:28:29 Title #three
01:28:38 Title #four
01:29:08 Title #four
01:29:38 Title #four
01:29:59 Title #four
01:37:08 Title #four
01:37:53 Title #four
01:38:53 Title #four
01:46:20 Title #four
I want to be able to group by Title and returns the min and max time for each title.
I've been able to get the min and max time for each titles with this:
df_max = df.groupby(['Title'])['Start time'].max()
df_min = df.groupby(['Title'])['Start time'].min()
However I don't really understand what df_max and df_min are returning exactly and how I should merge them...
You should use the .agg method.
df.groupby(['Title']).agg({'Start time':[min,max]})

Click button or hide box in iMacros or Greasemonkey

So I've had an iMacro for about a year now working fine.
The iMacro has the following line in it:
ONDIALOG POS=1 BUTTON=OK CONTENT=
That's because after the tab 2 closes, a dialog popup box appears and the "OK" button needs to be clicked. However, for some reason since a few days now this stopped working. I think the popup box somehow changed.
Here is how the box looks:
I need to be able to click this, because otherwise I can't continue doing what I need to do. I'm thinking if iMacros can do it (I tried recording with different recording modes, and nothing records when I click the OK button). I'm using iMacros for Firefox by the way. Or, maybe to do it somehow with Greasemonkey? Or if anyone has any other idea?
The website I'm trying to create an iMacro for is called Likesasap.com, and I'm trying to make a script for their website hits category.
Here is the script that I have that worked up until a month ago:
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 20
SET !VAR1 EVAL("var min = 2; var max = 3; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
SET !VAR2 EVAL("var min = 4; var max = 5; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
SET !VAR3 EVAL("var min = 25; var max = 27; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
TAB T=1
URL GOTO=http://www.likesasap.com/website.php
WAIT SECONDS={{!VAR1}}
TAG POS=1 TYPE=INPUT:BUTTON ATTR=*
TAB T=2
WAIT SECONDS={{!VAR3}}
TAB T=1
ONDIALOG POS=1 BUTTON=OK CONTENT=
WAIT SECONDS={{!VAR2}}
TAG POS=1 TYPE=INPUT:BUTTON ATTR=*
TAB T=2
WAIT SECONDS={{!VAR3}}
TAB T=1
ONDIALOG POS=1 BUTTON=OK CONTENT=
WAIT SECONDS={{!VAR2}}
TAG POS=1 TYPE=INPUT:BUTTON ATTR=*
TAB T=2
WAIT SECONDS={{!VAR3}}
TAB T=1
ONDIALOG POS=1 BUTTON=OK CONTENT=
TAB CLOSEALLOTHERS
WAIT SECONDS={{!VAR2}}
Can anyone help with this?
Thanks

how to auto set the check boxes to reflect the settings on opening the stack

The stack that I made should display the text line categories. I can set the Categories on the Select Categories card and the settings are saved in an external text file. When opening the stack again the Categories are correctly displayed in the form but on the card where the selection is made the selected check boxes do not correspond to the displayed Categories.
The code on the stack level that is not working for the above:
global gAllLines,gSelectedCategories
on openStack
put empty into gAllLines
set the itemDelimiter to tab
put fld "alllines" of cd "settingsandfiles" into gAllLines
put empty into gSelectedCategories
set the itemDelimiter to tab -- do I have to set the itemDelimiter here again even though it was set above?
set the defaultFolder to specialFolderPath("Documents")
put URL ("file:./myAppsData.txt") into gSelectedCategories
if "s" is among the items of gSelectedCategories then set the hilite of btn "Short" of cd "select_categories" to true
if "m" is among the items of gSelectedCategories then set the hilite of btn "Medium" of cd "select_categories" to true
if "l" is among the items of gSelectedCategories then set the hilite of btn "Long" of cd "select_categories" to true
end openStack
The code on the Save button on the Select the Categories card is:
global gAllLines,gSelectedCategories,gMyCategories
on mouseUp
put empty into gSelectedCategories
set the itemDelimiter to tab
if the hilite of btn "Short" is true then put "s" & tab after gSelectedCategories
if the hilite of btn "Medium" is true then put "m" & tab after gSelectedCategories
if the hilite of btn "Long" is true then put "l" & tab after gSelectedCategories
put gSelectedCategories into URL ("file:./myAppsData.txt")
go back
end mouseUp
Here is the link to the stack:
https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form_save%20and%20retrieve%20settings.zip
or here:
http://filecloud.io/lk06h3py
or here:
http://www.divshare.com/download/24928436-897
the
How to correct this problem?
Thanks in advance.
keram
=======================
I fixed it now by changing the code on the stack level:
on openStack
put empty into gAllLines
set the itemDelimiter to tab
put fld "alllines" of cd "settingsandfiles" into gAllLines
put empty into gSelectedCategories
put URL ("file:" & specialFolderPath("Documents") & "/myAppsData.txt") into gSelectedCategories
if "s" is among the items of gSelectedCategories then set the hilite of btn "Short" of cd "select_categories" to true
else set the hilite of btn "Short" of cd "select_categories" to false
if "m" is among the items of gSelectedCategories then set the hilite of btn "Medium" of cd "select_categories" to true
else set the hilite of btn "Medium" of cd "select_categories" to false
if "l" is among the items of gSelectedCategories then set the hilite of btn "Long" of cd "select_categories" to true
else set the hilite of btn "Long" of cd "select_categories" to false
end openStack
keram
When you save the data, it is tab-delimited. When you read back the data, the script assumes the default delimiter which is a comma. If you set the itemDelimiter to tab before reading the values, it should work.
It isn't clear whether the user is allowed to select multiple items or only one. If it is only one, then you don't need to test for items at all, there will only be a single character in the data ("s","m" or "l".)
I've just tested your stack and it works for me here (OSX9), are you doing this on a mac or pc? I'm wondering if the problem might be the route to the text file and whether it would be worth adding
set the defaultFolder to specialFolderPath("Documents")
to the script of your 'save' button.
But actually it sounds like you just need to do some debugging and research answers to questions such as: is the text file being created where you expect it to? Does it contain what you think it should? Your checkboxes seem to be highlighted by default, what happens if you unhighlight them and try your routine, do you still get them all showing as highlighted? etc etc etc
Dave Kilroy
Cannot access your stack. So I cannot know what the variables "s", "m" and "j" are, or if they properly fit into "the items" of the data pulled from that file.
You do know that items are chunks of text delimited by commas, correct? It sounds like the formatting is not right, because the command to set the hilites of those buttons seems straightforward. So what does "s" contain, and more importantly, how is the returned text formed?
Craig Newman

why check box does not move when stack is resized?

I made a stack that displays lines of text that change their width when the stack is resized.
The Category columns is changing its position on resizing but the check box does not.
What am I missing in the code? What changes have to be made?
See the code in the stack that can be downloaded here:
https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form-variable%20line%20height%2Bcheckbox.zip
Thanks in advance.
keram
If I understand what you are trying to achieve here then in your LayoutControl handler make the following change:
-- put the rect of btn "btnCheck" of me into theFieldRect
-- put item 3 of pControlRect - 5 into item 3 of theFieldRect
-- set the rect of btn "btnCheck" of me to theFieldRect
set the left of btn "btnCheck" of me to the right of fld "cat" of me
However I think the resizing of the Cat field is wrong too. Try something like:
on LayoutControl pControlRect
set the right of btn "btnCheck" of me to item 3 of pControlRect-4
set the right of fld "Cat" of me to the left of btn "btnCheck" of me
get the rect of fld "Line" of me
put the left of fld "Cat" of me into item 3 of it
set the rect of fld "Line" of me to it
put the formattedHeight of fld "Line" of me + item 2 of it into item 4 of it
set the rect of fld "Line" of me to it
put item 4 of it into item 4 of pControlRect
set the rect of graphic "Background" of me to pControlRect
end LayoutControl
To edit the LayoutControl script you need to open the datagrid property inspector and click on the Row Behavior... button. This will present the script editor for the behavior of the row template.
Because the DataGrid doesn't have this feature. If you would use the Geometry manager, the GM propeties are not copied from the checkbox in the template to the checkboxes in the actual DG. So, the GM won't work. Perhaps you could write a script of your own that sets the right of all checkboxes to a position relative to the width of the card:
on resizeStack
lock screen
repeat with x = 1 to number of buttons
if the style of btn x is "checkbox" then
set the right of btn x to the width of this cd - 100
end if
end repeat
unlock screen
end resizeStack
Unfortunately, this doesn't work with the datagrid either, because the DG also does some (or a lot) resizing of its own.
It would be much easier to create your own.

How Do type random text in imacros?

TAG POS=1 TYPE=TEXTAREA FORM=NAME:frmSendSms ATTR=ID:Message_ CONTENT=Ranndom text
How to type random text in this iMacros Command.
var macro;
macro ="CODE:";
macro +="TAG POS=1 TYPE=TEXTAREA FORM=NAME:frmSendSms ATTR=ID:Message_ CONTENT={{random_text}}"
var random_text="Some random text";
iimSet("random_text",random_text)
iimPlay(macro)
This could do the trick.

Resources