 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Warden
Joined: 04 Jan 2008 Posts: 11
|
Posted: Sat Jan 12, 2008 1:52 am Post subject: Check a Checkbox - Control check..... |
|
|
G'day from Australia
Firstly, let me praise AutoHotkey. I have barely touched it's surface, and it does everything I want. But in some cases, I have written those actions in an ugly fashion because of my own limitations.
Although I have written many hundreds of lines of code, it's only been in the last few days that I've found I can use
ControlClick ButtonText, WindowTitle
rather than
MouseClick Left, 50, 70
Wowzerz!
But I made the mistake of reading further and now I want to check a checkbox. Seems easy - and I'm sure it is. But I'm old and senile, and nothing I tried worked for me.
I have shown some of the attempts that I've made.
This is the code:
==================
F11:: ;Ignore background colours
{
SetTitleMatchMode 2
IfWinActive Windows Internet Explorer
{
Send !t ;Select menu item "Tools"
Send o ;Select "Internet Options"
Send !e ;Select "Accessibility"
;Control, Check,,, ahk_id Ignore &colors
;Control, Check,,, ahk_id Button2
;Control, Check,,, ahk_id ClassNN: Button2
;Control, Check,,ClassNN: #32770, colors
;Control, Check,, #32770, colors
;Control, Check,, Button2
}
}
Return
==================
The following was suggested, but did not work either.
============
WinWaitActive, Accessibility
Control, Check, , Button2, A
============
So, my questions are:
What is the correct line of code to check that particular checkbox?
What is ahk_id?
From other examples I've looked at, it appears to be the
button text, or the button name. But neither appear to work.
What is ClassNN?
How does it relate to "Spy"s ahk_class - if at all?
I would greatly appreciate any assistance.
_________________
Warden
Australia _________________ Warden
Australia |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sat Jan 12, 2008 7:02 pm Post subject: |
|
|
from help (searched ahk_id)
| Quote: | | Unique ID/HWND (ahk_id): All windowing commands can operate upon a specific window or control via its unique ID number. For example: WinActivate ahk_id %VarContainingID%. The ID of a window is typically retrieved via WinExist() or WinGet. The ID of a control is typically retrieved via ControlGet Hwnd, MouseGetPos, or DllCall. Also, ahk_id will operate upon controls even if they are hidden; that is, the setting of DetectHiddenWindows does not matter. |
also you might access internet options by calling
| Code: | | run, %A_Windir%\System32\inetcpl.cpl |
The ClassNN is a Class Name - Very much like "Button" The NN is its number of occurence. this is also the information you get from the spying tool.
try using it in conjunbction with ahk_class before ClassNN. very much like this:
| Code: | | Control, Check, , ahk_class Button2, A |
greets
derRaphael _________________
|
|
| Back to top |
|
 |
Warden
Joined: 04 Jan 2008 Posts: 11
|
Posted: Sat Jan 12, 2008 10:52 pm Post subject: inetcpl.cpl |
|
|
Thankyou derRaphael - That's a nice link to know.
Sadly "Control, Check, , ahk_class Button2, A" does not work for me either.
I can successfully use "MouseClick Left, 35, 70" to do the same job, but I am confused that several variations of "Control Check" do not appear to work in this instance, when every other command I've used works as expected - once I've got past my own limitations.
So far - all of the following have been tried without avail
WinWaitActive, Accessibility
Control Check,,, ahk_id Ignore &colors
Control Check,,, ahk_id Button2
Control Check,,, ahk_id ClassNN: Button2
Control Check,,ClassNN: #32770, colors
Control Check,, #32770, colors
Control Check,, Button2
Control, Check, ,ahk_class Button2, A
Andrew _________________ Warden
Australia |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sun Jan 13, 2008 1:10 am Post subject: |
|
|
sorry for misleading you
| Code: | | ControlClick, ClassNN |
means in ScriptCode
| Code: | | ConntrolClick, Button2 |
anyways, this should work. i assigned the hotkey SHIFT+CTRL+O to either enable or disable (toggle) the 1st three checkboxes in accessibility window
| Code: |
+^o::
SetTitleMatchMode, 2
run, %A_WinDir%\System32\inetcpl.cpl
; wait for Internet Options Window
WinWaitActive, Internet ahk_class #32770
; CLICKBUTTON -> Accessibility
ControlClick, Button14
; Wait for Accessibility Window
WinWaitActive, ahk_class #32770
ControlClick, Button2 ; colors
ControlClick, Button3 ; fonts
ControlClick, Button4 ; more fonts
ControlClick, Button8 ; OK
; wait for Internet Options Window
WinWaitActive, Internet ahk_class #32770
ControlClick, Button15 ; OK
return
|
tested on german win2k with msie 6 (thats why i used the classNN instead of their content - its more international this way)
have fun
derRaphael
post scriptum: you might want to use code Tags (simply highlighting the sourcecode and pressing the code-button) the next time to present your sourcecode properly ;) _________________
|
|
| Back to top |
|
 |
Warden
Joined: 04 Jan 2008 Posts: 11
|
Posted: Sun Jan 13, 2008 2:46 am Post subject: Control Check |
|
|
Thankyou again derRaphael
I regret that you've missed the point of my question.
ControlClick works fine for me. I am not trying to toggle a button, rather, I am trying to "Set" a Checkbox, the bottom line is that I'm trying to understand the particular command - Control Check - and its parameters.
Toggling background colours is merely a stepping stone, chosen because everyone who uses Windows will have that checkbox.
Thanks also for the tip about code tags - that's magic.
Andrew/Warden _________________ Warden
Australia |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jan 13, 2008 3:19 am Post subject: Re: Control Check |
|
|
| Warden wrote: | | ...the bottom line is that I'm trying to understand the particular command - Control Check - and its parameters. |
...this works for me...
| Code: | F9::
+^o::
SetTitleMatchMode, 2
Run, %A_WinDir%\System32\inetcpl.cpl
;//wait for Internet Options Window
WinWaitActive, Internet ahk_class #32770
;//CLICKBUTTON -> Accessibility
;//ControlClick, Button14
ControlSend, Button14, {Space}
;//Wait for Accessibility Window
WinWaitActive, ahk_class #32770
;//ControlClick, Button2 ;//colors
;//ControlClick, Button3 ;//fonts
;//ControlClick, Button4 ;//more fonts
;// *** If it still don't work for you...add some sleep... ***
;//Sleep, 1019
Control, Check, , Button2 ;//colors
;//Control, Check, , Button3 ;//fonts
;//Control, Check, , Button4 ;//more fonts
;//ControlClick, Button8 ;//OK
;//ControlSend, Button8, {Space}
;//wait for Internet Options Window
;//WinWaitActive, Internet ahk_class #32770
;//ControlClick, Button15 ;//OK
;//ControlSend, Button15, {Space}
return |
|
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sun Jan 13, 2008 4:43 am Post subject: |
|
|
im confused .... using my code actually toggles the checkboxes, since checkboxes are some style of buttons _________________
|
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jan 13, 2008 5:19 am Post subject: |
|
|
| DerRaphael wrote: | | im confused .... using my code actually toggles the checkboxes, since checkboxes are some style of buttons |
...yes, I'm kinda confused too, your code also works for me, but I re-did it with Control, Check, since he can't seem to get that particular command working...I didn't mean to say that the code you posted didn't work...cuz it does work...but it uses ControlClick instead of Control, Check... |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sun Jan 13, 2008 6:19 am Post subject: |
|
|
probably this clarifies questions:
| Code: |
; tst.ahk
Gui, Add, Edit, +ReadOnly vMySource w300 r20
Gui, Add, CheckBox, yp x320 checked, Test1
Gui, Add, CheckBox, disabled, Test2
Gui, Add, CheckBox, , Test3
Gui, Add, Button, w80 gCheck, Check All
Gui, Add, Button, wp gUnCheck, UnCheck All
Gui, Add, Button, wp gToggle, Toggle All
Gui, Show,, CheckBox Test
FileRead, MyScript, %A_ScriptFullPath%
GuiControl,,MySource,%MyScript%
return
GuiClose:
ExitApp
return
Check:
Control, Check,, Button1
Control, Check,, Button2
Control, Check,, Button3
return
UnCheck:
Control, UnCheck,, Button1
Control, UnCheck,, Button2
Control, UnCheck,, Button3
return
Toggle:
Loop,3
{
ControlGet, Status, Checked,, Button%A_Index%
If Status = 0
Control, Check,, Button%A_Index%
else
Control, UnCheck,, Button%A_Index%
}
return |
Button1 to Button3 are the CheckBoxes, NOT the Click-Buttons
So these can be Addressed as the Source states either thru ControlClick as in earlier example or thru Control, Check as done here
greets
derRaphael _________________
|
|
| Back to top |
|
 |
AHKisNice
Joined: 11 Jan 2008 Posts: 32
|
Posted: Sun Jan 13, 2008 1:04 pm Post subject: |
|
|
| What is a control? |
|
| Back to top |
|
 |
Warden
Joined: 04 Jan 2008 Posts: 11
|
Posted: Sun Jan 13, 2008 7:45 pm Post subject: |
|
|
Thankyou once again derRaphael - you have been very generous with your time, and with your patience.
It's 6:45 AM here - I have to head off to work
I'll try your code when I get home this afternoon.
In response to AHKisNice, loosely, a control is anything that goes onto a gui window. This is a button, a checkbox, a radio button, a richtextbox, a picture, a menu. Offhand, I can't think of any exceptions, but there might be some.
Andrew/Warden _________________ Warden
Australia |
|
| Back to top |
|
 |
Warden
Joined: 04 Jan 2008 Posts: 11
|
Posted: Tue Jan 15, 2008 9:36 am Post subject: |
|
|
It works in the GUI - but does not work for Internet Explorer. I can only guess that it is some anomoly in that programme.
Thasnks once again.
Andrew _________________ Warden
Australia |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jan 15, 2008 9:47 am Post subject: |
|
|
| Warden wrote: | | It works in the GUI... |
...omg what is "it", you never responded about my code, is my code "it"?
| Warden wrote: | | ...but does not work for Internet Explorer. |
...omg are you using IE7?...I only have & tested on IE6...
| Warden wrote: | | IfWinActive Windows Internet Explorer |
...yup...guess so, that is the Window Title of IE7...you might've wanted to specify in the 1st post what OS & version of IE...I never want to install IE7, so I can't test any further, but did you say that ControlClick works? Can you test Control, Check on other windows...like a standard File Properties dialog?...I don't know what to suggest, since I don't know how different the IE7 Internet Options Dialog is... |
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 150
|
Posted: Wed Jan 16, 2008 4:48 pm Post subject: |
|
|
| Warden wrote: | It works in the GUI - but does not work for Internet Explorer. I can only guess that it is some anomoly in that programme.
Thasnks once again.
Andrew |
to toggle on/off a check, the following code is sufficient..
| Code: | | Control, (Un)Check, , <controlname>, <wintitle> |
however in your case, the IE options in the Advanced tab is listed on a SysTreeView32 control which is not supported by Autohotkey internally. that's the reason why your code is not working. anyway, do a search in this forum on "SysTreeView32", maybe someone has found a work-around. |
|
| Back to top |
|
 |
Warden
Joined: 04 Jan 2008 Posts: 11
|
Posted: Wed Jan 16, 2008 6:08 pm Post subject: |
|
|
BINGO - at least I have an answer! ty  _________________ Warden
Australia |
|
| 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
|