AutoHotkey Community

It is currently May 27th, 2012, 6:10 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: November 27th, 2005, 10:27 am 
Offline

Joined: June 1st, 2005, 12:36 pm
Posts: 174
Hi,

my AutoHotkey.ini contains lots of hotstrings and tiny scripts, but only recently I noticed that some aren't working correctly when I move them more to the bottom of AutoHotkey.ini - what could be the cause?

Did I miss something in these two scripts?

This script should open an URL in IE once a day but only does so now when moved to the top of AutoHotkey.ini:
Code:
SetTimer, DBHT, 540000
return
DBHT:
IfNotExist,D:\files\program files\Autohotkey\DBHT_%A_YYYY%-%A_MM%-%A_DD%.txt
  Run,IExplore.exe http://www.bla.com/index.html
  FileCopy,D:\files\program files\Autohotkey\!info.txt,D:\files\program files\Autohotkey\DBHT_%A_YYYY%-%A_MM%-%A_DD%.txt
Return



Code:
;remotely run and quit Ghoster.exe
^+p::
Process, Exist, Ghoster.exe
pid=%ErrorLevel%
If pid=0
  Run,D:\files\program files\Autohotkey\Ghoster.exe
Else
  WinClose, Ghoster
Return


Actually, when I just moved these scripts around in AutoHotkey.ini I was only able to confirm problems with the first of these two scripts - two days ago I wasn't able to get the second to close the Ghoster process when the script was further down AutoHotkey.ini - very strange....

_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2005, 4:55 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
The top of the Scripts page describes the auto-execute section. I think it explains the behavior you're seeing.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2005, 10:33 am 
Offline

Joined: June 1st, 2005, 12:36 pm
Posts: 174
Hmm... I read that and tried to understand. I added #Persistent to the scripts in AutoHotkey.ini since that was the only conclusion that I came up with, but it's still not working :(

Isn't it possible to have more than x scripts in AutoHotkey.ini?

_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2005, 10:58 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Try this in your ini file, it will allow multiple auto-exec sections to be executed. So the included scripts should work.
Code:
;[...]
GoSub, AutoExecScript1
GoSub, AutoExecScript3
GoSub, AutoExecScript3
return ; end autoexec of main script

AutoExecScript1:
#Include Script1.ahk

AutoExecScript2:
#Include Script2.ahk

AutoExecScript3:
#Include Script3.ahk

;[...]
;end of main script

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2005, 12:18 pm 
Offline

Joined: June 1st, 2005, 12:36 pm
Posts: 174
Aaaaah, now I get it! :D

Thanks a lot, AutoHotkey is fun again! :) Maybe this example should be added to "The Auto-execute Section" on http://www.autohotkey.com/docs/Scripts.htm ?

_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 28th, 2005, 7:59 pm 
Offline

Joined: June 1st, 2005, 12:36 pm
Posts: 174
brotherS wrote:
[...]
Code:
;remotely run and quit Ghoster.exe
^+p::
Process, Exist, Ghoster.exe
pid=%ErrorLevel%
If pid=0
  Run,D:\files\program files\Autohotkey\Ghoster.exe
Else
  WinClose, Ghoster
Return


Actually, when I just moved these scripts around in AutoHotkey.ini I was only able to confirm problems with the first of these two scripts - two days ago I wasn't able to get the second to close the Ghoster process when the script was further down AutoHotkey.ini - very strange....

I guess I was too happy too soon... after restarting Windows, this tiny script works only partly AGAIN! :?

It does start Ghoster.exe but doesn't close it anymore when that hotkey is used again... :( Any ideas?

_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2005, 10:29 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
maybe you have to use DetectHiddenWindows. Just a guess

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2005, 12:13 pm 
Offline

Joined: June 11th, 2005, 9:34 am
Posts: 264
Location: England ish
to test it, why don't you make it send a msgBox, and confirm what is not working if its the script's content or the synatax.

but hey i like the gosub solution, solved some of my problems as well ^_^

_________________
::
I Have Spoken
::


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 29th, 2005, 5:43 pm 
Offline

Joined: June 1st, 2005, 12:36 pm
Posts: 174
brotherS wrote:
Code:
;remotely run and quit Ghoster.exe
^+p::
Process, Exist, Ghoster.exe
pid=%ErrorLevel%
If pid=0
  Run,D:\files\program files\Autohotkey\Ghoster.exe
Else
  WinClose, Ghoster
Return


:? :? :?
Damn, I just CAN'T get this to work again! Neither DetectHiddenWindows nor various other things I tried were helping... :x

I confirmed with "MsgBox, test" that the script itself IS working, it just won't close the process!

I then tried to use Ghoster.exe (that's its name in the Task Manager) there instead of just Ghoster, together with the "process" command instead of WinClose, but that didn't work either

I then tried to use the full path for the Ghoster.exe and the "process" command - same result :(

...

I then cursed a bit more and tried this:
Code:
^+o::
DetectHiddenWindows, On
Process, Close, fdm.exe
return


fdm.exe is another running exe but - again - the process command won't work!

...

A few more minutes passed while I tried several things - and suddently BOTH triggers were working correctly?!? Any explanation? Anyone?

What follows is the working version of the script, I really hope it will continue to work - but why isn't it removing Ghoster's tray icon when it closes the process? :?

Code:
;2005-11-29
;remotely run and quit Ghoster.exe
#Persistent
^+p::
DetectHiddenWindows, On
Process, Exist, Ghoster.exe
pid=%ErrorLevel%
If pid=0
  Run, D:\Eigene Dateien\program files\Autohotkey\Ghoster.exe
Else
  Process, Close, Ghoster.exe
Return

_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 30th, 2005, 2:45 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
brotherS wrote:
why isn't it removing Ghoster's tray icon when it closes the process?
Some apps don't respond properly to WinClose. You might try sending an Alt-F4 keystroke to the window instead; that is, Send !{F4}. If that doesn't work, you might try WinMenuSelectItem to exit the application (if its window has a standard menu bar).


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 30th, 2005, 4:42 pm 
I'm using "Process, Close, Ghoster.exe" now but that isn't removing the tray icon. I tried it with "Send !{F4}" but was not really sure how to really send it to the process in question - result: didn't work. :?

Maybe the problem is that Ghoster.exe creates no own window but only its icon sits in the tray?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2005, 1:20 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Since you're using "Process Close", that will abruptly terminate the specified process as described in the documentation. Terminated processes do not have a chance to save documents, remove tray icons, or do other cleanup activities.

It sounds like you've already tried DetectHiddenWindows+WinClose and other tricks, so I'm not sure what else to suggest other than Rajat's SendMessage Tutorial (which might also help determine whether the process owns any windows).


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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