AutoHotkey Community

It is currently May 27th, 2012, 11:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: January 30th, 2012, 9:34 am 
Online

Joined: December 24th, 2011, 11:21 am
Posts: 22
Location: Mexicali
Ok, what I want is to center an image on a Fullscreen Gui, I mean don't matter the resolution of the screen or the size of the image, just to always center the image

Like these examples:
Image
Image

I don't know if it could be possible to get first the resolution of the image and then with some operations calculate automatically by ScreenWidth and ScreenHeight the way to center the image.
Also I don't know if there's another effective way to centering the image.

I have this code for now:
Code:
Gui 1:-owner toolwindow -caption +LastFound
hwnd:=WinExist()
WinSet,Transparent,0,ahk_id %hwnd%
Gui, Margin, 0,0
Gui, Show, % "W" . A_ScreenWidth . " H" . A_ScreenHeight . " X0 Y0"
Return
ESC::
GuiClose:
 ExitApp   


The code creates the fullscreen Gui but not the image or centering the image, that's what I need,.
I searched A LOT in the forum and I didn't get the solution to my needs,
I want to mention that I don't want to stretching the image, just centering, so could use Gui color to the rest of the Gui

Please someone help me with this to finish my project.


Last edited by Edd on February 3rd, 2012, 4:07 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 11:16 am 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
Code:
Gui, Margin, 0,0
Gui 1:-owner -toolwindow -caption +LastFound
Gui, Add, Picture, vMyPic, C:\mypicture.jpg
Gui, Show, % "W" . A_ScreenWidth . " H" . A_ScreenHeight . " X0 Y0", My GUI
GuiControlGet, Pic, Pos, MyPic
xx := (A_ScreenWidth-picw)/2
yy := (A_ScreenHeight-pich)/2
GuiControl, MoveDraw, MyPic, x%xx% y%yy%
WinSet,Transparent,0 ,My GUI
Return

ESC::
GuiClose:
ExitApp

Change the C:/mypicture.jpg to your own image

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 11:31 am 
Online

Joined: December 24th, 2011, 11:21 am
Posts: 22
Location: Mexicali
It works!THANKS!:D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 11:36 am 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
Image

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 3:03 pm 
I answered something similar with an example here:

http://www.autohotkey.com/forum/post-509191.html#509191


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 5:24 pm 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
The Pic control will do it for you:
Code:
SS_CENTERIMAGE := 0x0200
PicPath := A_ScriptDir . "\AutoHotkey_logo.gif"    ; change to fit your needs
GuiColor := "Black"                                ; "
Gui, +Owner -Caption +LastFound
Gui, Color, %GuiColor%
Gui, Margin, 0,0
Gui, Add, Pic, Center %SS_CENTERIMAGE% vMyPic, %PicPath%
GuiControl, Move, MyPic, w%A_ScreenWidth% h%A_ScreenHeight%
Gui, Show, AutoSize, My GUI
Return
ESC::
GuiClose:
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject: A little thing more..
PostPosted: February 2nd, 2012, 1:21 am 
Online

Joined: December 24th, 2011, 11:21 am
Posts: 22
Location: Mexicali
A little thing more..
Now I need this

Code:

Gui, Margin, 0,0
Gui 1:-owner -toolwindow -caption +LastFound
hwnd:=WinExist()
WinSet,Transparent,0,ahk_id %hwnd%
Gui, Add, Picture, vMyPic, image.jpg
Gui, Show, % "W" . A_ScreenWidth . " H" . A_ScreenHeight . " X0 Y0", My GUI
GuiControlGet, Pic, Pos, MyPic
xx := (A_ScreenWidth-picw)/2
yy := (A_ScreenHeight-pich)/2
GuiControl, MoveDraw, MyPic, x%xx% y%yy%
WinSet, bottom,,ahk_id %hwnd%
WinSet,Transparent,OFF,ahk_id %hwnd%
Return
ESC::
GuiClose:
ExitApp



I want to start showing the gui hidden to the user until it's set to bottom, so the user can only see the gui by minimizing all the windows.
I have that code now, but the gui appears to the user like a second or less then It's set to bottom, but how can I avoid to show the gui before it's not set to bottom?
Thanks :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 2:54 am 
Offline

Joined: December 27th, 2011, 7:06 pm
Posts: 31
Would this be what you mean?
Quote:
Hide: Hides the window and activates the one beneath it. This is identical in function to Gui Cancel except that it allows a hidden window to be moved, resized, or given a new title without showing it. For example: Gui, Show, Hide x55 y66 w300 h200, New Title


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 2:51 pm 
Online

Joined: December 24th, 2011, 11:21 am
Posts: 22
Location: Mexicali
Sorry I don't understand, I tried to implement it but It doesn't works


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 3:35 pm 
Offline

Joined: November 12th, 2011, 2:24 pm
Posts: 122
You could create it offscreen and move it afterwards.

Code:
Gui, Margin, 0,0
Gui 1:-owner -toolwindow -caption +LastFound
hwnd:=WinExist()

Gui, Add, Picture, vMyPic, image.jpg
Gui, Show, W%A_ScreenWidth% H%A_ScreenHeight%  X%A_ScreenWidth% Y0, My GUI
GuiControlGet, Pic, Pos, MyPic
xx := (A_ScreenWidth-picw)/2
yy := (A_ScreenHeight-pich)/2
GuiControl, MoveDraw, MyPic, x%xx% y%yy%
WinSet, bottom,,ahk_id %hwnd%
WinMove, ahk_id %hwnd%,,0,0

Return
ESC::
GuiClose:
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 4:24 pm 
Online

Joined: December 24th, 2011, 11:21 am
Posts: 22
Location: Mexicali
Oh, this works good, but now the image flickers the first time that the Gui is shown, how can I avoid that?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 4:38 pm 
Offline

Joined: November 12th, 2011, 2:24 pm
Posts: 122
Can you give some detail.The first time it is shown it is offscreen (or should be ) so you cannot see it.

Here i put a sleep 5000 so you can only see it after 5sec when it has been moved.Does it flicker before the 5sec?



Code:
Gui, Margin, 0,0
Gui 1:-owner -toolwindow -caption +LastFound
hwnd:=WinExist()

Gui, Add, Picture, vMyPic, image.jpg
Gui, Show, W%A_ScreenWidth% H%A_ScreenHeight%  X%A_ScreenWidth% Y0, My GUI
GuiControlGet, Pic, Pos, MyPic
xx := (A_ScreenWidth-picw)/2
yy := (A_ScreenHeight-pich)/2
GuiControl, MoveDraw, MyPic, x%xx% y%yy%
WinSet, bottom,,ahk_id %hwnd%
sleep 5000
WinMove, ahk_id %hwnd%,,0,0

Return
ESC::
GuiClose:
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 4:45 pm 
Online

Joined: December 24th, 2011, 11:21 am
Posts: 22
Location: Mexicali
yes:/ it flickers at the time that I minimize all windows to see the Gui, then It flickers.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 5:16 pm 
Online

Joined: December 24th, 2011, 11:21 am
Posts: 22
Location: Mexicali
It seems I fixed:D
Code:
Gui, Margin, 0,0
Gui, Color, 000000
Gui 1:+owner -caption +LastFound
hwnd:=WinExist()
Gui, Add, Picture, vMyPic, image.jpg
Gui, Show, W%A_ScreenWidth% H%A_ScreenHeight%  X%A_ScreenWidth% Y0, My GUI
GuiControlGet, Pic, Pos, MyPic
xx := (A_ScreenWidth-picw)/2
yy := (A_ScreenHeight-pich)/2
GuiControl, MoveDraw, MyPic, x%xx% y%yy%
WinSet, bottom,,ahk_id %hwnd%
WinMove, ahk_id %hwnd%,,0,0
Return
ESC::
GuiClose:
ExitApp


only needed to change it to +owner
Thanks to all!:D


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Edd and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group