Borje Posted April 6, 2009 Share Posted April 6, 2009 (edited) Hi everybody I have problem with this script I can not find the problem I think that is som problem with loop's ? I need little help to have that to work. The problem is when I select a number the open file dialog box not displayed in center of the window, but if I run only the snippet it works when I not #include <GUIConstants.au3> and the first Gui pops up that is also a problem. Please can anybody help me with this, many thanks. [#include <GUIConstants.au3> #include <EditConstants.au3> Local $msg Global $val $GUI = GUICreate(" Select a number !", 400,170, @DesktopWidth/2-200, @DesktopHeight/2-110, -1 ); WS_EX_ACCEPTFILES GUISetBkColor (0x00E0FFFF) GUICtrlCreateLabel("1 = ????? 00000: 0000", 13, 10, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("5 = ????? 00000 0000", 252, 10, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("2 = ????? 00000 0000", 13, 35, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("6 = ????? 00000 0000", 252, 35, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("3 = ????? 00000 0000", 13, 60, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("7 = ????? 00000 0000", 252, 60, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("4 = ????? 00000 0000", 13, 85, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("8 = ????? 00000 0000", 252, 85, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("-----------------------------------------------------------", 13, 110, 400) GUICtrlCreateLabel("-----------------------------------------------------------", 206, 110, 400) $val = GUICtrlCreateInput("", 190, 107, 15, 20,$ES_NUMBER) GUICtrlCreateIcon(@ScriptFullPath, -1, 177, 40, 32, 32) GUICtrlCreateIcon(@ScriptFullPath, -1, 13, 128, 32, 32) GUICtrlCreateIcon(@ScriptFullPath, -1, 355, 128, 32, 32) ;$ok = GUICtrlCreateButton ("Ok", 110, 133, 80, 25) $av = GUICtrlCreateButton("Avbryt", 160, 133, 80, 25) GUISetState(@SW_SHOW, $GUI) While 1 if GUICtrlRead($val) = 0 then GUICtrlSetData($val,"") ElseIf GUICtrlRead($val) <> "" Then ExitLoop EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $av GUIDelete($GUI) Exit ;Terminate()Exit; close EndSwitch WEnd GUIDelete($GUI) ;------------------------------------------------------------ Snippet --------------------------------------------------------------- If StringInStr($cmdlineraw, '/MoveWin') Then $cmdlineraw = StringSplit(StringMid($cmdlineraw, StringInStr($cmdlineraw, '/MoveWin')), ':') While 1 Select Case WinExists($cmdlineraw[2]) $size = WinGetPos($cmdlineraw[2]) $PosX = @DesktopWidth / 2 - $size[2] / 2 $PosY = @DesktopHeight / 2 - $size[3] / 2 WinMove($cmdlineraw[2], "", $PosX, $PosY) WinActivate($cmdlineraw[2]) ExitLoop EndSelect Sleep(50) WEnd Exit EndIf $PID = _FindBrowseWin('Open file Dialog Box') $Read_File = FileOpenDialog("Open file Dialog Box", @ScriptDir & "\", "AutoIt Files (*.au3)", 3, @ScriptFullPath) ProcessClose($PID) Func _FindBrowseWin($sTitle) If @Compiled Then Return (Run(@ScriptFullPath & ' /MoveWin:' & $sTitle)) Else Return (Run(@AutoItExe & ' "' & @ScriptFullPath & '" /MoveWin:' & $sTitle)) EndIf EndFunc ;==>_FindBrowseWin ;------------------------------------------------------------ Snippet --------------------------------------------------------------- ;After Filedialog is displayed and after selected a file I would like to, come here /] Edited April 6, 2009 by Borje Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 6, 2009 Share Posted April 6, 2009 Hi everybody I have problem with this script I can not find the problem I think that is som problem with loop's ? I need little help to have that to work. The problem is when I select a number the open file dialog box not displayed in center of the window, but if I run only the snippet it works when I not #include <GUIConstants.au3> and the first Gui pops up that is also a problem. Please can anybody help me with this, many thanks. CODE#include <GUIConstants.au3> #include <EditConstants.au3> Local $msg Global $val $GUI = GUICreate(" Select a number !", 400,170, @DesktopWidth/2-200, @DesktopHeight/2-110, -1 ); WS_EX_ACCEPTFILES GUISetBkColor (0x00E0FFFF) GUICtrlCreateLabel("1 = ????? 00000: 0000", 13, 10, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("5 = ????? 00000 0000", 252, 10, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("2 = ????? 00000 0000", 13, 35, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("6 = ????? 00000 0000", 252, 35, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("3 = ????? 00000 0000", 13, 60, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("7 = ????? 00000 0000", 252, 60, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("4 = ????? 00000 0000", 13, 85, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("8 = ????? 00000 0000", 252, 85, 400) GUICtrlSetFont(-1, 10, 400, 1) GUICtrlCreateLabel("-----------------------------------------------------------", 13, 110, 400) GUICtrlCreateLabel("-----------------------------------------------------------", 206, 110, 400) $val = GUICtrlCreateInput("", 190, 107, 15, 20,$ES_NUMBER) GUICtrlCreateIcon(@ScriptFullPath, -1, 177, 40, 32, 32) GUICtrlCreateIcon(@ScriptFullPath, -1, 13, 128, 32, 32) GUICtrlCreateIcon(@ScriptFullPath, -1, 355, 128, 32, 32) ;$ok = GUICtrlCreateButton ("Ok", 110, 133, 80, 25) $av = GUICtrlCreateButton("Avbryt", 160, 133, 80, 25) GUISetState(@SW_SHOW, $GUI) While 1 if GUICtrlRead($val) = 0 then GUICtrlSetData($val,"") ElseIf GUICtrlRead($val) <> "" Then ExitLoop EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $av GUIDelete($GUI) Exit ;Terminate()Exit; close EndSwitch WEnd GUIDelete($GUI);------------------------------------------------------------ Snippet --------------------------------------------------------------- CODEIf StringInStr($cmdlineraw, '/MoveWin') Then $cmdlineraw = StringSplit(StringMid($cmdlineraw, StringInStr($cmdlineraw, '/MoveWin')), ':') While 1 Select Case WinExists($cmdlineraw[2]) $size = WinGetPos($cmdlineraw[2]) $PosX = @DesktopWidth / 2 - $size[2] / 2 $PosY = @DesktopHeight / 2 - $size[3] / 2 WinMove($cmdlineraw[2], "", $PosX, $PosY) WinActivate($cmdlineraw[2]) ExitLoop EndSelect Sleep(50) WEnd Exit EndIf $PID = _FindBrowseWin('Open file Dialog Box') $Read_File = FileOpenDialog("Open file Dialog Box", @ScriptDir & "\", "AutoIt Files (*.au3)", 3, @ScriptFullPath) ProcessClose($PID) Func _FindBrowseWin($sTitle) If @Compiled Then Return (Run(@ScriptFullPath & ' /MoveWin:' & $sTitle)) Else Return (Run(@AutoItExe & ' "' & @ScriptFullPath & '" /MoveWin:' & $sTitle)) EndIf EndFunc ;==>_FindBrowseWin ;------------------------------------------------------------ Snippet --------------------------------------------------------------- ;After Filedialog is displayed and after selected a file I would like to, come here Try the loop like this: ; $val = Control ID of an input While 1 If GUICtrlRead($val) <> "" Then If GUICtrlRead($val) = 0 Then GUICtrlSetData($val, "") Else ExitLoop EndIf EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $av GUIDelete($GUI) Exit EndSwitch WEnd I think you are getting unexpected result from comparing a string to a numeric 0 in your version. AutoIt attempts to automatically deal with mismatched variable types, but you have to be very aware of the assumptions it makes. For example "" = 0 = True. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Borje Posted April 6, 2009 Author Share Posted April 6, 2009 Thanks PsaltyDS I have try the code but it not works perhaps I missunderstand what you mean. Link to comment Share on other sites More sharing options...
Borje Posted April 6, 2009 Author Share Posted April 6, 2009 When I select a number in GUI the file opendialog not in center of screen and after fileopendialog the GUI popup again why? When I select a number in GUI the second time the fileopen go to the middle why? I can not have this to work. Link to comment Share on other sites More sharing options...
Borje Posted April 6, 2009 Author Share Posted April 6, 2009 The problem is solved ! I put this in beginning of the code and all is work after that. this section of code I put in the beginning of script: If StringInStr($cmdlineraw, '/MoveWin') Then $cmdlineraw = StringSplit(StringMid($cmdlineraw, StringInStr($cmdlineraw, '/MoveWin')), ':') While 1 Select Case WinExists($cmdlineraw[2]) $size = WinGetPos($cmdlineraw[2]) $PosX = @DesktopWidth / 2 - $size[2] / 2 $PosY = @DesktopHeight / 2 - $size[3] / 2 WinMove($cmdlineraw[2], "", $PosX, $PosY) WinActivate($cmdlineraw[2]) ExitLoop EndSelect Sleep(50) WEnd Exit EndIf $PID = _FindBrowseWin('Open file Dialog Box') Thanks to all for the help 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