Sign in to follow this  
Followers 0
Lakes

Having Problems Activating A Window

2 posts in this topic

This would work fine if only I could get Focus to/activate the Banner input Window!

The Banner Window is there, just not active.

I`ve tried ControlFocus and WinActivate with no luck :)

I put the Delay in to give time to activiate the window manually, just to check it was pasteing the text ok.

;For use with DigitalPeers Camtrack Program

;Banner Input
;Title: Banner

;Control ID:    1046
;ClassNameNN:   Edit1

;Control ID:    1074
;ClassNameNN:   Button1
;Text:      Send

;Select Font
;Control ID:    1076
;ClassNameNN:   ComboBox1

;Font Style
;Control ID:    1075
;ClassNameNN:   ComboBox2

;Font Size
;Control ID:    1077
;ClassNameNN:   ComboBox3

;Left-Centre-Right Align
;Control ID:    1081
;ClassNameNN:   Static1

;Select Color
;Control ID:    1081
;ClassNameNN:   Static1

;-------------------------
;Scrolling Banner Input
;Title: Scrolling Banner
;-------------------------

#include <Date.au3>
#include <GUIConstants.au3>
; == GUI generated with Koda ==);

$BanText = GUICreate("CamTrack Banner Text", 312, 135, 189, 200)

$Butt  = GUICtrlCreateButton("SEND", 256, 8, 49, 21, 0)
$Butt1 = GUICtrlCreateButton("SEND1", 256, 40, 49, 21, 0)
$Butt2 = GUICtrlCreateButton("SEND2", 256, 72, 49, 21, 0)
$Butt3 = GUICtrlCreateButton("SEND3", 256, 104, 49, 21, 0)


$Input = GUICtrlCreateInput("", 8, 8, 233, 21)
$Input1 = GUICtrlCreateInput("", 8, 40, 233, 21)
$Input2 = GUICtrlCreateInput("", 8, 72, 233, 21)
$Input3 = GUICtrlCreateInput("", 8, 104, 233, 21)

$DayName  = _DateDayOfWeek( @WDAY )
$TimeName = _DateTimeFormat( _NowCalc(),1)

ControlSend ($BanText,"",$Input, $DayName &" " &$TimeName)
ControlSend ($BanText,"",$Input1, "Hello")
ControlSend ($BanText,"",$Input2,"GoodBye")
ControlSend ($BanText,"",$Input3,"Good Night All")

$Banner = "Banner"
$BanEd = "Edit1"
$SendButt = "Button1"
$Err = 0

GUISetState(@SW_SHOW)

While 1
;_BanChk($Err)

$msg = GuiGetMsg()
Select
    
    Case $msg = $Butt
        $Text = ControlGetText ($BanText, "", $Input)
        WinActivate ($Banner)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)

    Case $msg = $Butt1
        $Text = ControlGetText ($BanText, "", $Input1)
        ControlFocus ($Banner,"", $BanEd)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)

    Case $msg = $Butt2
        $Text = ControlGetText ($BanText, "", $Input2)
        ControlFocus ($Banner,"", $BanEd)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)

    Case $msg  = $Butt3
        $Text = ControlGetText ($BanText, "", $Input3)
        ControlFocus ($Banner,"", $BanEd)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)
EndSelect


    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Func _Delay()
Sleep(1000)
EndFunc

Func _BanChk($Err)
    If WinExists("Banner") or WinExists("Scrolling Banner") =0 then
    $Err= MsgBox(16+5,"ERROR!","Please enable your Camtrack Banner Input")
    Select
        Case $Err = 2
            Exit
        Case $Err = 4
            _BanChk
    EndSelect
    EndIF
EndFunc

Thanks!


2015 - Still no flying cars, instead blankets with sleeves.

Share this post


Link to post
Share on other sites



This would work fine if only I could get Focus to/activate the Banner input Window!

The Banner Window is there, just not active.

I`ve tried ControlFocus and WinActivate with no luck :)

I put the Delay in to give time to activiate the window manually, just to check it was pasteing the text ok.

;For use with DigitalPeers Camtrack Program

;Banner Input
;Title: Banner

;Control ID:    1046
;ClassNameNN:   Edit1

;Control ID:    1074
;ClassNameNN:   Button1
;Text:      Send

;Select Font
;Control ID:    1076
;ClassNameNN:   ComboBox1

;Font Style
;Control ID:    1075
;ClassNameNN:   ComboBox2

;Font Size
;Control ID:    1077
;ClassNameNN:   ComboBox3

;Left-Centre-Right Align
;Control ID:    1081
;ClassNameNN:   Static1

;Select Color
;Control ID:    1081
;ClassNameNN:   Static1

;-------------------------
;Scrolling Banner Input
;Title: Scrolling Banner
;-------------------------

#include <Date.au3>
#include <GUIConstants.au3>
; == GUI generated with Koda ==);

$BanText = GUICreate("CamTrack Banner Text", 312, 135, 189, 200)

$Butt  = GUICtrlCreateButton("SEND", 256, 8, 49, 21, 0)
$Butt1 = GUICtrlCreateButton("SEND1", 256, 40, 49, 21, 0)
$Butt2 = GUICtrlCreateButton("SEND2", 256, 72, 49, 21, 0)
$Butt3 = GUICtrlCreateButton("SEND3", 256, 104, 49, 21, 0)
$Input = GUICtrlCreateInput("", 8, 8, 233, 21)
$Input1 = GUICtrlCreateInput("", 8, 40, 233, 21)
$Input2 = GUICtrlCreateInput("", 8, 72, 233, 21)
$Input3 = GUICtrlCreateInput("", 8, 104, 233, 21)

$DayName  = _DateDayOfWeek( @WDAY )
$TimeName = _DateTimeFormat( _NowCalc(),1)

ControlSend ($BanText,"",$Input, $DayName &" " &$TimeName)
ControlSend ($BanText,"",$Input1, "Hello")
ControlSend ($BanText,"",$Input2,"GoodBye")
ControlSend ($BanText,"",$Input3,"Good Night All")

$Banner = "Banner"
$BanEd = "Edit1"
$SendButt = "Button1"
$Err = 0

GUISetState(@SW_SHOW)

While 1
;_BanChk($Err)

$msg = GuiGetMsg()
Select
    
    Case $msg = $Butt
        $Text = ControlGetText ($BanText, "", $Input)
        WinActivate ($Banner)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)

    Case $msg = $Butt1
        $Text = ControlGetText ($BanText, "", $Input1)
        ControlFocus ($Banner,"", $BanEd)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)

    Case $msg = $Butt2
        $Text = ControlGetText ($BanText, "", $Input2)
        ControlFocus ($Banner,"", $BanEd)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)

    Case $msg  = $Butt3
        $Text = ControlGetText ($BanText, "", $Input3)
        ControlFocus ($Banner,"", $BanEd)
        _Delay()
        ControlCommand($Banner,"",$BanEd, "EditPaste", $Text)
        _Delay()
        ControlClick($Banner,"",$SendButt)
EndSelect
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
;;;;;;;
    EndSelect
WEnd
Func _Delay()
Sleep(1000)
EndFunc

Func _BanChk($Err)
    If WinExists("Banner") or WinExists("Scrolling Banner") =0 then
    $Err= MsgBox(16+5,"ERROR!","Please enable your Camtrack Banner Input")
    Select
        Case $Err = 2
            Exit
        Case $Err = 4
            _BanChk
    EndSelect
    EndIF
EndFunc

Thanks!

Your first problem come from

$Banner = "Banner"

it must be change to

$Banner = "CamTrack Banner Text"

or you have to use the Opt('WinTitleMatchMode',2) to match any string.

I am not sure of the logic of what you intend to do but at least you can test.

reread the doc as if the window exist you don't need to activate when using Control... functions neither need Delay :mellow:

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  
Followers 0