XxIcONxX Posted May 15, 2007 Share Posted May 15, 2007 Hi guys i got a little problem that i hope u can help me to solve. Okay iv'e made a tiny shortcut program(im using imagebuttons) and im using an ini file to save the shortcut paths. but uh my question is is it possible to use the icon from the progarm that my shortcut points to ? And is it possible to make that automated ? ive been trying to do it like this but my app cant find the image ($ini[1][1] = c:/windows/system32/sol.exe) $ParentWin = GUICreate("Shortcut program =]",240,40,-1,-1,$ws_caption,$WS_EX_TOOLWINDOW) $button1 = GUICtrlCreateButton ("1", 0,0,40,40,$BS_ICON) GUICtrlSetImage (-1,$ini[1][1],-1) but that didnt work at all and then i tried with a regular image (not image button) and i used a resource hacker to find out the name of the icon. GUICtrlCreateIcon("c:/windows/system32/sol.exe",500,0,0) and it worked but yet... i want to use a imagebutton and i want my prog to find what value the display icon has automaticly. thanks ps im sorry for my bad english and i hope ur able to understand what im saying ds Link to comment Share on other sites More sharing options...
James Posted May 15, 2007 Share Posted May 15, 2007 So you want an image button to be a shortcut to your program? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
XxIcONxX Posted May 15, 2007 Author Share Posted May 15, 2007 (edited) yeah and i got that already but i want the icon in my app to be the same as the file it points to heres the source. expandcollapse popup;Include constants #include <GUIConstants.au3> Opt("TrayIconHide", 1) Global $page = 1 $ini = IniReadSection(@ScriptDir & "\settings.ini", $page) $ParentWin = GUICreate("Shortcut program =]", 240, 40, -1, -1, $ws_caption, $WS_EX_TOOLWINDOW) $button1 = GUICtrlCreateButton("1", 0, 0, 40, 40, $BS_ICON) GUICtrlSetImage(-1, $ini[1][1], -1) $button2 = GUICtrlCreateButton("2", 40, 00, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 7) $button3 = GUICtrlCreateButton("3", 80, 00, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 22) $button4 = GUICtrlCreateButton("4", 120, 0, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 23) $button5 = GUICtrlCreateButton("5", 160, 0, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 32) $button6 = GUICtrlCreateButton("close", 200, 0, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 21) WinSetOnTop("Shortcut program =]", "", 1) $ParentWin_Pos = WinGetPos($ParentWin, "") GUISetState(@SW_SHOW) $ChildWin = GUICreate("Settings", 232, 160, $ParentWin_Pos[0] + 100, $ParentWin_Pos[1] - 100) $Input_1 = GUICtrlCreateInput("", 10, 10, 150, 20) $Input_2 = GUICtrlCreateInput("", 10, 40, 150, 20) $Input_3 = GUICtrlCreateInput("", 10, 70, 150, 20) $Input_4 = GUICtrlCreateInput("", 10, 100, 150, 20) $input_5 = GUICtrlCreateInput("", 10, 130, 150, 20) $path1 = GUICtrlCreateButton("...", 170, 10, 50, 20) $path2 = GUICtrlCreateButton("...", 170, 40, 50, 20) $path3 = GUICtrlCreateButton("...", 170, 70, 50, 20) $path4 = GUICtrlCreateButton("...", 170, 100, 50, 20) $path5 = GUICtrlCreateButton("...", 170, 130, 50, 20) GUISwitch($ParentWin) While 1 $ini = IniReadSection(@ScriptDir & "\settings.ini", $page) $msg = GUIGetMsg(1) If $msg[0] = $button1 Then Run($ini[1][1]) If @error Then ContinueLoop If $msg[0] = $button2 Then Run($ini[2][1]) If @error Then ContinueLoop If $msg[0] = $button3 Then Run($ini[3][1]) If @error Then ContinueLoop If $msg[0] = $button4 Then Run($ini[4][1]) If @error Then ContinueLoop If $msg[0] = $button5 Then Run($ini[5][1]) If @error Then ContinueLoop If $msg[0] = $button6 Then $ini = IniReadSection(@ScriptDir & "\settings.ini", $page) GUICtrlSetData($Input_1, $ini[1][1]) GUICtrlSetData($Input_2, $ini[2][1]) GUICtrlSetData($Input_3, $ini[3][1]) GUICtrlSetData($Input_4, $ini[4][1]) GUICtrlSetData($input_5, $ini[5][1]) GUISetState(@SW_SHOW, $ChildWin) EndIf If $msg[0] = $path1 Then $sTmpFile = FileOpenDialog("Select file:", "C:/", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)") If @error Then ContinueLoop GUICtrlSetData($Input_1, $sTmpFile) EndIf If $msg[0] = $path2 Then $sTmpFile = FileOpenDialog("Select file:", "C:/", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)") If @error Then ContinueLoop GUICtrlSetData($Input_2, $sTmpFile) EndIf If $msg[0] = $path3 Then $sTmpFile = FileOpenDialog("Select file:", "C:/", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)") If @error Then ContinueLoop GUICtrlSetData($Input_3, $sTmpFile) EndIf If $msg[0] = $path4 Then $sTmpFile = FileOpenDialog("Select file:", "C:/", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)") If @error Then ContinueLoop GUICtrlSetData($Input_4, $sTmpFile) EndIf If $msg[0] = $path5 Then $sTmpFile = FileOpenDialog("Select file:", "C:/", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)") If @error Then ContinueLoop GUICtrlSetData($input_5, $sTmpFile) EndIf Select Case $msg[0] = $GUI_EVENT_CLOSE If $msg[1] = $ChildWin Then $data1 = GUICtrlRead($Input_1) $data2 = GUICtrlRead($Input_2) $data3 = GUICtrlRead($Input_3) $data4 = GUICtrlRead($Input_4) $data5 = GUICtrlRead($input_5) If $data1 <> $ini[1][1] Then IniWrite(@ScriptDir & "\settings.ini", $page, "button1", $data1) EndIf If $data2 <> $ini[2][1] Then IniWrite(@ScriptDir & "\settings.ini", $page, "button2", $data2) EndIf If $data3 <> $ini[3][1] Then IniWrite(@ScriptDir & "\settings.ini", $page, "button3", $data3) EndIf If $data4 <> $ini[4][1] Then IniWrite(@ScriptDir & "\settings.ini", $page, "button4", $data4) EndIf If $data4 <> $ini[5][1] Then IniWrite(@ScriptDir & "\settings.ini", $page, "button4", $data5) EndIf GUISwitch($ChildWin) GUISetState(@SW_HIDE, $ChildWin) ElseIf $msg[1] = $ParentWin Then GUISwitch($ParentWin) GUIDelete() Exit EndIf EndSelect WEnd Edited May 15, 2007 by XxIcONxX Link to comment Share on other sites More sharing options...
James Posted May 15, 2007 Share Posted May 15, 2007 Ahh right. Well lets say your using Windows Media Player as where you want the shortcut to goto right? Well we would do this. #include <GuiConstants.au3> $gui = GUICreate("Window", 400, 200, -1, -1) GuiCtrlCreateButton("Button", 100, 100, 100, 50, $BS_ICON) GUICtrlSetImage(-1, @ProgramFilesDir & '\Windows Media Player\wmplayer.exe', 1) GuiSetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Wend That should work, you may need to change the way the button links to. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
XxIcONxX Posted May 15, 2007 Author Share Posted May 15, 2007 oh yeah that worked... in that case somehow it doesnt work for other files =( i guess i have to use the regular icons from shell32.dll instead =| Link to comment Share on other sites More sharing options...
James Posted May 15, 2007 Share Posted May 15, 2007 Are you declaring the icon number? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
XxIcONxX Posted May 15, 2007 Author Share Posted May 15, 2007 hmm it didn't work when i used the number... well i want the app to take the first possible icon and use that instead, since i want it to be more dynamic. But i guess i'll stick around with shell32.dll thanks for the help tho Link to comment Share on other sites More sharing options...
James Posted May 15, 2007 Share Posted May 15, 2007 (edited) OK then. Right, so when you try and use it what are you trying to add? Edited May 15, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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