AutoHotkey Community

It is currently May 25th, 2012, 10:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Reset ahk
PostPosted: July 6th, 2007, 6:47 pm 
Offline

Joined: May 16th, 2007, 3:24 pm
Posts: 11
I have an ahk application that use GUI as a user panel. If the user press one button, one script will run.
Sometimes the script is get stuck because of other aspect than the application itself. I would like to know is there any way to reset the script without exiting the application?

What I meant is really resetting the script (maybe by stopping the current thread?), not breaking from loop or something like that.

I already try to search in this forum, and also in the help file, but I can't find it (or maybe I haven't try hard enough??)...

thank a lot


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2007, 6:51 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Is Reload what you're looking for?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2007, 7:54 pm 
Offline

Joined: May 16th, 2007, 3:24 pm
Posts: 11
I think Reload will reset the whole application, just like do close and re-open it... am I right?.. If I do that, it will reset the memory inside my application.

What I am looking for is the function to reset only the script that is running.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2007, 8:08 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
perhaps store the variables you need somewhere and then use reload and then retrieve those values?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2007, 8:31 pm 
Offline

Joined: May 16th, 2007, 3:24 pm
Posts: 11
ok... let's make this a little bit more clear... it's more than just a variable..

for example my application has an embedded Windows Media Player, and right now it's playing a song... and I press a button to search song in my computer, so another thread will be created to do it... and sometimes it get stuck...

If I use reload... it will stop everything, including my song... and I dont want that to happen.. and i dont want to hear it from the beginning as well...

you've got what i mean?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2007, 8:51 pm 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
Well if the script is persistent then

Code:
exit


Will exit the current thred, but it needs to be called by the thread itself.

If its getting stuck in a loop, then you can set an option to break if a certain condition is true. ie

Code:
Loop
{
If stuck
break
}

#b::
stuck:=1
return

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2007, 9:19 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
it would be very helpful if you could post some example code, but it sounds like all you need to do is have a break within a loop and then have a return after the loop in order to go back to exactly where it was

yeh basically what fraggle said


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2007, 10:06 pm 
Offline

Joined: May 16th, 2007, 3:24 pm
Posts: 11
maybe the exit is what i'm looking for, but is that any way to call it from another thread, let say by pressing a button, to close another thread?

the problem in my application is not in ahk script itself, but it calls another application, and that application is the one who get stuck. but because of my ahk application waiting for the result, it seems like it stop there.
for example it get stuck here
Code:
 
searchSong:
   mySong=birdsong
   myResult:=Run('otherapplication.exe','%mySong%')
   if myResult
       Add('birdsong')
Return

and if something like this happen, I would like to reset it simply just pressing one button...
but pls dont tell me to put an error trap there, because that's not what i mean...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 12:00 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
Code:
myResult:=Run('otherapplication.exe','%mySong%')


i didn not realise that such a thing was possible or necessary. could you show me where there is run() in the documentation?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 12:44 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
boge wrote:
the problem in my application is not in ahk script itself, but it calls another application, and that application is the one who get stuck.

Well why didn't you say so earlier? Image

If it's an external app you want to kill, this is what you do. When you run it:
Code:
Run, MyApp.exe, , , OutputVarPID

Then to kill it:
Code:
Process Close, %OutputVarPID%


Last edited by ManaUser on July 7th, 2007, 12:52 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 12:49 am 
Offline

Joined: May 16th, 2007, 3:24 pm
Posts: 11
run() in that "example" is my own function to call external application...
and i believe that the one that get stuck is the "otherapplication.exe"... since that application is not mine, so i can't do anything with it...
what i want to do is just to be able to reset my script...

Quote:
If it's an external app you want to kill, this is what you do.

i can't do this.. this is only one example...

pls guys... i just want to be able to reset... not to solve the problem with any other ways...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 12:53 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
What do you mean you can't do it? Why give us examples that dont' have anything to do with the real problem?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 1:12 am 
Offline

Joined: May 16th, 2007, 3:24 pm
Posts: 11
I mean... that's not the only external application that i used...
in my other subprogram, i run another application...
and like i said earlier... i also have embedded program (like the windows media player) in my application...

the problem is... from all of those "external" things... i dont know in which application it get stuck... and to kill the specific one means that i have to know exactly in which part my ahk application get stuck... am i right??
and i dont have that luxury to have an error trap for each of them...

that's why, i would like to be able just simply reset it...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 1:23 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Well what if you laucnhed a seperate autohotkey script to do the part that gets stuck then?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 2:56 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
Quote:
the problem is... from all of those "external" things... i dont know in which application it get stuck... and to kill the specific one means that i have to know exactly in which part my ahk application get stuck... am i right??
and i dont have that luxury to have an error trap for each of them...


its like trying to squeeze blood from a stone this :)
i dont really understand anything of what you are saying.....
why cant you find out where it gets stuck?
why dont you have the luxury of having error messages. just put a tooltip after each command in your script with the values expected and see what happens. i dont believe theres a program that cant output variables

Code:
run() in that "example" is my own function to call external application...


and i didnt know that as you didnt post the function


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], kiropes, Yahoo [Bot] and 66 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group