Sign in to follow this  
Followers 0
Xander

WinGetPos on a GUIcreated object

10 posts in this topic

#1 ·  Posted (edited)

I've been scripting for a while but rarely touch GUIs. I'm writing a script that performs computer maintenance operations (defrag, cleanup, AV scans, etc) and trying to implement a GUI to have it provide feedback on task completions. I'm using GUICtrlSetData to add a line to the gui when a task is done. I've been using Tooltip("Starting ___ task",0,0) partly for troubleshooting but I want to move it to the titlebar of the GUI. Once the script has passed all of its tests, I'll probably take out the Tooltips altogether but, for the moment, I'd like to understand why it's not working.

Dim $win[4]
 
 
Local $hEventLog, $hGUI, $aEvent
$hGUI = GUICreate("EventLog", 400, 300) ;GUI is from the Help file
$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
 
 
Exit
Func Tip($text)
    $win=WinGetPos("Eventlog") ;Au3info confirms this as the window's name, too
    If not @error then Tooltip($text,$win[0]+30,$win[1]+3)  ;seems to always fail.  WHY?
EndFunc
Edited by Xander

Share this post


Link to post
Share on other sites



WTH!? I added a GUICtrlSetData line at the end of the Func and suddenly it's working. HUH?

And, if I then rem the same line out... it still works. Aaaargh. It's now no different than it was before I wrote the above post but now it's working.

Share this post


Link to post
Share on other sites

You dont have any kind of main loop so the program creates the gui and then exits right after. Your tip function never gets called so I dont know why it would fail. Use the handle from guicreate() in WinGetPos() instead of the title. Also its not wrong but you dont need to create $win as an array. WinGetPos() will do it for you.

Dim $win
 
Local $hEventLog, $hGUI, $aEvent
$hGUI = GUICreate("EventLog", 400, 300) ;GUI is from the Help file
$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
 
Tip('Test')
 
Do
Until GUIGetMsg() = -3
 
Func Tip($text)
    $win=WinGetPos($hGUI) ;Au3info confirms this as the window's name, too
    If not @error then Tooltip($text,$win[0]+30,$win[1]+3)  ;seems to always fail.  WHY?
EndFunc

Share this post


Link to post
Share on other sites

What I listed wasn't the entirety of the script. I didn't think you wanted 620 lines of code but the few that weren't working.

"Tip" was getting called but, for some reason, decided not to work until after I'd posted here.

Seriously, it's no different than it had been but now it's working.

Share this post


Link to post
Share on other sites

No where in you post did you state that this is a "portion" or your 620 lines of code. Why you posted parts of your code that your not having any problems with is whats confusing me.

Share this post


Link to post
Share on other sites

Why would I do that? I posted the most relevant portions of code. I said in my first post that the script does a lot of things whereas the portion I posted clearly did none of those.

Regardless, your suggestion to use the Function I'd written was wholly and completely invaluable.

Share this post


Link to post
Share on other sites

Why would I do that?

Because you are in a HELP forum. And when you say things like "I rarely touch GUIs" and " I'd like to understand why it's not working." people are going to look at the broken ass code you posted and try to get it to work. That is unless you clarify that you already know what you posted doesn't work.

I posted the most relevant portions of code.

Out of your 620 lines of code that was the most relevant?

I said in my first post that the script does a lot of things whereas the portion I posted clearly did none of those.

The code you posted did nothing.

Regardless, your suggestion to use the Function I'd written was wholly and completely invaluable.

Wow.. I completely agree. A suggestion to use the function written by you is completely invaluable.
1 person likes this

Share this post


Link to post
Share on other sites

You missed the sarcasm, apparently. I was implying that you were being a pretentious tool.

Share this post


Link to post
Share on other sites

@Xander you should post a working replicator of the issue, as far i can see is that your main problem is that your script exit in the 11 line :S , in that case i will send you to read tutorials and the help file because it seems like noob mistakes. I agree with Beege in that point. Is Ilogic ask for help with a code like yours.

Share this post


Link to post
Share on other sites

You missed the sarcasm, apparently. I was implying that you were being a pretentious tool.

A pretentious tool? No I dont think so. Perhaps a fool for trying to help a dumb ass that thinks his code magically fixed itself.

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