ThanhDuy Posted June 17, 2009 Share Posted June 17, 2009 I use send key to change status but it not good. Can you help me another solution ControlSetText($handle, "", "[CLASS:YUI_Win32Edit; INSTANCE:2]", $status) ControlSend($handle, "", "[CLASS:YUI_Win32Edit; INSTANCE:2]", "{ENTER}") expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <listboxconstants.au3> #NoTrayIcon Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 0) Opt("SendKeyDelay",0) Opt("SendKeyDownDelay",0) Global Const $version = "[_¯_¯_¯_¯_¯]" Global Const $YahooVersion = RegRead( "HKLM\SOFTWARE\Yahoo\pager","ProductVersion") If WinExists($version) Then Exit (0) HotKeySet("{F1}","HelpAbout") Dim $run = false Dim $Gui, $StatusEdit, $StartStopButton, $AutoScrollCheckBox, $AvailInvisCheckBox, $AutoChangeCheckBox, $WordCheckBox, $CurrentStatus Dim $TimeInviInput Dim $AutoScroll, $AvailInvis, $StatusList, $AutoChange, $TrimWord, $TimeInvi = 200 $Gui = GUICreate($version, 300, 200, 400, 250) GUISetIcon("105.ico") GUICtrlCreateLabel("Status Message",5,5,100,15) $StatusEdit = GUICtrlCreateEdit("Status Message", 5, 20, 290, 50, $WS_VSCROLL) $CurrentStatus = GUICtrlCreateEdit("",5,73,290,17,$ES_READONLY) GUICtrlCreateGroup("Option",5,90,200,67) $AutoScrollCheckBox = GUICtrlCreateCheckbox("AutoScroll",10,105) $AvailInvisCheckBox = GUICtrlCreateCheckbox("Available-Invisible",100,105) $AutoChangeCheckBox = GUICtrlCreateCheckbox("Auto Change",10,130) $WordCheckBox = GUICtrlCreateCheckbox("Word",100,130) $StartStopButton = GUICtrlCreateButton("start", 230, 97, 50, 25,0x0C00) GUICtrlCreateGroup("Speed",5,156,200,38) GUICtrlCreateLabel("Time Invisible",10,173,100,15) $TimeInviInput = GUICtrlCreateInput("200",80,168,50,20) GUICtrlCreateLabel("mili-sec",135,173,35,15) GUISetState(@SW_SHOW) While True Local $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit (0) Case $msg = $StartStopButton ButtonHandle() EndSelect WEnd Func AvailInvisFunc($handle, ByRef $Availble) If $AvailInvis = $GUI_CHECKED Then If $Availble Then $Availble = False ControlSend($handle, "", "[CLASS:ATL:007C37E8; INSTANCE:1]", "^!i") Sleep(1000) Else $Availble = True ControlSend($handle, "", "[CLASS:ATL:007C37E8; INSTANCE:1]", "^!a") EndIf EndIf EndFunc Func AutoScrollFunc(ByRef $status, $num, ByRef $lr, ByRef $trim, $StatusMessage, ByRef $ism) If $AutoScroll = $GUI_CHECKED Then If $lr Then Local $char = StringLeft($status, $num) $status = StringTrimLeft($status, $num) & $char If $status = $StatusMessage Then $lr = False Else Local $char = StringRight($status, $num) $status = $char & StringTrimRight($status, $num) If $status = $StatusMessage Then $lr = True EndIf Else If $lr Then If $trim Then $status = StringTrimLeft($status, $num) If $status = "" Then $trim = false Else $status = StringRight ($StatusMessage, $ism) $ism += $num If $status = $StatusMessage or $ism > StringLen($StatusMessage) Then $ism = 0 $lr = false $trim = True EndIf EndIf Else If $trim Then $status = StringTrimRight($status, $num) If $status = "" Then $trim = false Else $status = StringLeft ($StatusMessage, $ism) $ism += $num If $status = $StatusMessage or $ism > StringLen($StatusMessage) Then $ism = 0 $lr = True $trim = True EndIf EndIf EndIf EndIf EndFunc #cs Func AutoScrollFunc(ByRef $status, $num, ByRef $lr, ByRef $trim, $StatusMessage, ByRef $ism) Local $char If $lr Then $char = StringLeft($status, $num) $status = StringTrimLeft($status, $num) Else $char = StringRight($status, $num) $status = StringTrimRight($status, $num) EndIf If $AutoScroll = $GUI_CHECKED Then If $lr Then $status &= $char Else $status = $char & $status EndIf Else If $status = "" Then $trim = false If Not $trim and $lr Then $status = StringRight ($StatusMessage, $ism) $ism += $num If $status = $StatusMessage or $ism > StringLen($StatusMessage) Then $ism = 0 $lr = false $trim = True EndIf EndIf If Not $trim and Not $lr Then $status = StringLeft ($StatusMessage, $ism) $ism += $num If $status = $StatusMessage or $ism > StringLen($StatusMessage) Then $ism = 0 $lr = True $trim = True EndIf EndIf EndIf EndFunc #ce Func AutoChangeFunc( ByRef $status, ByRef $lr, ByRef $trim, $StatusMessage ) If $AutoChange = $GUI_UNCHECKED and Not $trim Then $status = $StatusMessage $lr = True $trim = True EndIf EndFunc Func FindIndex($status, ByRef $num, $lr, $trim, $StatusMessage) Local $value Local $start, $end, $step If $trim and $lr Then $start = 1 $end = StringLen($status) $step = 1 EndIf If $trim and Not $lr Then $start = StringLen($status) $end = 1 $step = -1 EndIf If Not $trim and $lr Then $start = StringLen($StatusMessage) - StringLen($status) $end = 1 $step = -1 EndIf If Not $trim and Not $lr Then $start = StringLen($status) + 1 $end = StringLen($StatusMessage) $step = 1 EndIf For $i = $start To $end Step $step $value = StringMid($status,$i,1) If Not $trim Then $value = StringMid($StatusMessage,$i,1) If $value = " " Then If $trim and $lr Then $num = $i If $trim and Not $lr Then $num = ($start - $i + 1) If Not $trim and $lr then $num = $i If Not $trim And Not $lr Then $num = $i ExitLoop EndIf Next EndFunc Func YahooStatus($status) Local $handle = WinGetHandle("[CLASS:YahooBuddyMain; TITLE:Yahoo! Messenger;]", "ListView") Local $Availble = True Local $lr = True Local $trim = true Local $StatusMessage = $status Local $ism = 0 Local $num = 1 While $run AvailInvisFunc( $handle, $Availble ) If Not $Availble Then ContinueLoop If $TrimWord = $GUI_CHECKED Then FindIndex($status, $num, $lr, $trim, $StatusMessage ) AutoChangeFunc( $status, $lr, $trim, $StatusMessage ) AutoScrollFunc($status, $num, $lr, $trim, $StatusMessage, $ism) ControlSetText($handle, "", "[CLASS:YUI_Win32Edit; INSTANCE:2]", $status) ControlSend($handle, "", "[CLASS:YUI_Win32Edit; INSTANCE:2]", "{ENTER}") GUICtrlSetData( $CurrentStatus, $status ) Invisible(); System pause WEnd EndFunc Func Invisible() Local $begin = TimerInit() While TimerDiff($begin) <= $TimeInvi local $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit (0) Case $msg = $StartStopButton GUICtrlSetData($StartStopButton,"start") $run = false EndSelect WEnd EndFunc Func ButtonHandle() If WinExists("[CLASS:YahooBuddyMain; TITLE:Yahoo! Messenger;]", "ListView") Then GUICtrlSetData($StartStopButton,"stop") $AutoScroll = GUICtrlRead( $AutoScrollCheckBox ) $AvailInvis = GUICtrlRead( $AvailInvisCheckBox ) $TimeInvi = GUICtrlRead( $TimeInviInput ) $AutoChange = GUICtrlRead( $AutoChangeCheckBox ) $TrimWord = GUICtrlRead( $WordCheckBox ) Local $status = GUICtrlRead( $statusEdit ) & " " $run = True WinActivate("[CLASS:YahooBuddyMain; TITLE:Yahoo! Messenger;]", "ListView") YahooStatus($status) EndIf EndFunc Func HelpAbout() EndFunc EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now