MichaelB 0 Posted July 27, 2007 I have finally progressed past little AUTOIT scripts that do just what the name implies. My latest endeavor is a desktop app launcher,strictly as a learning experience. My problem rears its ugly head when I attempt to write a right-click routine to open a FILE SELECT GUI. Up to here, I have a nice little interface with a bunch of buttons and obviously the ability to close the app. I want to right click on a button and have a FILE SELECT box come up. I need to return the selected executable (along with an icon ) to the button that I right clicked on, and have a link there to start the program. I realize that just about ANYBODY could write what I have so far, but now I'm ready to progress. I have gotten as far as GUICtrlCreateContextMenu and come to a screeching halt. I know this sounds like I want someone to write the code for me, but that is not the case. I just need some pointers as to how to get AUTOIT to do my bidding. Any and all help will be greatly appreciated as I struggle forward making great advances in software. michaelb Share this post Link to post Share on other sites
smashly 12 Posted July 27, 2007 Hi, Hope this crude example helps#include <GuiConstants.au3> Global $PathToFile $Gui = GUICreate("Context Buttons", 220, 60) $Icon = GUICtrlCreateIcon("shell32.dll",1 ,16,16,16,16) GUICtrlSetState(-1, $GUI_DISABLE) $Button = GUICtrlCreateButton("Right Click To Set..", 10, 10, 200, 30, $WS_CLIPSIBLINGS) $Context = GUICtrlCreateContextMenu($Button) $ContextMenu = GUICtrlCreateMenuitem("Browse for file", $Context) GuiSetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $ContextMenu $FileOpen = FileOpenDialog("Browse...", @ProgramFilesDir, "Executable (*.exe)",3) If @error <> 1 Then $PathToFile = $FileOpen $Sp = StringSplit($FileOpen, "\") GUICtrlSetImage($Icon, $FileOpen, 0, 0) GuiCtrlSetData($Button, StringTrimRight($Sp[$Sp[0]], 4)) EndIf Case $msg = $Button If FileExists($PathToFile) Then ShellExecute($PathToFile) Else MsgBox(0,"Assign file to button..", "You need to assign a file to the button first", 3) EndIf EndSelect WEnd Cheers Share this post Link to post Share on other sites
cmichaelb 0 Posted August 5, 2007 Hi, Hope this crude example helps#include <GuiConstants.au3> Global $PathToFile $Gui = GUICreate("Context Buttons", 220, 60) $Icon = GUICtrlCreateIcon("shell32.dll",1 ,16,16,16,16) GUICtrlSetState(-1, $GUI_DISABLE) $Button = GUICtrlCreateButton("Right Click To Set..", 10, 10, 200, 30, $WS_CLIPSIBLINGS) $Context = GUICtrlCreateContextMenu($Button) $ContextMenu = GUICtrlCreateMenuitem("Browse for file", $Context) GuiSetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $ContextMenu $FileOpen = FileOpenDialog("Browse...", @ProgramFilesDir, "Executable (*.exe)",3) If @error <> 1 Then $PathToFile = $FileOpen $Sp = StringSplit($FileOpen, "\") GUICtrlSetImage($Icon, $FileOpen, 0, 0) GuiCtrlSetData($Button, StringTrimRight($Sp[$Sp[0]], 4)) EndIf Case $msg = $Button If FileExists($PathToFile) Then ShellExecute($PathToFile) Else MsgBox(0,"Assign file to button..", "You need to assign a file to the button first", 3) EndIf EndSelect WEnd Cheers To SMASHLY - I am forever in your debt. Your code is right on the money. I haven't learned as much as I wanted to, but the frustration factor has all but vanished. Thanks So Much, MichaelB Share this post Link to post Share on other sites
Generator 0 Posted August 5, 2007 Some good example in my launcher, feel free to use it. Share this post Link to post Share on other sites