Sign in to follow this  
Followers 0
stuka

...

5 posts in this topic

#1 ·  Posted (edited)

.

Edited by stuka

Share this post


Link to post
Share on other sites



How do I pause a script right after I double-click it. I only want it to run(the loop) when I click on 'Start' under the context menu.

Thank you. :P

Huh? :)

There has to be some kind of loop going to detect user actions on your "context menu". When that loop detects 'Start' then it runs the other loop. Is "context menu" something from outside your script, like right click on a file in Explorer?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

the context menu will be the one when I right click my script icon at the task-bar

That context menu is not created by AutoIt, it's native to the Windows desktop environment. How do you propose to add "Start" to it?

Perhaps you mean the menu on the tray icon? That's very doable and there are plenty of demos on the forum and in the help file for that. Check out TrayCreateItem() and TrayCreateMenu(), with demo scripts, in the help file.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

yup, the 'menu on the tray icon'. I'm using the TrayCreateItem() function, but I can't figure out the script to pause the script once a user starts the script. My tray icon menu looks something like this:

About
-------
Start
Pause
-------
Add To Startup Registry
Remove From Startup Registry
-------
Exit

The script has to pause IMMEDIATELY after it is started.

I want it to run only after the user chooses to allow it to run. :)

That ALMOST makes good sense. All you need to do is get off the idea of "PAUSE" and think "looping, waiting for Start".

Here's a working demo:

Opt("TrayAutoPause", 0) ; Don't pause just because user opened menu

$StartItem = TrayCreateItem("Start")
TrayCreateItem("")
TraySetState()

MsgBox(64, "Begin", "Click Start in the tray menu...", 2)
Do
    Sleep(20)
Until TrayGetMsg() = $StartItem

ProgressOn("Tray Thang", "You clicked Start!  Working...")
For $n = 1 To 100
    ProgressSet($n)
    Sleep(20)
Next
Sleep(1000)
ProgressOff()

MsgBox(64, "Done", "Ta da!")

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

so it means, I'm gonna use the default menu as well?

Nope. I just used it to make the demo as minimal as possible. You can completely replace the Tray Items with your own, make some of them radio buttons, add submenus, etc. The sky's the limit.

My script was the least code I could think of that would pause until you clicked Start, then did something to show that it worked.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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