AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to set correct icon for MsgBox ?
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Zippo()
Guest





PostPosted: Fri Jun 20, 2008 10:48 am    Post subject: Reply with quote

Try clearing your prefetch folder (C:\WINDOWS\Prefetch) of anything related to AHK or that script between runs and see if that stops it...
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Fri Jun 20, 2008 12:24 pm    Post subject: Reply with quote

CMark wrote:
So, it doesn't seem to be problem with old RAM data.

You have to always tell which OS you're using when reporting a problem. Icon is cached for faster access later, and stored in IconCache.db which is usually set to hidden. And I suspect the problematic side is more or less AHK's compiler than Windows in this case, but I've never compiled scripts so can't really tell.
Back to top
View user's profile Send private message
CMark
Guest





PostPosted: Fri Jun 20, 2008 2:31 pm    Post subject: Reply with quote

Sean wrote:

You have to always tell which OS you're using when reporting a problem. And I suspect the problematic side is more or less AHK's compiler than Windows in this case, but I've never compiled scripts so can't really tell.


CMark wrote:

Well I tried this on several XP Pc computers.
It always has this problem.


So, as you can see/read, OS is Windows XP.

Sean wrote:

And I suspect the problematic side is more or less AHK's compiler than Windows in this case, but I've never compiled scripts so can't really tell.


When I tried AHK01.EXE on other copmputers
I didn't compile it again.
I simple used 2 versions of AHK01.EXE compiled on the first XP PC computer.
I first executed version-1 AHK01.EXE (version with msnms.ico icon).
It works OK (it has same icon for AHK01.EXE and for MsgBox).
Then I copied version-2 over version-1.
When I execute version-2 AHK01.EXE (version with COMPUTER.ICO icon)
it has correct icon in systray(COMPUTER.ICO)
but MsgBox still has msnms.ico icon (on the taskbar button).

So, the problematic side shouldn't be AHK's compiler.

Also, you can see:
Mike wrote:

You can even copy some quite other AHK exe file
over that first one
MsgBox icon stays same.


Anyway, it's quite easy to try any of this.
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Fri Jun 20, 2008 2:51 pm    Post subject: Reply with quote

CMark wrote:
So, as you can see/read, OS is Windows XP.

Read again when reporting a problem. You should've said it in your first post.

Quote:
So, the problematic side shouldn't be AHK's compiler.

Have you experienced the problem with other applications? You may experiment with notepad.exe and mspaint.exe. After copying them to some other place, rename (say to test.exe) and execute each after each. The same symptom? I have some conjecture on this, but it's solely a guess I better not tell.

Anyway, try the second one after search and delete the IconCache.db.
Back to top
View user's profile Send private message
CMark
Guest





PostPosted: Fri Jun 20, 2008 3:12 pm    Post subject: Reply with quote

Sean wrote:

Have you experienced the problem with other applications? You may experiment with notepad.exe and mspaint.exe. After copying them to some other place, rename (say to test.exe) and execute each after each. The same symptom? I have some conjecture on this, but it's solely a guess I better not tell.


No, problem is only for the MsgBox icon for AutoHotkey's EXE files.

Sean wrote:

Anyway, try the second one after search and delete the IconCache.db.


It doesn't help.
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Fri Jun 20, 2008 3:19 pm    Post subject: Reply with quote

CMark wrote:
It doesn't help.

The cached icon isn't saved to IconCache.db immediately. And IconCache.db is user-based, so be sure to delete the currently logged-on user's one. To see if it's really related to IconCache.db, try the second one after reboot, or at least logoff and re-logon, and delete it.
Back to top
View user's profile Send private message
CMark
Guest





PostPosted: Fri Jun 20, 2008 3:54 pm    Post subject: Reply with quote

@Sean

I did it that way.

But now I tried something else.
I renamed IconCache.db to IconCache.db000.
Then I switch off pc.
Then I start PC again.
There was not IconCache.db this time.

Then I tried second AHK01.EXE.

This time MsgBox icon was OK (same as AHK01.EXE icon).

So, it seems this work.
Not so nice procedure although.
Is there some better way to fix problem when EXE icon changed?
Is this kind of problem specific to AutoHotkey and why?
Back to top
CMark
Guest





PostPosted: Fri Jun 20, 2008 4:29 pm    Post subject: Reply with quote

Thanks to all
and, of course, especially to Sean Cool Cool Cool
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Fri Jun 20, 2008 4:29 pm    Post subject: Reply with quote

CMark wrote:
Is there some better way to fix problem when EXE icon changed?
I don't know, but one possible method may be to always delete/move/rename the first one before copying the second one, hoping Windows/Shell catches it and thus revokes the previously cached icon, but not much possibility as it already ignores overwrite.

Quote:
Is this kind of problem specific to AutoHotkey and why?

I'd like to make it clear that the following is my pure guess. To make it short, I reckon AHK is somehow ignorant/irresponsive to some requests, like about hIcon to be used in the task button so make Shell resort to the cached one when available. One thing I'm not sure is if it always behaves so or only when displaying MsgBox. Have you ever tried with AHK's GUI windows and observed the same symptom?

PS. I found an API which I believe can update the cached icons: Shell_GetCachedImageIndex. You may call it before displaying the MsgBox.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Sat Jun 21, 2008 3:36 am    Post subject: Reply with quote

CMark wrote:
Is this kind of problem specific to AutoHotkey and why?

I think I found out the reason. I opened AutoHotkey.exe in ResHacker and found to my surprise that the main/first icon group consists of a large icon only! So, AHK's resource table will only report the exsistence of the large icon, i.e. the absence of the small icon. I assume it's the same with the AHK compiler. It'll give the shell a trouble to retrieve the small icon to be used in the task button. So if a cached one is found then use it, otherwise it has to create the small icon from the large icon.

In case of the tray icon, it's actually AHK itself, not the shell, which will specify the (large or small) icon to be used in the tray, so it'll certainly not resort to the IconCache, so there will be no problem.
Back to top
View user's profile Send private message
CMark
Guest





PostPosted: Sat Jun 21, 2008 5:09 am    Post subject: Reply with quote

Thanks Sean Very Happy Very Happy Very Happy
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Sat Jun 21, 2008 5:57 am    Post subject: Reply with quote

No problem. It's still a guess, and I like to guess. Wink
BTW, now I have two candidates I decided to actually test them. The result was that the symptom was manifested only with MsgBox, including MessageBox API via DllCall. When I tested with AHK's GUI the task button's icon was correctly updated. Still not sure of which side's fault though.
Back to top
View user's profile Send private message
Mike"
Guest





PostPosted: Sat Jun 21, 2008 6:29 am    Post subject: Reply with quote

Sean wrote:

Have you ever tried with AHK's GUI windows and observed the same symptom?


I've tried a lot of examples.
I've never had this problem with AHK's GUI windows.
I've also never had this problem with AHK's InputBox and Progress either.

My guess is that AHK creates windows for GUI/InputBox/Progress
and always specify correct icon for that.

And for MsgBox, I guess, AHK just call the Windows OS function.
When OS creates a window for MsgBox, it also specify correct (caller's) icon,
as far as you don't change EXE's icon.
But, if caller's (EXE) icon is changed, OS continue to use old icon for MsgBox window.
Is this a Windows bug, or is somehow AHK EXE incorrect, I can't tell.
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Sat Jun 21, 2008 8:15 am    Post subject: Reply with quote

All of these GUI/InputBox/Progress/MsgBox call OS functions. I think the difference of MsgBox is that it's provided/controlled directly by the system itself, so, in a certain sense, not quite a window of the application. That might be the root of this icon problem. The best solution, to my personal taste, is to make the msgbox genuinely an owned window so that no task button appear for it and give it OnTop style.
Code:
DetectHiddenWindows On
Process, Exist
WinGet, hWnd, ID, ahk_class AutoHotkey ahk_pid %ErrorLevel%
DllCall("MessageBox","Uint", hWnd, "str", "OK", "str", "AutoHotkey", "Uint", MB_TOPMOST:=0x40000)
Back to top
View user's profile Send private message
Mike"
Guest





PostPosted: Sat Jun 21, 2008 10:49 am    Post subject: Reply with quote

Sean wrote:
All of these GUI/InputBox/Progress/MsgBox call OS functions. I think the difference of MsgBox is that it's provided/controlled directly by the system itself, so, in a certain sense, not quite a window of the application. That might be the root of this icon problem. The best solution, to my personal taste, is to make the msgbox genuinely an owned window so that no task button appear for it and give it OnTop style.
Code:
DetectHiddenWindows On
Process, Exist
WinGet, hWnd, ID, ahk_class AutoHotkey ahk_pid %ErrorLevel%
DllCall("MessageBox","Uint", hWnd, "str", "OK", "str", "AutoHotkey", "Uint", MB_TOPMOST:=0x40000)




Well, Sean, an interesting idea.
But I guess you didn't try it all the way (compile+icon1/execute/compile+icon2/execute).
This script has same icon problem for MsgBox icon as AHK01.EXE with simple "MsgBox icon test"
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group