computergroove Posted November 18, 2010 Share Posted November 18, 2010 (edited) The following script creates a small window on the screen and then places a picture in the window and when I click the picture the program opens notepad. #include <GUIConstantsEx.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Local $Button1, $b1label, $height, $width, $hPosition, $vPosition $height = 100 $width = 100 $hPosition = $width $vPosition = 1 GUICreate("MAC Hovering Button", $width, $height, @DesktopWidth - $hPosition, $vPosition, $WS_POPUP, $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.jpg", -1, -1) GUICtrlSetState(-1, $GUI_DISABLE) Opt("GUICoordMode", 2) $b1label = GUICtrlCreateLabel("", 1, 1, $width, $height, 0x201) GUICtrlSetBkColor($b1label, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetOnEvent($b1label, "Change") GUISetState() While 1 Sleep(11) WEnd Func Change() If WinExists("[CLASS:Notepad]") Then; check to see if the MAC program is already running WinActivate("[CLASS:Notepad]"); makes MAC program active Else Run('notepad.exe') ; Starts MAC program EndIf EndFunc Func _Exit() Exit EndFunc ;==>_Exit The above works fine. When I click the button notepad opens. The problem I was having was re-sizing the picture to fit into the window. I was able to get the picture to auto re-size into the window by changing the following line from $Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.jpg", -1, -1) to $Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.jpg", -1, -1, $width, $height) and $Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.jpg", -1, -1, 100, 100) both of the above break the change() function. Why? I can re-edit the picture I want to use each time but I would like to avoid that if I can. There also seems to be a discrepancy between the desktop resolution and the width and height of the GUICreate and GUICtrlCreatePic functions. I can only assume that the width and height options are not measured in pixels. Edited November 20, 2010 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 18, 2010 Share Posted November 18, 2010 There also seems to be a discrepancy between the desktop resolution and the width and height of the GUICreate and GUICtrlCreatePic functions. I can only assume that the width and height options are not measured in pixels.You are a pixel. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
computergroove Posted November 19, 2010 Author Share Posted November 19, 2010 You are a pixel. What is that supposed to mean? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
computergroove Posted November 20, 2010 Author Share Posted November 20, 2010 OK I got it. I needed to remove: Opt("GUICoordMode", 2) Apparently it wasn't needed and was causing a problem. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html 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