Change hotkeys when fullscreen app is active Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest

Change hotkeys when fullscreen app is active  Topic is solved

04 May 2017, 06:56

I found this thread: https://autohotkey.com/board/topic/3265 ... ntry208939

There are two scripts that should detect if the app active is fullscreen or not.

The first script doesn't works very well for me.

Code: Select all

;---Check if Full Screen Active Subroutine
Check_FullScreenActive:
wingetpos,,,w,h,A
wwwh=%w%%h%
swsh=%a_screenwidth%%a_screenheight%
WinGet, Style, Style, A
FullScreenActive := false
if !(Style & 0xC00000) {
  if(wwwh = swsh) {
    FullScreenActive := true
  }
}
return
An example of it's usage:

Code: Select all

#a::
Gosub Check_FullScreenActive
If !(FullScreenActive) {
  msgbox not full screen
}
return
The author post this one a few days later saying that it was been improved but I can't get it to work.

Code: Select all

[color=red]Gui +LastFound[/color]
hAB := WinExist(), L := 0
ABM := DllCall( "RegisterWindowMessage", Str,"AppBarMsg" )
WinGetPos, GX,GY,GW,GH, ahk_id %hAB%
VarSetCapacity( APPBARDATA,36,0 ) ; http://msdn2.microsoft.com/en-us/library/ms538008.aspx
Off := NumPut(36,APPBARDATA), Off :=  NumPut( hAB, Off+0 ), Off :=  NumPut( ABM, Off+0 )
Off := NumPut(   1, Off+0 ) , Off :=  NumPut(  GX, Off+0 ), Off :=  NumPut(  GY, Off+0 )
Off := NumPut(  GW, Off+0 ) , Off :=  NumPut(  GH, Off+0 ), Off :=  NumPut(   1, Off+0 )
DllCall( "Shell32.dll\SHAppBarMessage", UInt,(ABM_NEW:=0x0), UInt,&APPBARDATA ) 
OnMessage( ABM, "ABM_Callback" )  
OnExit, QuitScript
Return

ABM_Callback( wParam, LParam, Msg, HWnd ) {
  Global L
  If (LParam != L) {
    L := LParam
  }
  Return 
}

QuitScript:
  DllCall("Shell32.dll\SHAppBarMessage", UInt,(ABM_REMOVE := 0x1), UInt,&APPBARDATA )
  ExitApp
Return

; L variable 1 if fullscreen 0 if not
#y:: msgbox %L%
When I try to run it AHK says that the first line

Code: Select all

[color=red]Gui +LastFound[/color]
does not contain a recognized action.
After searching a little bit it looks like the correct line is Gui +LastFound and the is just code to mark the text in red in this forum
https://autohotkey.com/docs/commands/Gui.htm#LastFound
So I try with the next code:

Code: Select all

Gui +LastFound
hAB := WinExist(), L := 0
ABM := DllCall( "RegisterWindowMessage", Str,"AppBarMsg" )
WinGetPos, GX,GY,GW,GH, ahk_id %hAB%
VarSetCapacity( APPBARDATA,36,0 ) ; http://msdn2.microsoft.com/en-us/library/ms538008.aspx
Off := NumPut(36,APPBARDATA), Off :=  NumPut( hAB, Off+0 ), Off :=  NumPut( ABM, Off+0 )
Off := NumPut(   1, Off+0 ) , Off :=  NumPut(  GX, Off+0 ), Off :=  NumPut(  GY, Off+0 )
Off := NumPut(  GW, Off+0 ) , Off :=  NumPut(  GH, Off+0 ), Off :=  NumPut(   1, Off+0 )
DllCall( "Shell32.dll\SHAppBarMessage", UInt,(ABM_NEW:=0x0), UInt,&APPBARDATA ) 
OnMessage( ABM, "ABM_Callback" )  
OnExit, QuitScript
Return

ABM_Callback( wParam, LParam, Msg, HWnd ) {
  Global L
  If (LParam != L) {
    L := LParam
  }
  Return 
}

QuitScript:
  DllCall("Shell32.dll\SHAppBarMessage", UInt,(ABM_REMOVE := 0x1), UInt,&APPBARDATA )
  ExitApp
Return

; L variable 1 if fullscreen 0 if not
#y:: msgbox %L%
Now it runs but sends a blank msgbox wherever I test it.

Sombody knows what I am doing wrong?

PD: I find others scripts wich should do the same but they look way more recurse intensive and/or less compatible with other setups.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Xaucy and 158 guests