iMacros - Detect {{LOOP}} value number and scrol down the page - eval

I found a solution for what I need, but maybe someone can help me optimize it.
When the {{LOOP}} value have 20 to 40,60,80,100,120,140,160, ... 2000... 10000... etc. or more, I need to Scroll Down the page with the value I need.
Because the WebPage is big and I should reach maybe 20000 as the value of {{LOOP}}.
In this case, my solution seems a little out of hand. I would have to repeat the code in many lines.
SET !LOOP 20
SET !EXTRACT {{!LOOP}}
SET scrolla EVAL("var x='{{!EXTRACT}}'; var z; if(x=='20'){z=\"javascript:window.scrollBy(0,5000)\";} else{z=\"javascript:window.scrollBy(0,500)\";}; z;")
SET scrolla EVAL("var x='{{!EXTRACT}}'; var z; if(x=='40'){z=\"javascript:window.scrollBy(0,5000)\";} else{z=\"javascript:window.scrollBy(0,500)\";}; z;")
SET scrolla EVAL("var x='{{!EXTRACT}}'; var z; if(x=='60'){z=\"javascript:window.scrollBy(0,5000)\";} else{z=\"javascript:window.scrollBy(0,500)\";}; z;")
'URL GOTO={{scrolla}}
PROMPT {{scrolla}}
Someone have another solution for my problem? More optimized? and not using so many lines?
thank you so much
I am using (FCI):
iMacros for CR v10.1.1 'PE', CR v105.0.5195.102 (_x64), Win10_x64.
('CR' = 'Chrome' / 'PE' = 'Personal Edition')
Later edit:
Another idea that crossed my mind would be to use a .csv and put 20, 40, 50 ... 1000 on the specific line to match the {{LOOP}}, and the other lines 0,0,0,0,. and in EVAL function I will use it (x=='{{!COL1}}') instead of (x=='20'), (x=='40')..

Related

define geofence around location stored in array

I am working on an app where I have a set of pre-defined co-ordinates stored in an array like the one below:
var SpeedcameraLocationDictionary: [[String : AnyObject]] = [
["camindex": "1a", "Latitude":xxxx, "Longitude":xxxx,"Distance":34, "legalspeed":110],
["camindex": "1b", "Latitude":xxxx, "Longitude":xxxx,"Distance":34, "legalspeed":110],
["camindex": "2a", "Latitude":xxxx, "Longitude":xxxx,"Distance":26, "legalspeed":110],
["camindex": "2b", "Latitude":xxxx, "Longitude":xxxx,"Distance":26, "legalspeed":110]]
What I want to do is, when the users location matches any lat & long in the array (+ or - 5 meters) , start doing some calculations. I have variables set up to hold the lat & long of the user, and the relevant CLLocation manager. Implanting on checking the users location every 30 secs, so i have a timer set up to trigger at 30sec intervals.
I believe I need to set up a geofence around the relevant point, but I'm not really sure how to do the check & set up.
I imagine it would be along the lines of the following:
if Timer = 30secs
let region = CLCircularRegion(center: Latitudefromarray,longitudefromarray, radius: 5,)
if (Latitude +/- 5m == region AND longitude +/- 5m == region)
do calculations....
could somebody either point me in the direction of a tutorial that could help me achieve this goal, or provide some sample code to achieve the goal I'm after? i have been following this tutorial but am struggling to adapt it to my needs.
Thanks

Exporting ARIMA-regression forecasts

I'll be grateful if you can answer this. I fit a regression-ARIMA model as
'm1<-arima(y1,order=c(0,1,1),xreg=x1)'
Standard command for ARIMA with regressors.
Then I use it to predict ahead:
'f1<-predict(m1,newxreg=x2,n.ahead=5)'
standard stuff
The problem appears next, where I get this output (focusing on the part that matters):
[126] 0.160095040 0.350650026 0.281973859 -0.161599717 0.305046264
$se
Time Series:
Start = 131
End = 135
Frequency = 1
[1] 0.2268524 0.2283935 0.2299241 0.2314447 0.2329553
I'd overlook that it repeats the entire series, which I'm not interested in; my problem is that I can't export the predictions! When I submit
'write.csv(f1,"out.csv")'
I get
Error in data.frame(pred = c(0.303546011854172, 0.240057038087077, 0.125706531559436, : arguments imply differing number of rows: 130, 5
As for the forecasts, the vector f1 appears of length 2, with f1[1] being the 130 original observations, and f1[2] being the 5 forecasts! (Instead of f1[1] being the forecast of the 1st period ahead, f1[2] the forecast of the 2nd period, etc)
Any ideas of what's going on and what can I do about it?
And to intrique you even more, the problem only appears when I use regressors! Everything works well if I only have ARIMA!
Any help is much appreciated!

Creating a visible timer on experiment stimulus in psychopy

New to the forum, thanks in advance for any help you could provide.
I have a series of .jpgs that are being presented to users as they study the info contained within. Instructions state that each jpg can be studied for a max of 120secs. I've already coded it such that the jpg will advance after the 120sec limit:
RespKey= []
RT = []
event.clearEvents()
myClock.reset()
t1example = myClock.getTime()
t2example = t1example
while t2example < (t1example+120): # value added to t1 here is timeout value;
RespKey = event.getKeys(keyList=["space"], timeStamped=myClock) # they are told to press space bar when done studying
if len(RespKey) > 0:
RT = RespKey[0][1]
Resp = RespKey[0][0].lower()
print Resp
print RT
break
else:
t2study = myClock.getTime() # end of timeout loop
myWin.flip()
The problem is, I don't know how to make the Clock/ Timer/ Stopwatch function visible to the user while studying the jpg. Is there a way to superimpose a visible clock onto the stimulus so nobody is surprised when the study time comes to an end?
Note: New to coding, please couch jargon in layman speak if at all possible.
Thank you!
Yes. Before the loop (and before re-setting the clock), create a text stimulus like this:
clockText = visual.TextStim(myWin) # include other parameters if you want to change the default size, font, etc
Then on every frame, you will update the content of that stimulus. i.e. just prior to the myWin.flip() call, do this:
clockText.setText(str(t2study)) # you can format/round this as required
clockText.draw()
Check the face_jpg.py Coder demo for an example of displaying text like this on every frame.

Using PyMEL to set the "Alpha to Use" attribute in an object of class psdFileTex

I am using Maya to do some procedural work, and I have a lot of textures that I need to load into Maya, and they all have transparencies (alpha channels). I would very much like to be able to automate this process. Using PyMEL, I can create my textures and hook them up to a shader, but the alpha doesn't set properly by default. There is an attribute in the psdFileTex node called "Alpha to Use", and it must be set to "Transparency" in order for my alpha channel to work. My question is this - how do I use PyMEL scripting to set the "Alpha to Use" attribute properly?
Here is the code I am using to set up my textures:
import pymel.core as pm
pm.shadingNode('lambert', asShader=True, name='myShader1')
pm.sets(renderable=True, noSurfaceShader=True, empty=True, name='myShader1SG')
pm.connectAttr('myShader1.outColor', 'myShader1SG.surfaceShader', f=True)
pm.shadingNode('psdFileTex', asTexture=True, name='myShader1PSD')
pm.connectAttr('myShader1PSD.outColor', 'myShader1.color')
pm.connectAttr('myShader1PSD.outTransparency', 'myShader1.transparency')
pm.setAttr('myShader1ColorPSD.fileTextureName', '<pathway>/myShader1_texture.psd', type='string')
If anyone can help me, I would really appreciate it.
Thanks
With any node, you can use listAttr() to get the available editable attributes. Run listAttr('myShaderPSD'), note in it's output, there will be two attributes called 'alpha' and 'alphaList'. Alpha, will return you the current selected alpha channel. AlphaList will return you however many alpha channels you have in your psd.
Example
pm.PyNode('myShader1PSD').alphaList.get()
# Result: [u'Alpha 1', u'Alpha 2'] #
If you know you'll only ever be using just the one alpha, or the first alpha channel, you can simply do this.
psdShader = pm.PyNode('myShader1PSD')
alphaList = psdShader.alphaList.get()
if (len(alphaList) > 0):
psdShader.alpha.set(alphaList[0])
else:
// No alpha channel
pass
Remember that lists start iterating from 0, so our first alpha channel will be located at position 0.
Additionally and unrelated, while you're still using derivative commands of the maya.core converted for Pymel, there's still some commands you can use to help make your code read nicer.
pm.setAttr('myShader1ColorPSD.fileTextureName', '<pathway>/myShader1_texture.psd', type='string')
We can convert this to pymel like so:
pm.PyNode('myShader1ColorPSD').fileTextureName.set('<pathway>/myShader1_texture.psd')
And:
pm.connectAttr('myShader1PSD.outColor', 'myShader1.color')
Can be converted to:
pm.connect('myShader1PSD.outColor', 'myShader1.color')
While they may only be small changes, it reads just the little bit nicer, and it's native PyMel.
Anyway, I hope I have helped you!

How to run Batch Photoshop Script to move layers X amount sequentially?

I have 70 layers in a photoshop file. I need to move X vertically, one after the other. So they'd look like:
>>Layer 1<<
>>Layer 2<<
>>Layer 3<<
Instead of just being stacked on top of each other. Not sure how to do this? Ideally, I should just specify an amount in pixels to Transform up.
A layer seems only be able to move with delta.
To move by delta use the MyLayer.transform(DeltaX,DeltaY); where MyLayer is a reference to the artLayer you want to move. The unit of DeltaX and DeltaY are the same as your Ruler in photoshop.
I wrote this little function to move a layer to an absolute position. I hope this will be of some use to you...
//******************************************
// MOVE LAYER TO
// Author: Max Kielland
//
// Moves layer fLayer to the absolute
// position fX,fY. The unit of fX and fY is
// the same as the ruler setting.
function MoveLayerTo(fLayer,fX,fY) {
var Position = fLayer.bounds;
Position[0] = fX - Position[0];
Position[1] = fY - Position[1];
fLayer.translate(-Position[0],-Position[1]);
}
Thanks a lot for this! Because of this tip I managed to complete a script that downloads/places (thousands of) map tiles... couldn't have done it without you ; )
I am new to 'Photoscripting' so I'd like to point out something (now obvious) that may also take other newbies than I a while to get: if you've calculated your 'fX' and 'fY' input through some mathematical means, be careful to explicitly add the unit you are using to your input number, otherwise you'll be placing things all over the place (waaaaaay off the canvas in my case ; P ).
Like this:
MoveLayerTo(myLayerRef, myX + "px", myY + "px").
Thanks a lot again, and cheers!

Resources