StSchnell Posted December 20, 2008 Share Posted December 20, 2008 Hello community, I am new at AutoIt and now I have a question about the following code in vb script: Const WindowTitle = "Test" Const ClassName = "HH Parent" Dim oAutoIt Set oAutoIt = CreateObject("AutoItX3.Control") Sub view_onclick() Dim Title Title = "[TITLE:" & WindowTitle & "; CLASS:" & ClassName & "]" Dim XPos, YPos, Width, Height XPos = oAutoIt.WinGetPosX(Title) YPos = oAutoIt.WinGetPosY(Title) Width = oAutoIt.WinGetPosWidth(Title) Height = oAutoIt.WinGetPosHeight(Title) If oAutoIt.ControlCommand(Title, "", "SysTabControl321", "IsVisible", "") Then oAutoIt.ControlClick(Title, "", "ToolbarWindow321", "left", 1, 10, 10) oAutoIt.WinMove Title, "", XPos, YPos, Width, Height Else oAutoIt.ControlClick(Title, "", "ToolbarWindow321", "left", 1, 10, 10) End If End Sub All works well, but not the WinMove command. If I set a MsgBox command between ControlClick and WinMove it works. Is there a command to take a DoEvents, a ReDraw or something else to bring the program to a ControlClick and then to move the window? Thanks for tips. Cheers Stefan Meet me at XING Visit my private homepage Visit my commercial homepage Look at my book inter alia about AutoIt and SAP Link to comment Share on other sites More sharing options...
StSchnell Posted December 21, 2008 Author Share Posted December 21, 2008 (edited) Hello community, a small addition: expandcollapse popup;-Begin----------------------------------------------------------------- ;-Constants------------------------------------------------------------- Const $WindowTitle = "Test5" Const $ClassName = "HH Parent" ;-Variables------------------------------------------------------------- Dim $Title $Title = "[TITLE:" & $WindowTitle & "; CLASS:" & $ClassName & "]" ;-Function IsTabControlVisible------------------------------------------ Func IsTabControlVisible() Return ControlCommand($Title, "", "SysTabControl321", "IsVisible") EndFunc ;-Function ShowTabControl----------------------------------------------- Func ShowTabControl() Return ControlClick($Title, "", "ToolbarWindow321", "left", 1, _ 10, 10) EndFunc ;-Procedure main-------------------------------------------------------- Func main() Dim $Size $Size = WinGetPos($Title) If IsTabControlVisible() Then ShowTabControl() WinMove($Title, "", $Size[0], $Size[1], $Size[2], $Size[3]) Else ShowTabControl() EndIf EndFunc ;-Main------------------------------------------------------------------ main() ;-End------------------------------------------------------------------- I check the function with an external AutoIt program and all works well. I do not know the difference between the ActiveX from AutoIt and the program, any ideas? Thanks for tips. Cheers Stefan [21.12.2008] Edited December 21, 2008 by StSchnell Meet me at XING Visit my private homepage Visit my commercial homepage Look at my book inter alia about AutoIt and SAP Link to comment Share on other sites More sharing options...
ReFran Posted December 21, 2008 Share Posted December 21, 2008 After Controlclick you should check the result (winactive, winclose,, ...) or at least give the programm time to wait on event with WScript.Sleep 1000 HTH, Reinhard Link to comment Share on other sites More sharing options...
StSchnell Posted December 22, 2008 Author Share Posted December 22, 2008 Hello Reinhard, thanks for your tip. I checked WinWaitActive and Sleep from AutoIt and both do not work. WScript.Sleep also do not work, because I use VBScript in a HTML site. It is not possible to use methods of the WScript object in VBScript in a HTML site, specifically Sleep. Now I solve the problem with the following vb script: '-Begin----------------------------------------------------------------- Option Explicit '-Procedure Sleep------------------------------------------------------- Sub Sleep() Dim Arg Set Arg = WScript.Arguments WScript.Sleep CInt(Arg(0)) End Sub '-Main------------------------------------------------------------------ Sleep() '-End------------------------------------------------------------------- I call this script file with this function: '-Sleep----------------------------------------------------------------- Function Sleep(Time) Dim Path Path = GetActualPath() Sleep = oShell.Run(Path & "\Sleep.vbs " & Time, 0, true) End Function Now, after a CommandClick, I call Sleep 1 and all works well. Cheers Stefan Meet me at XING Visit my private homepage Visit my commercial homepage Look at my book inter alia about AutoIt and SAP Link to comment Share on other sites More sharing options...
ReFran Posted December 22, 2008 Share Posted December 22, 2008 I remember that I've had a similar problem with a HTA script, where also WScript.sleep don't work. I looked for an older script. The solution was to setTimeOut: While not WshShell.AppActivate("Adobe Acrobat") : setTimeout "Wait()",5000 : Wend .... .... sub Wait : end sub That should work, but my HTA knowledge is a little bit rusty. Best regards, Reinhard Link to comment Share on other sites More sharing options...
StSchnell Posted December 22, 2008 Author Share Posted December 22, 2008 Hello Reinhard, thanks for your tip and your example. I do not know the command setTimeout, but it sounds good. Cheers Stefan Meet me at XING Visit my private homepage Visit my commercial homepage Look at my book inter alia about AutoIt and SAP 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