AutoHotkey Community

It is currently May 27th, 2012, 9:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Rename Control
PostPosted: October 21st, 2011, 2:01 am 
Window titles can be renamed, but what about controls?

Example:
Code:
ControlSetTitle, SysListView321,,new title yo


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 6:22 am 
I guess not eh


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 6:31 am 
Offline

Joined: February 18th, 2011, 2:06 am
Posts: 207
Try this....
Code:
Gui, Add, Text, x26 y27 w80 h20 , Control rename
Gui, Add, Button, x76 y77 w100 h30 , Old name
; Generated using SmartGUI Creator for SciTE
Gui, Show, w274 h158, Untitled GUI
return

GuiClose:
ExitApp

^1:: ; Ctrl + 1
ControlSetText, Button1, NEW name, Untitled GUI
return

Use ControlSetText along with the window spy (to get ClassNN of control).

_________________
Docs
I use AHK Basic 1.0.48.5, WinXP Home SP3, Firefox


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 7:59 am 
It didn't work. Thanks anyway, mac.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 9:09 am 
Offline

Joined: August 7th, 2011, 1:23 pm
Posts: 754
Super Guest wrote:
It didn't work. Thanks anyway, mac.

It works! Run this
Code:
#SingleInstance force

Run, notepad
sleep, 100
send, Hello world
send !{F4}
sleep, 100
ControlSetText, Button1, NEW name1, ahk_class #32770
ControlSetText, Button2, NEW name2, ahk_class #32770
ControlSetText, Button3, NEW name3, ahk_class #32770
ExitApp

All the three buttons will have a new caption.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 10:30 am 
Offline

Joined: July 10th, 2008, 8:49 am
Posts: 1865
Location: Brussels, Belgium
Odlanir wrote:
Super Guest wrote:
It didn't work. Thanks anyway, mac.

It works! Run this
Code:
#SingleInstance force

Run, notepad
sleep, 100
send, Hello world
send !{F4}
sleep, 100
ControlSetText, Button1, NEW name1, ahk_class #32770
ControlSetText, Button2, NEW name2, ahk_class #32770
ControlSetText, Button3, NEW name3, ahk_class #32770
ExitApp

All the three buttons will have a new caption.


Note that this kind of script must be relaunch each time you refresh the window.
In the exampel of notepad if you press cancel then Alt+F4 the caption of the button are reset totheir default system name.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 1:59 pm 
Offline

Joined: August 7th, 2011, 1:23 pm
Posts: 754
If the goal is to change permanently the application button caption as long as the application remainst active this could be a way to get it.
This script will also close itself when the traced application will get closed.

Code:
#SingleInstance force
run notepad,,,NotPadPID
sleep, 100
send, Hello world
send !{F4}
sleep, 100

Loop
{
   sleep, 100
   ControlSetText, Button1, --(YES)--, ahk_pid %NotPadPID%
   ControlSetText, Button2, --(NO)--, ahk_pid %NotPadPID%
   ControlSetText, Button3, --(Cancel)--, ahk_pid %NotPadPID%
   IfWinNotActive, ahk_pid %NotPadPID%
      ExitApp
}
return

^esc::exitapp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 9:45 pm 
Sorry, I should have explained more clearly. My aim here is not to rename the outward appearance of the control but to rename its literal control name. For example, if you were to use Window Spy on a message box, the buttons would read "New Text" instead of "Button1."


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 10:10 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
for what purpose?

I would bet you can't change the ClassNN of a control made by another window. However, knowing this community, I wouldn't bet much.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 10:52 pm 
Oh. Well, I figured it was worth asking about, since titles can be renamed.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, hyper_, iBob35555VR, tomoe_uehara and 70 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