VSiAQ Posted December 18, 2005 Share Posted December 18, 2005 I've used AutoIt for a long time and now need some help. English isn't my native language and it's difficult to express my idea. Sorry about that. I'm currently writing a script that involve making GUI. The GUI only contains an Input box, which allows me to type a command in, and press Enter to process. It's actually a Tool window. I created it by using this code: $gui = GuiCreate($title, $width, $height, $left, $top, $WS_CLIPSIBLINGS + $WS_SYSMENU, $WS_EX_ACCEPTFILES + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) All the needed variables are declared before that. The "Console", or actually the input box is created with this: $console = GuiCtrlCreateInput("", 0, 0, $console_width, $console_height, $ES_AUTOHSCROLL + $GUI_FOCUS + $GUI_ACCEPTFILES) Everytime the user drag-and-drop a file or folder into this console, my GUI will trigger the hotkey: - If he press "Enter", my app will open the file / folder for him. - If he press "Ctrl + Enter", the app will "scroll down" to display some extra options, like create a shortcut for the file / folder. I "scroll down" the app by using the following code: Func WinScroll($right, $down) $inc = 0 While $inc < $right $inc = $inc + 1 WinMove($title, "", $left, $top, $width + $inc, $height) WEnd $newwidth = $width + $right $inc = 0 While $inc < $down $inc = $inc + 1 WinMove($title, "", $left, $top, $newwidth, $height + $inc) WEnd $newheight = $height + $down EndFunc After that, the app will create some more controls on the GUI: GuiCtrlSetState($console, $GUI_DISABLE) WinScroll(140, 35) $add_label = GuiCtrlCreateLabel("Shortcut name: ", 5, $console_height + 10) $add_name = GuiCtrlCreateInput("", 80, $console_height + 5, 140, $console_height, $ES_AUTOHSCROLL) GuiCtrlSetState($add_name, $GUI_FOCUS) $add_ok = GuiCtrlCreateButton("Add", 225, $console_height + 3, 50) $add_cancel = GuiCtrlCreateButton("Cancel", 280, $console_height + 3, 50) To add a shortcut after clicking Add button, I add these lines to the loop: Select Case $msg = $add_ok AddShortcut(); my function ;;; other cases EndSelect When the shortcut is added, or the user press Cancel, the app will scroll back and delete all controls: WinScrollBack(); my function GuiCtrlDelete($add_name) GuiCtrlDelete($add_label) GuiCtrlDelete($add_ok) GuiCtrlDelete($add_cancel) It works perfectly until I want to add some more features to my app. Like triggering Alt + Enter, then scroll back and display an extra menu, allow users to add a group of files/folders. I use the same scenario as the add shortcut funcition above. However, the above function go away as soon as my new function works. I mean, the add function no longer work. When I press Ctrl + Enter, the app scroll down and immediatelly scroll back, althought I don't click Cancel or adding shortcut. Why does it happen? I haven't found out the reason and now needing help. Urgent! I want to finish this app and send it as a gift to my best friend before Xmas. Please help me. Any ideas/suggestions are welcomed. Thanks million times! Link to comment Share on other sites More sharing options...
Valuater Posted December 18, 2005 Share Posted December 18, 2005 (edited) you only gave us bits and pieces of your script... not enough there to "guess" what the problem isUrgent! I want to finish this app and send it as a gift to my best friend before Xmas. Please help me.Any ideas/suggestions are welcomed. Thanks million times!if thats true.. you have two choices1post your script.. so we can help2dont post your script and pay someone to help you8) Edited December 18, 2005 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted December 18, 2005 Share Posted December 18, 2005 xmas is comming in 2006 too! 8) Link to comment Share on other sites More sharing options...
VSiAQ Posted December 18, 2005 Author Share Posted December 18, 2005 I attach my script here.VSiAQ.au3 Link to comment Share on other sites More sharing options...
VSiAQ Posted December 18, 2005 Author Share Posted December 18, 2005 Sorry to post twice in a row. Just to describe the problem more precisely. If you drag a file into the console, then press Ctrl+Enter, the app will scroll down and then scroll back at once. It should stay there until I click Cancel or finish adding shortcut. Or, at least, it was what I tried to do. Thing goes fine in the version I attach here Link to comment Share on other sites More sharing options...
Valuater Posted December 19, 2005 Share Posted December 19, 2005 (edited) nice work... very good 1 i cannot run the script as i do not have the ini files and the script crashes 2 maybe try to create the"added" controls in the beginning... then immediately hide them ... then when the system scrolls down "show" the controls... and instead of deleting them.. hide them again example expandcollapse popup#Include <GUIConstants.au3> ; Default values for main gui $title = "Dorevo" $width = 500 $height = 400 $left = 300;@DesktopWidth - $width / 2 $top = 300;@DesktopHeight - $height / 2 ; Default values for console $console_height = 20 $console_width = $width $newwidth = $width $newheight = $height ; Create gui & console $gui = GuiCreate($title, $width, $height, $left, $top, $WS_CLIPSIBLINGS + $WS_SYSMENU, $WS_EX_ACCEPTFILES + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $console = GuiCtrlCreateInput("", 0, 0, $console_width, $console_height, $ES_AUTOHSCROLL + $GUI_FOCUS) GUICtrlSetState ($console, $GUI_ACCEPTFILES) ; create the buttons then hide or expand the window ( your choice ) $xpand = GUICtrlCreateButton( "Xpand the window", 200, 110, 100, 20) $hide = GUICtrlCreateButton( "Hide controls", 100, 310, 100, 20) $dummy = GUICtrlCreateButton( "Dummy control", 200, 310, 100, 20) $show = GUICtrlCreateButton( "Show controls", 300, 310, 100, 20) ; set and hide gui GuiSetState(@SW_HIDE) ; hide controls GUICtrlSetState($hide, $GUI_HIDE ) GUICtrlSetState($dummy, $GUI_HIDE ) GUICtrlSetState($show, $GUI_HIDE ) WinMove($title, "", $left, $top, $width, 100) GuiSetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $xpand Set_xpand() Case $msg = $hide Set_hide() Case $msg = $show Set_show() EndSelect WEnd ; ---------- Functions ----------- func Set_xpand() If GUICtrlRead($xpand) = "Xpand the window" Then $inc = 100 While $inc < 400 $inc = $inc + 1 WinMove($title, "", $left, $top, $width, $inc) WEnd Set_show() GUICtrlSetData($xpand, "Shrink the window") Else Set_hide() GUICtrlSetState($show, $GUI_HIDE ) $inc = 400 While $inc > 100 $inc = $inc - 1 WinMove($title, "", $left, $top, $width, $inc) WEnd GUICtrlSetState($xpand, $GUI_SHOW ) GUICtrlSetData($xpand, "Xpand the window") EndIf EndFunc Func Set_hide() GUICtrlSetState($xpand, $GUI_HIDE ) GUICtrlSetState($dummy, $GUI_HIDE ) GUICtrlSetState($hide, $GUI_HIDE ) EndFunc Func Set_show() GUICtrlSetState($xpand, $GUI_SHOW ) GUICtrlSetState($dummy, $GUI_SHOW ) GUICtrlSetState($hide, $GUI_SHOW ) GUICtrlSetState($show, $GUI_SHOW ) EndFunc hope that helps 8) Edited December 19, 2005 by Valuater 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