legolaas Posted March 9, 2015 Share Posted March 9, 2015 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> $Main = GUICreate('GUI', 200, 100) $hDownload1 = InetGet('https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif',@ScriptDir&'/paypal.gif') $Button = GUICtrlCreatePic('', 10, 35, 100,51) GUICtrlSetCursor(-1,0) iconbutton_1($Button) GUISetState() Do $msg = GUIGetMsg() $hov=GUIGetCursorInfo() if $hov[2]=1 and $hov[4]=$Button Then ShellExecute("http://google.com",1) sleep(50) Until $msg = $GUI_EVENT_CLOSE Func iconbutton_1($control) _GDIPlus_Startup() $hwd = GUICtrlGetHandle($control) $width = _WinAPI_GetClientWidth($hwd) $height = _WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) $hBitmap1 = _ImageDrawicon($hBitmap1,@ScriptDir&'/paypal.gif',100,51) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _WinAPI_DeleteObject($hBMP1) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc Func _ImageDrawicon($hImage, $picture, $iW, $iH, $iX = 0, $iY = 0) $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic1) $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage, 0, 0, $iW, $iH) Global $icon = _GDIPlus_ImageLoadFromFile($picture) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $icon, $iX, $iY, $iW, $iH) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_GraphicsDispose ($hGraphic1) Return $hBitmap EndFunc Shellexecute kısmında sıkıntı var hata veriyor. Yardımınızı bekliyorum. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted March 9, 2015 Share Posted March 9, 2015 Verilen hatayı da yazarsanız daha iyi yardımcı olabiliriz. Quote Link to comment Share on other sites More sharing options...
legolaas Posted March 10, 2015 Author Share Posted March 10, 2015 Verilen hatayı da yazarsanız daha iyi yardımcı olabiliriz. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted March 10, 2015 Share Posted March 10, 2015 Kod bende sorunsuz çalışıyor. Sizin verdiğiniz hata ekranında ise hatanın ShelExecute kısmında değil de $hov kısmında yani GUIGetCursorInfo fonksiyonunda hata olduğuna işaret ediyor. Bir sebepten ötürü konum bilgisini veya tıklama bilgisini alamıyor olabilir. Bunun yerine başka bir yöntemle kodu aşağıdaki gibi düzelttim. GUI düzenlemelerinizi aşağıdaki yöntemle de yapabilirsiniz. Yapmaya çalıştığınız şeyin tam olarak aynısını yapmakta. Sorun olursa tekrar bildirin, ilgilenelim. #include <GUIConstantsEx.au3> #include <GDIPlus.au3> $Main = GUICreate('GUI', 200, 100) $hDownload1 = InetGet('https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif',@ScriptDir&'/paypal.gif') $Button = GUICtrlCreatePic('', 10, 35, 100,51) GUICtrlSetCursor(-1,0) iconbutton_1($Button) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE exit case $Button ShellExecute("www.google.com") EndSwitch WEnd Func iconbutton_1($control) _GDIPlus_Startup() $hwd = GUICtrlGetHandle($control) $width = _WinAPI_GetClientWidth($hwd) $height = _WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) $hBitmap1 = _ImageDrawicon($hBitmap1,@ScriptDir&'/paypal.gif',100,51) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _WinAPI_DeleteObject($hBMP1) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc Func _ImageDrawicon($hImage, $picture, $iW, $iH, $iX = 0, $iY = 0) $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic1) $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage, 0, 0, $iW, $iH) Global $icon = _GDIPlus_ImageLoadFromFile($picture) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $icon, $iX, $iY, $iW, $iH) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_GraphicsDispose ($hGraphic1) Return $hBitmap EndFunc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.