yarsye 发表于 2010-5-20 09:24:03

(已解决)Is there got a function can search the letters on a button?

本帖最后由 yarsye 于 2010-9-4 12:29 编辑

Sorry , my current running system is Eng OS , i just want to click a button not using Control ID or Advanced(Class) , for they will change on the same button on different OSes, so i think it could be done if click the button using search the letters on that button .Is there got a function or a method able to solve this issue?
Thanks for your viewing .

sxd 发表于 2010-5-20 09:37:25

CLASS also change on the different OS?

netegg 发表于 2010-5-20 09:41:31

本帖最后由 netegg 于 2010-5-20 09:45 编辑

Try function guictrlread($button) if the program is made by youself. If not, they shouldn't be changed, just like sxd's thought.

yarsye 发表于 2010-5-20 10:14:00

Yes ,in my system there is a button in the application got two same Control ID (1003) ,and the Advanced(Class) :-- "INSTANCE8"will also change to 20 or 38 , i have no idea about this , but it really comes.

pusofalse 发表于 2010-5-20 10:37:15

See 'advanced window matching options', which locates in Help File->AutoIt->Using AutoIt->Window Titles and Text (Advanced).

PS:
Q: How to resolve my system language problem?
A: Control Panel->Regional and Language Options->Advanced->select 'Chinese (RPC)' for a non-Unicode program->OK->Restart your computer.

C.L 发表于 2010-5-20 10:55:52

Maybe different wintitle's letters was got on different OSes, and if you want to search the letters you must be get the correct title of the window ,so I don't find a way to do that(Maybe you can make a Multilingual version~~ :-)).
But, if you just want to click a button , you can try the function "Mouseclick()"
You can see the Autoit Helpfile for the "Mouseclick()" function.

lanfengc 发表于 2010-5-20 10:58:15

test this code.#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $BtClickFlg=True;Declare a global variable ,if button clicked, this global variable will control the function not to run again.
$Form1 = GUICreate("Form1", 122, 196, 192, 114)   ;create form
$Button1 = GUICtrlCreateButton("Myfirst BT", 8, 8, 105, 41)   ;create button
$Button2 = GUICtrlCreateButton("Mysecond BT", 8, 72, 105, 41)
$Button3 = GUICtrlCreateButton("Mythird BT", 8, 136, 105, 41)
GUISetState(@SW_SHOW)   ;show form
#EndRegion ### END Koda GUI section ###
$stringtoclickbt=InputBox("Input","Please input which button you want to click:","","",300,80);input the letter on the button which you want to click
While 1   ;message loop
        $nMsg = GUIGetMsg();get message
        Switch $nMsg;switch message
                Case $GUI_EVENT_CLOSE;if message is $GUI_EVENT_CLOSE,exit program
                        Exit
                Case $Button1;if message is button1
                        MsgBox(0,"Button1 Click","You clicked button1!");show a messagebox, title is 'button1 click',text is 'You clicked button1!'
                        $BtClickFlg=False;set button click flg to false,the function just run once
                Case $Button2   
                        MsgBox(0,"Button2 Click","You clicked button2!")
                        $BtClickFlg=False
                Case $Button3
                        MsgBox(0,"Button3 Click","You clicked button3!")
                        $BtClickFlg=False
        EndSwitch
        If $BtClickFlg=True Then   ;if button click flg is true , call function clickbutton to Sends a mouse click command to the button witch you type in the inputbox
                clickbutton($stringtoclickbt)
        EndIf
WEnd

Func clickbutton($stringonbutton)
        Local $string1=GUICtrlRead($Button1);Declare a local variable ,set the value is button1's text
        Local $string2=GUICtrlRead($Button2);Declare a local variable ,set the value is button2's text
        Local $string3=GUICtrlRead($Button3);Declare a local variable ,set the value is button3's text
        If $stringonbutton=$string1 Then   ;if button1's text is same to the string you type in, Sends a mouse click command to button1
                ControlClick($Form1,"",$Button1,"left")
        EndIf
        If $stringonbutton=$string2 Then;if button2's text is same to the string you type in, Sends a mouse click command to button2
                ControlClick($Form1,"",$Button2,"left")
        EndIf
        If $stringonbutton=$string3 Then;if button3's text is same to the string you type in, Sends a mouse click command to button3
                ControlClick($Form1,"",$Button3,"left")
        EndIf
EndFunc

yarsye 发表于 2010-5-20 11:42:06

test this code.
lanfengc 发表于 2010-5-20 10:58 http://www.autoitx.com/images/common/back.gif

wonderful ! that's what i wanted . thanks
页: [1]
查看完整版本: (已解决)Is there got a function can search the letters on a button?