Jump to content
Sign in to follow this  
helzin

Make the script run in background

Recommended Posts

helzin

Hello everyone!

I've just started to learn AutoIt, and I'm not very good at it, so I need some help with a script. I've build this scrit that pressing buttoms in Firefox, it mostly uses MouseClick and Send, so it's really easy made, so here to my question, how do I make this script work in the background? (So I can do other stuff meanwhile the script is running) If you need to see the code I can post it aswell :)

Share this post


Link to post
Share on other sites
Andreik

If your script doesn't have a GUI or run other programs(with GUIs), #NoTrayIcon should be enough.

If you post your code is much better, we can help you more.

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
helzin

CODE
While 1

Sleep(1000)

MouseClick("Main", 404, 501)

Sleep(2000)

MouseClick("Main", 396, 66)

Sleep(200)

$x = Iniread("links.ini", $section, "x", 9999)

sleep(200)

if $x = 9999 Then

Exitloop

EndIf

send($x)

sleep(800)

Send("{enter}")

$section = $section + 1

WEnd

That's my simple code :)

Share this post


Link to post
Share on other sites
Andreik

CODE
While 1

Sleep(1000)

MouseClick("Main", 404, 501)

Sleep(2000)

MouseClick("Main", 396, 66)

Sleep(200)

$x = Iniread("links.ini", $section, "x", 9999)

sleep(200)

if $x = 9999 Then

Exitloop

EndIf

send($x)

sleep(800)

Send("{enter}")

$section = $section + 1

WEnd

That's my simple code :)

Now define what mean for you "run in background". What should be hide? Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
helzin

I want the whole script to run in the background, so I can for example look at movie or do anything I want. So the script should be able to do stuff in the background without that I get disturbed, as it is now it moves the mouse, so I can't do anything while the script is running. I've been thinking of use ("{tab}") to no have to use MouseClick, but I don't think that's the best way to do it. And I still don't know how to do it so it can run in background.

Thank you for helping.

Share this post


Link to post
Share on other sites
Andreik

I want the whole script to run in the background, so I can for example look at movie or do anything I want. So the script should be able to do stuff in the background without that I get disturbed, as it is now it moves the mouse, so I can't do anything while the script is running. I've been thinking of use ("{tab}") to no have to use MouseClick, but I don't think that's the best way to do it. And I still don't know how to do it so it can run in background.

Thank you for helping.

If the place where you want to click are some control you can use ControlClick() instead MouseClick() and ControlSend() instead Send(). Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
helzin

Hmm, seems to work, partially, I get it to work sometimes, it works in skype, then it can write stuff to my friends, and I don't notice it. But when I'm trying to use it in Internet Explorer nothing happends, do you know why?

Share this post


Link to post
Share on other sites
helzin

I wonder if you can give me an example if this commands, like how to use it in Mozilla firefox. It should target the box where you enter the address to a homepage, then enter the address and press enter to enter the page. I'm trying to use this, but without success.

CODE

ControlClick ( "Mozilla Firefox", "text", controlID [, "main" [, 1 [, 537 [, 68 ]]]] )

Sleep(12)

ControlSend ( "Mozilla Firefox", "", controlID, "www.google.se" [, flag = 0] )

Sleep(12)

I get a error:

CODE
ControlClick ( "Mozilla Firefox", "text", [, "main" [, 1 [, 537 [, 68 ]]]] )

ControlClick ( "Mozilla Firefox", "text", ^ ERROR

And there is no controlID in Window Info when I'm targeting Mozilla, why?

Edited by helzin

Share this post


Link to post
Share on other sites
Jos

You are supposed to remove the Square brackets. They are an indication for optional parameters...

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
helzin

Thanks, I'm still not getting it to work thought, this is what I've done, I have opened Mozilla Firefox and wrote in google.com, now I want the script to search on stuff for me, just to write in something and then press enter. This is what I've tryed with;

ControlClick ( "Google - Mozilla Firefox", "", controlID , main, 1, 566, 383)

Sleep(100)

ControlSend ( "Google - Mozilla Firefox", "", controlID, "help me")

Sleep(12)

controlsend ( "Google - Mozilla Firefox", "",controlID, "{enter}")

This is the error I get:

>"C:\Program\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\didbjo01\Skrivbord\asd.au3"

C:\Documents and Settings\********\Skrivbord\asd.au3 (1) : ==> Missing separator character after keyword.:

ControlClick ( "Google - Mozilla Firefox", "", controlID , main, 1, 566, 383)

ControlClick ( "Google - Mozilla Firefox", "", controlID , main^ ERROR

>Exit code: 1 Time: 0.210

Share this post


Link to post
Share on other sites
Jos

Maybe it helps when you study the examples shown in the helpfile.

where you have controlID and main you should specify a proper value or variable.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
FireFox

@helzin

Take a look to FF.au3 udf (firefox udf) in example scripts forum, then you will be able to do what you want with firefox :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.