Jump to content
Sign in to follow this  
bob.frew

combobox text

Recommended Posts

bob.frew

Hi.

I'm hoping you can help me.

I'm using Windows XP Home with AutoIt v3.1 .

I am trying to write a script that toggles between two desktop colour schemes (under Windows Classic style). I prefer working with yellow on black, but have to change when I encounter the old black text on black backround problem.

I have the script working fine to the point where I need to read the current value in the selected combobox2 on the Appearance Tab of Display Properties. I used the Autoit Info tool to establish controlID etc.

I have been trying to use the following

$colournow = ControlGetText ( "Display Properties", "Appearance", "ComboBox2" )

(in all forms I can think of but without success. using controlID 1114 instead of ComboBox2 etc.)

I get nothing in $colournow

This is my first effort, beyond the "hello world" so I'm hoping I'm doing something wrong.

Script so far is as follows

;- - - - - - - - - - - - - - - - - - - -

Opt("ExpandEnvStrings",1)

Opt("ExpandVarStrings",1)

Opt("MustDeclareVars",1)

;

Dim $colournow

Run("C:\WINDOWS\system32\control.exe")

WinWaitActive("Control Panel")

ControlGetFocus ("Control Panel")

Send("{DOWN 6}")

Send("{ENTER}")

WinClose("Control Panel")

WinWaitActive("Display Properties")

ControlGetFocus ("Display Properties")

Send("^{TAB}") ; couldn't get Send("^{TAB 3}") to work

Sleep(100) ; seems happier with pause to catch up

Send("^{TAB}")

Sleep(100)

Send("^{TAB}") ; to the Appearance Tab

Sleep(100)

Send("{TAB}") ; to the Color scheme combobox

$colournow = ControlGetText ( "Display Properties", "Appearance", "1114" )

If $colournow ="High Contrast #1" Then

Send("{RIGHT 7}")

Else

Send("{LEFT 7}")

EndIf

Bob


AutoIt is great - leave me alone and I'll play for hours

Share this post


Link to post
Share on other sites
GaryFrost

This works on mine the ^{TAB 3} works here, but you'll have to figure out what works best for you.

;- - - - - - - - - - - - - - - - - - - -
Opt ("ExpandEnvStrings", 1)
Opt ("ExpandVarStrings", 1)
Opt ("MustDeclareVars", 1)
;
Dim $colournow
Const $CB_ERR = -1
Const $CB_GETCURSEL = 0x147
Const $CB_GETLBTEXT = 0x148
Const $CB_GETLBTEXTLEN = 0x149

Run(@SystemDir & "\control.exe")
WinWait("Control Panel")
WinWaitActive("Control Panel")
ControlGetFocus("Control Panel")
Sleep ( 500 )
Send("{DOWN 6}")
Sleep ( 500 )
Send("{ENTER}")
WinClose("Control Panel")

WinWait("Display Properties")
WinWaitActive("Display Properties")
ControlGetFocus("Display Properties")
Sleep ( 100 )
Send("^{TAB 3}"); couldn't get Send("^{TAB 3}") to work
;~ Sleep(100); seems happier with pause to catch up
;~ Send("^{TAB}")
;~ Sleep(100)
;~ Send("^{TAB}"); to the Appearance Tab
;~ Sleep(100)
;~ Send("{TAB}"); to the Color scheme combobox

;~ $colournow = ControlGetText("Display Properties", "Appearance", "ComboBox2")
Sleep ( 1000 )
Local $hcombobox = ControlGetHandle("Display Properties","","ComboBox2")
Local $ret = DllCall("user32.dll","int","SendMessage","hwnd",$hcombobox, "int", $CB_GETCURSEL, "int", 0, "int", 0)
$ret = DllCall("user32.dll","int","SendMessage","hwnd", $hcombobox, "int", $CB_GETLBTEXT, "int", $ret[0], "str", "")
$colournow = $ret[4]

If $colournow = "High Contrast #1" Then
    Send("{RIGHT 7}")
Else
    Send("{LEFT 7}")
EndIf
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
seandisanti

Hi.

I'm hoping you can help me.

I'm using Windows XP Home with AutoIt v3.1 .

I am trying to write a script that toggles between two desktop colour schemes (under Windows Classic style). I prefer working with yellow on black, but have to change when I encounter the old black text on black backround problem.

I have the script working fine to the point where I need to read the current value in the selected combobox2 on the Appearance Tab of Display Properties. I used the Autoit Info tool to establish controlID etc.

I have been trying to use the following

since you're working with known values, ie: the value that is currently set, and the value you want it to be set to. Can't you just use:

ControlSetText ( "title", "text", controlID, "new text" ) with the literal value that you want it to have?


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites
GaryFrost

since you're working with known values, ie: the value that is currently set, and the value you want it to be set to. Can't you just use:

ControlSetText ( "title", "text", controlID, "new text" ) with the literal value that you want it to have?

<{POST_SNAPBACK}>

Not sure that'll work with a combobox, but the following will

just set the param to one wanted

If $colournow = "High Contrast #1" Then
;~  Send("{RIGHT 7}")
; on my system Windows standard is 19
    DllCall("user32.dll","int","SendMessage","hwnd",$hcombobox, "int", $CB_SETCURSEL, "int", 19, "int", 0)
Else
;~  Send("{LEFT 7}")
  ; on my system High Contrast #1 is 3
    DllCall("user32.dll","int","SendMessage","hwnd",$hcombobox, "int", $CB_SETCURSEL, "int", 3, "int", 0)
EndIf

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
bob.frew

Thanks for your help guys.

I have managed to get the script working now after a bit of digging. I guess I'll spend the next few months reading up on the Windows API (I know nothing) and a lot more of the Autoit forum.

Cheers ..Bob


AutoIt is great - leave me alone and I'll play for hours

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.