AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems with hotkeys in script

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Mr Speaker
Guest





PostPosted: Sat Nov 21, 2009 4:54 am    Post subject: Problems with hotkeys in script Reply with quote

Hi,

I'm fairly new to AutoHotkey and need some assistance with this script.

Code:
HotKey, LWin & RCtrl, ResizeOn
return

HotKey, LWin & LCtrl, ResizeOff
return

ResizeOn:
{
   WinWait, ahk_class GHOST_WindowClass
   IfWinExist
   {
      WinMove, , , 0, 0, 2048, 768 ; move the window to 0,0 and reize it to 2048x768
      WinSet, Style, -0xC00000 ; remove the titlebar and border(s)   
   }   
}
return

ResizeOff:
{
   WinWait, ahk_class GHOST_WindowClass
   IfWinExist
   {
      WinMove, , , 0, 0, 1024, 768 ; move the window to 0,0 and reize it to 1024x768
      WinSet, Style, +0xC00000 ; Adds the titlebar and border(s)   
   }   
}
return

#NoTrayIcon


The script is supposed to make a specified application fullscreen for a dual monitor set up and remove the windows bar on hitting one key combination then return to normal size and replace the bar when the second key combination is used. When I press the key combination go make it full screen it works fine however when I hit the combination to return to a regular screen size it doesn't have any affect.

Any suggestions are much appreciated.

Regards,
Mr Speaker
Back to top
entropic



Joined: 21 Dec 2008
Posts: 161

PostPosted: Sat Nov 21, 2009 4:59 am    Post subject: Reply with quote

Give this a try. I made some changes to the code, changed the dynamic hotkeys to regular ones (the ones using the Hotkey command), removed braces in the ResizeOn and ResizeOff labels (they're only necessary for functions), and replaced the IfWinExist commands with checking ErrorLevel, it will be 0 if the window comes into existence, 1 if it does not, and I added a 5 second timeout to it so it doesn't wait indefinitely.
Code:

LWin & RCtrl::
   GoSub, ResizeOn
return

LWin & LCtrl::
   GoSub, ResizeOff
return

ResizeOn:
   WinWait, ahk_class GHOST_WindowClass,, 5
   If (ErrorLevel = 0)
   {
      WinMove, , , 0, 0, 2048, 768 ; move the window to 0,0 and reize it to 2048x768
      WinSet, Style, -0xC00000 ; remove the titlebar and border(s)   
   }   
return

ResizeOff:
   WinWait, ahk_class GHOST_WindowClass,, 5
   If (ErrorLevel = 0)
   {
      WinMove, , , 0, 0, 1024, 768 ; move the window to 0,0 and reize it to 1024x768
      WinSet, Style, +0xC00000 ; Adds the titlebar and border(s)   
   }   
return

#NoTrayIcon
Back to top
View user's profile Send private message
Mr Speaker
Guest





PostPosted: Sat Nov 21, 2009 5:24 am    Post subject: Reply with quote

Hi entropic,

Thanks it works perfectly, just what I needed. Very Happy

Thanks again,
Mr Speaker
Back to top
entropic



Joined: 21 Dec 2008
Posts: 161

PostPosted: Sat Nov 21, 2009 5:26 am    Post subject: Reply with quote

Glad I could help Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group