Sign in to follow this  
Followers 0
Arclite86

Want to make a new usefull UDF function need help

52 posts in this topic

#1 ·  Posted (edited)

I want to create a function in the firefox it needs to simulate a few key combinations

like :"ctrl+shift+b than 2x enter" I know how i can do this with the "sent " but I want  use it in the firefox udf, so the key combinations will be focused on the firefox browser even when the window is not actieve (minimized, running in the background) could somebody please help,

I think allot of other autoit users would be very glad with this new function.

Edited by Arclite86

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

For key presses you can use send. Read the helpfile for more info.

For more advance functions search "firefox udf" in the example scripts sub-forum.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

For key presses you can use send. Read the helpfile for more info.

For more advance functions search "firefox udf" in the example scripts sub-forum.

I have read the helpfile but it doesn't explane everything

and i have searched in the firefox udf

I have this:

Send("{LSHIFT}{LCTRL}{B}") 

but it doesn't work and no bookmark window is poping up what am I doing wrong?

Edited by Arclite86

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The helpfile explains everything.

[keys: The sequence of keys to send.]

'+'
This tells AutoIt to send a SHIFT keystroke, therefore Send("Hell+o") would send the text "HellO". Send("!+a") would send "ALT+SHIFT+a".

'^'
This tells AutoIt to send a CONTROL keystroke, therefore Send("^!a") would send "CTRL+ALT+a".

 

What you are doing is telling it to do: press (but not hold down) lshift, THEN press (but not hold down) lctrl, THEN press B. And, of course you have to make sure the window has focus.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

The helpfile explains everything.

 

What you are doing is telling it to do: press (but not hold down) lshift, THEN press (but not hold down) lctrl, THEN press B. And, of course you have to make sure the window has focus.

ok i have managed to open the bookmark window

but i want to run this program on the background so at the same time I can do something else

so like you said I need to focus it on the firefox window (so i can run it in the background)

I am searching for focus in the helpfile but nothing is coming up

could you please help or give me an example how to use focus for the firefox window

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If you want it to run in the background, you MUST use a Firefox UDF. You said you searched for it, but did you actually try anything? You not giving enough info to help you.

The alternative to using a UDF, not entirely in the background but may be sufficient,  is:

Get a handle to the current window

Give firefox focus, send your keys

Restore focus to the previous handle.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

If you want it to run in the background, you MUST use a Firefox UDF. You said you searched for it, but did you actually try anything? You not giving enough info to help you.

Ok,I already installed the  FF UDF and the bookmark pop up I know how to make a ff  window running in the background, But i want to know how i can focus the send("{}") function to the firefox window

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Send will not work without giving focus. Firefox does not have handles that would work with controlsend.

Think about what you are trying to accomplish with the send keys, odds are you can do it directly through the UDF. Only exception is if your trying to mess with flash or similar embedded software, then I think your screwed.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

Send will not work without giving focus. Firefox does not have handles that would work with controlsend.

Think about what you are trying to accomplish with the send keys, odds are you can do it directly through the UDF. Only exception is if your trying to mess with flash or similar embedded software, then I think your screwed.

Ok, using keys was just a gues to open the bookmark window, is there a other way to open the bookmark window ( or any other window) in firefox without using keys, so i can run firefox in the background and activate a bookmark.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Why do you need to use a bookmark, rather than navigating directly?

the bookmark is a code that activate's something for a website, when i click on it it will activate so i cant use a url, but is there a other way than using keys to click on this bookmark so i can run it in the background

this is the bookmark code:

javascript:(function(){var%20a=function(b,c,d){return%20a=document.getElementsByClassName?function(a,b,c){c=c||document;for(var%20g,d=c.getElementsByClassName(a),e=b?new%20RegExp('\\b'+b+'\\b','i'):null,f=[],h=0,i=d.length;i>h;h+=1)g=d[h],(!e||e.test(g.nodeName))&&f.push(g);return%20f}:document.evaluate?function(a,b,c){b=b||'*',c=c||document;for(var%20i,j,d=a.split('%20'),e='',f='http://www.w3.org/1999/xhtml',g=document.documentElement.namespaceURI===f?f:null,h=[],k=0,l=d.length;l>k;k+=1)e+='[contains(concat(\'%20\',%20@class,%20\'%20\'),%20\'%20'+d[k]+'%20\')]';try{i=document.evaluate('.//'+b+e,c,g,0,null)}catch(m){i=document.evaluate('.//'+b+e,c,null,0,null)}for(;j=i.iterateNext();)h.push(j);return%20h}:function(a,b,c){b=b||'*',c=c||document;for(var%20g,i,d=a.split('%20'),e=[],f='*'===b&&c.all?c.all:c.getElementsByTagName(b),h=[],j=0,k=d.length;k>j;j+=1)e.push(new%20RegExp('(^|\\s)'+d[j]+'(\\s|$)'));for(var%20l=0,m=f.length;m>l;l+=1){g=f[l],i=!1;for(var%20n=0,o=e.length;o>n&&(i=e[n].test(g.className),i);n+=1);i&&h.push(g)}return%20h},a(b,c,d)},b=function(a,b){if(-1==a.className.indexOf('x-grid3-row-selected')){var%20c=document.createEvent('MouseEvents');c.initMouseEvent('mousedown',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(c);var%20d=document.createEvent('MouseEvents');d.initMouseEvent('click',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(d)}};try{if(-1==window.location.href.indexOf('tweepi.com'))throw'';var%20c=document.createElement('script');c.textContent='window.fua();',(document.head||document.documentElement).appendChild(c),c.parentNode.removeChild(c);var%20d=a('x-grid3-rows','div',document.getElementById('tweepiGridDiv'));if(d.length<=0)return;b(d[0],!1),b(d[d.length-1],!0)}catch(e){alert('Something%20went%20wrong.%20Please%20make%20sure%20you%20are%20on%20a%20Tweepi.com%20page!%20'+e)}})();

could I also activate it with in autoit or will that be to hard, and how can i do that..?

Edited by Arclite86

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

When you have the url open try something like the following. I have no way to test it.

$sScript="javascript:{function...."
_FFCmd("content.wrappedJSObject." & $sScript)
Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

 

When you have the url open try something like the following. I have no way to test it.

$sScript="javascript:{function....")
_FFCmd("content.wrappedJSObject." & $sScript)

it give the error:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\joesoef pc\Desktop\autoit\firefox.au3" /UserParams    
+>23:17:45 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413  Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:C:\Program Files (x86)\AutoIt3
C:\Users\joesoef pc\Desktop\autoit\firefox.au3(115,1865) : ERROR: syntax error
$sScript="javascript:(function(){var%20a=function(b,c,d){return%20a=document.getElementsByClassName?function(a,b,c){c=c||document;for(var%20g,d=c.getElementsByClassName(a),e=b?new%20RegExp('\\b'+b+'\\b','i'):null,f=[],h=0,i=d.length;i>h;h+=1)g=d[h],(!e||e.test(g.nodeName))&&f.push(g);return%20f}:document.evaluate?function(a,b,c){b=b||'*',c=c||document;for(var%20i,j,d=a.split('%20'),e='',f='http://www.w3.org/1999/xhtml',g=document.documentElement.namespaceURI===f?f:null,h=[],k=0,l=d.length;l>k;k+=1)e+='[contains(concat(\'%20\',%20@class,%20\'%20\'),%20\'%20'+d[k]+'%20\')]';try{i=document.evaluate('.//'+b+e,c,g,0,null)}catch(m){i=document.evaluate('.//'+b+e,c,null,0,null)}for(;j=i.iterateNext();)h.push(j);return%20h}:function(a,b,c){b=b||'*',c=c||document;for(var%20g,i,d=a.split('%20'),e=[],f='*'===b&&c.all?c.all:c.getElementsByTagName(b),h=[],j=0,k=d.length;k>j;j+=1)e.push(new%20RegExp('(^|\\s)'+d[j]+'(\\s|$)'));for(var%20l=0,m=f.length;m>l;l+=1){g=f[l],i=!1;for(var%20n=0,o=e.length;o>n&&(i=e[n].test(g.className),i);n+=1);i&&h.push(g)}return%20h},a(b,c,d)},b=function(a,b){if(-1==a.className.indexOf('x-grid3-row-selected')){var%20c=document.createEvent('MouseEvents');c.initMouseEvent('mousedown',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(c);var%20d=document.createEvent('MouseEvents');d.initMouseEvent('click',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(d)}};try{if(-1==window.location.href.indexOf('tweepi.com'))throw'';var%20c=document.createElement('script');c.textContent='window.fua();',(document.head||document.documentElement).appendChild(c),c.parentNode.removeChild(c);var%20d=a('x-grid3-rows','div',document.getElementById('tweepiGridDiv'));if(d.length<=0)return;b(d[0],!1),b(d[d.length-1],!0)}catch(e){alert('Something%20went%20wrong.%20Please%20make%20sure%20you%20are%20on%20a%20Tweepi.com%20page!%20'+e)}})();")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~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~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\joesoef pc\Desktop\autoit\firefox.au3 - 1 error(s), 0 warning(s)
!>23:17:45 AU3Check ended. Press F4 to jump to next error.rc:2
+>23:17:45 AutoIt3Wrapper Finished..
>Exit code: 2    Time: 0.464

on the line:

$sScript="javascript:(function(){var%20a=function(b,c,d)..........")

What do i need to with this?

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

You double quote is in the wrong place.

yes i saw it ^_^

i already chanced it, i dont get an error anymore but nothing is happening ..

is there maybe an other way to activate this script, because the code is 100% working so thats not the problem

Edited by Arclite86

Share this post


Link to post
Share on other sites

I have a javascript but i want to run it on autoit how do I do that

script:

javascript:(function(){var%20a=function(b,c,d){return%20a=document.getElementsByClassName?function(a,b,c){c=c||document;for(var%20g,d=c.getElementsByClassName(a),e=b?new%20RegExp('\\b'+b+'\\b','i'):null,f=[],h=0,i=d.length;i>h;h+=1)g=d[h],(!e||e.test(g.nodeName))&&f.push(g);return%20f}:document.evaluate?function(a,b,c){b=b||'*',c=c||document;for(var%20i,j,d=a.split('%20'),e='',f='http://www.w3.org/1999/xhtml',g=document.documentElement.namespaceURI===f?f:null,h=[],k=0,l=d.length;l>k;k+=1)e+='[contains(concat(\'%20\',%20@class,%20\'%20\'),%20\'%20'+d[k]+'%20\')]';try{i=document.evaluate('.//'+b+e,c,g,0,null)}catch(m){i=document.evaluate('.//'+b+e,c,null,0,null)}for(;j=i.iterateNext();)h.push(j);return%20h}:function(a,b,c){b=b||'*',c=c||document;for(var%20g,i,d=a.split('%20'),e=[],f='*'===b&&c.all?c.all:c.getElementsByTagName(b),h=[],j=0,k=d.length;k>j;j+=1)e.push(new%20RegExp('(^|\\s)'+d[j]+'(\\s|$)'));for(var%20l=0,m=f.length;m>l;l+=1){g=f[l],i=!1;for(var%20n=0,o=e.length;o>n&&(i=e[n].test(g.className),i);n+=1);i&&h.push(g)}return%20h},a(b,c,d)},b=function(a,b){if(-1==a.className.indexOf('x-grid3-row-selected')){var%20c=document.createEvent('MouseEvents');c.initMouseEvent('mousedown',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(c);var%20d=document.createEvent('MouseEvents');d.initMouseEvent('click',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(d)}};try{if(-1==window.location.href.indexOf('tweepi.com'))throw'';var%20c=document.createElement('script');c.textContent='window.fua();',(document.head||document.documentElement).appendChild(c),c.parentNode.removeChild(c);var%20d=a('x-grid3-rows','div',document.getElementById('tweepiGridDiv'));if(d.length<=0)return;b(d[0],!1),b(d[d.length-1],!0)}catch(e){alert('Something%20went%20wrong.%20Please%20make%20sure%20you%20are%20on%20a%20Tweepi.com%20page!%20'+e)}})();

Share this post


Link to post
Share on other sites

How about a little more explanation, such as why you feel the need to mix languages? Or what you are trying to accomplish on Tweepi? Help us help you.

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

How about a little more explanation, such as why you feel the need to mix languages? Or what you are trying to accomplish on Tweepi? Help us help you.

Ok this is a tweepi function created by tweepi fans ( its legal) I can run this script using this code:

Send("{LSHIFT}^{LCTRL}^{B}")
Send("{ENTER}")
Send("{ENTER}")

but when this script is running I want to do something different at the same time ( this function can run for hours) and the code above is not focused on the firefox window

so when I run the firefox window in the background the "send" code above will not work because its runnning in the background and its not focused but if i could focus the "send"would also be great

Share this post


Link to post
Share on other sites

Being unfamiliar with tweepi, what is the purpose of the function? I can't see why you would have to switch back and forth between AutoIt and javascript.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0