 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Klaus
Joined: 12 May 2005 Posts: 205 Location: Münster, Germany
|
Posted: Mon May 26, 2008 8:16 am Post subject: ControlGetText doesn't work after hotkey pressed |
|
|
Hi, Community,
have a look please at my little code snippet that I isolated from a bigger application:
| Code: | HotKey, !a, myLabel
Gui, Add, Edit, w100 h20 vmyEdit,10
Gui, Add, Button, gmyLabel, Add
Gui, show
return
myLabel:
ControlGetText, tmpMyEdit, Edit1
if (Errorlevel != 0)
MsgBox, %Errorlevel%
newMyEdit := tmpMyEdit + 10
GuiControl,, Edit1, %newMyEdit%
return
|
There is a little gui with an edit field, initially filled with the numeric value of 10.
Pressing the button there will be added 10 to the current content of my edit field.
But using the alt-a hotkey which launches the same label like the pressed button, the ControlGetText fails and the expression "newMyEdit ..." won't work and the following GuiControl... blanks the control.
Could anyone help?
Thanks in advance,
Klaus |
|
| Back to top |
|
 |
Guest
|
Posted: Mon May 26, 2008 9:03 am Post subject: |
|
|
| Code: | HotKey, !a, myLabel
Gui, +LastFound
Gui, Add, Edit, w100 h20 vmyEdit,10
Gui, Add, Button, gmyLabel, Add
Gui, show,,blah
return
myLabel:
ControlGetText, tmpMyEdit, Edit1,blah
if (Errorlevel != 0)
MsgBox, %Errorlevel%
newMyEdit := tmpMyEdit + 10
GuiControl,, Edit1, %newMyEdit%
return |
|
|
| Back to top |
|
 |
Klaus
Joined: 12 May 2005 Posts: 205 Location: Münster, Germany
|
Posted: Mon May 26, 2008 9:12 am Post subject: |
|
|
Thank you, Guest,
that's the solution , although I do not understand the technical background.
Pressing the button, ControlTextGet works without coding the window's name,
but using the hotkey, the window's name is required?
What's the difference?
Thanks again,
Klaus |
|
| Back to top |
|
 |
HugoV
Joined: 27 May 2007 Posts: 650
|
Posted: Mon May 26, 2008 9:17 am Post subject: |
|
|
No need for a hotkey if you use & | Code: | Gui, Add, Edit, w100 h20 vmyEdit,10
Gui, Add, Button, gmyLabel, &Add
Gui, show
return
myLabel:
ControlGetText, tmpMyEdit, Edit1
if (Errorlevel != 0)
MsgBox, %Errorlevel%
newMyEdit := tmpMyEdit + 10
GuiControl,, Edit1, %newMyEdit%
return |
|
|
| Back to top |
|
 |
Klaus, nli Guest
|
Posted: Mon May 26, 2008 9:21 am Post subject: |
|
|
Thanks, HugoV, for your hint, of course there is no need for hotkeys in my sample code, but it is only a simplified excerpt of a bigger one, where hotkeys are required very well.
Regards,
Klaus |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1494
|
Posted: Mon May 26, 2008 9:53 am Post subject: |
|
|
The reason for that error has to do with how each new thread has its own last found window.
Using the window name, or by using a command like WinWaitActive, should restore intended function, however the thread is launched. _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
klaus, nli Guest
|
Posted: Mon May 26, 2008 10:31 am Post subject: |
|
|
Hi, [VxE],
thank you very much for that conclusive explanation.
I have to inspect lots of programmes now concerning that case.
Thanks a lot,
Klaus |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|