Inteli Button: The only button you'll ever need (Custom Tool)

Page 1 of 1 (4 items)
This post has 3 Replies | 2 Followers

Posts 443
PJ | Forum Activity | Posted: Tue, Jun 15 2021 3:10 AM

Purpose
This is a Generic Button (Custom Tool).
It associates Any Layout with Any Panel of your choice.
One button can therefore have different Actions depending on the Active Layout.
With this Button and Duplicates thereof you can generate a Layout Specific ShortCutsBar in Logos.
The icon in MessageBox Titles can be extracted from the executable you use, Logos or Verbum. (Change the Value of SetIcon in line 3 to 1 and recompile the script)

Executable or Script
You can use any version, Script or Executable.
The executable is standalone.
To run the script you'll need a copy of AutoHotkey
If you don't trust the executable version you can delete it (Inteli Button._) and compile your own version.
Rename "Inteli Button._" to "Inteli Button.exe" to use the executable version.

Setup

  1. You can substitute ".exe" with ".ahk" in the steps below depending on the version you want to use.
  2. Save the "Inteli Button.exe" anywhere.
  3. You can duplicate this button as many times as you like.
  4. You can rename this button to anything as long as it has the ".exe" extension.
  5. Drag and drop the executable file to the ShortCuts Bar in Logos.
  6. Each Copy of the Executable is one Generic Button.


Association (Programming)

  1. Open A Resource and set the Copy location as L4
  2. Close All Panels
  3. Press the Button
  4. It will ask to open a Panel, so close the Message and Open a Panel
  5. With an Active Panel, click the Button
  6. It will show a message indicating that it associated the current Layout with the Active Panel
  7. Close the Message and All Panels
  8. Click the Button again
  9. It will open the registered Panel (The button is now programmed to open this panel for this layout when it's clicked)


Association Removal

  1. To remove the Layout Panel Association, hold down Alt when clicking the Button
  2. You will be informed about the removal
  3. You can associate any layout with any Panel (The Button can be programmed to have different meanings in different Layouts)
  4. To make another Button with the same power, just goto Setup above and follow the steps (from step 3) to make a duplicate.


Initialization of Buttons
Associations are stored inside the Button.ini file in the Button's Directory.
Each button registers as a Section (Button's Name) with the Layout's Name as Key and the Panel's L4 Link as Value

Format:
[Section]
Key=Value

Sample:
[Inteli Button]
Logos Bible Software - Next Devotional=logosres:leb;ref=BibleLEB2.1Pe5.1

Comments:

Please inform me about any bugs encountered. This code is not tested for verbum, but I hope I guessed the correct code to make it work for verbum.

This code will not work for the WebApp.

This code will only run on Windows or a Windows VM. You are free to use the source code logic as reference for a Mac version if possible.

Any ideas to improve are welcome.

Download: 4186.Inteli_Button.zip

Posts 595
J. Remington Bowling | Forum Activity | Replied: Wed, Jun 16 2021 11:25 AM

PJ:
If you don't trust the executable version you can delete it (Inteli Button._) and compile your own version.

Those who would be suspicious of an executable might also be suspicious of unzipping the file too. If you put it on github, people can take a look at the code before downloading.

Potato resting atop 2020 Mac Pro stand.

Posts 443
PJ | Forum Activity | Replied: Wed, Jun 16 2021 11:57 AM

J. Remington Bowling:
Those who would be suspicious of an executable might also be suspicious of unzipping the file too.

I agree ... sometimes a little trust and wisdom could open up a whole new world Smile

Posts 443
PJ | Forum Activity | Replied: Thu, Jun 17 2021 11:09 PM
Here are the Code with some additional functionality. 
Holding down Shift while pressing the button will use the Active Panel's Title to Save the Current Layout (Code Line 29).
There is also a function to open a Layout with the Active Panel's Title (Code Line 46).
The last option should be configured manually in the Button.ini file to work. It will override other settings.

SOURCE
#SingleInstance Force 														;Force only one instance
#NoEnv
/*
===========================================================================
TWO MODES IN THIS SCRIPT
Button Clicked with no 	 	key Down is Layout Trigger Panel
Button Clicked with Shift 	Key down is Panel Trigger Layout
===========================================================================
*/
USE_PACKAGE_ICON := 0
USE_BIBLESOFTWARE_ICON := 1

SetIcon:=USE_PACKAGE_ICON												;0 = Default Icon | 1 = Logos Icon (for MsgBox)
SetWorkingDir := A_ScriptDir												;Consitent Directory
StringReplace,ButtonName,A_ScriptName,.ahk,,All								;Extract Button Name only (the easy way)
StringReplace,ButtonName,ButtonName,.exe,,All
 
SetTimer, CenterMsgBox, 10													;Timer to set MsgBox center of Application

try {																		;As this is a Button, Logos is running, so just attach
	App := ComObjActive("LogosBibleSoftware.Application")					;Get the running instance of Logos
	App.Activate															;Activate the App to receive KeyStrokes
} catch {																	;If ran and Logos is not running, Inform the user
	MsgBox, 4160,%ButtonName% Button, Sorry`, Logos is not running!			;If the above timer is not set (line 8) 
																			;the MsgBox wil default to Primary Screen Center
	ExitApp																	;Exit App on failure
}

GetKeyState, state,Shift													;Monitor if Shift is down
if (state = "D")															;D = down
{
	PanelTitle := App.GetACtivePanel().Title								;Get Active Panel's Title
	App.SaveLayout(PanelTitle)												;Save As Layout
	App.LoadLayout(PanelTitle)												;Load Layout
	ExitApp																	;Exit App
}
/*
****************************************************************************
User can now link a Panel Title to a matching Layout
Section	=Button Name
Key		=Active Panel Title
Value	=Layout Name
****************************************************************************
*/
;Check if user defined a Layout for this Panel
Panel := App.GetActivePanel													;Get Active Panel
if (Panel)																	;If there was an object found
{
	PanelTitle := App.GetACtivePanel().Title
	IniRead,uri,%A_ScriptDir%\Button.ini,%ButtonName%,%PanelTitle%,None
	If !(uri=="None")
	{
		App.LoadLayout(uri)
		ExitApp
	}
}
/*
===========================================================================
	Button Removal
===========================================================================
*/

GetKeyState, state, Alt														;Monitor if Alt is down
if (state = "D")															;D = down
{
		process, exist, logos.exe											;Check if Logos process is running
		if errorlevel														;If no error then 
		{							
			WinGetTitle,layoutName,ahk_exe logos.exe						;Get the App's Title
		} else {															;Else if error
			process, exist, verbum.exe										;check if verbum is running
			if errorlevel													;If no Error
			{
				WinGetTitle,layoutName,ahk_exe verbum.exe					;Get the App's Title
			} else {														;Else inform the user that we failed
				MsgBox, 4160,%ButtonName% Button, Sorry`, Please inform the developer that I don't recognize your Application!
				ExitApp														;On failure Exit the App
			}
		}
		IniDelete,%A_ScriptDir%\Button.ini,%ButtonName%,%layoutName%		;If Alt Key is down, remove the associated entry
																			;Inform user of removal, even if nothing was removed
		MsgBox, 4160,%ButtonName% Button, You Removed the Association for the "%layoutName%" Layout.
		ExitApp																;Exit the App
}
 
/*
===========================================================================
	Layout Panel Association
===========================================================================
*/

Panel := App.GetActivePanel													;Get Active Panel
if (Panel)																	;If there was an object found
{
	process, exist, logos.exe												;check for logos process
	if errorlevel															;if process exits
	{
		WinGetTitle,layoutName,ahk_exe logos.exe							;Get App's Title
	} else {
		process, exist, verbum.exe											;Else try verbum
		if errorlevel
		{
			WinGetTitle,layoutName,ahk_exe verbum.exe						;extract Title
		} else {															;Notify on failure
			MsgBox, 4160,%ButtonName% Button, Sorry`, Please inform the developer that I don't recognize your Application!
			ExitApp															;Exit App
		}
	}
	IniRead,uri,%A_ScriptDir%\Button.ini,%ButtonName%,%layoutName%,None		;Read Init file
	If (uri == "None")														;No Default specified yet (2Do code)
	{																		;Use Keys to Get L4 Link uri
																			;2Do extract with LogosComApi
		Sleep,10
		clp := Clipboard
		Clipboard :=
		Sleep, 250 
		Send, {ESCAPE 4}
		Send, ^!C
		ClipWait
	 
		uri := Clipboard
		Clipboard := clp
		clp :=
		IniWrite,%uri%,%A_ScriptDir%\Button.ini,%ButtonName%,%layoutName%	;Write Uri Layout Association to Button.ini file
		PanelTitle := App.GetActivePanel.Title								;Inform the user of the Association
		MsgBox, 4160,%ButtonName% Button, %ButtonName% Associated Layout (%layoutName%) and %PanelTitle%
		ExitApp																;Exit App
	} else {
		App.ExecuteUri(uri)													;If we get here we have a valid Uri entry, so execute it
		;PanelTitle := App.GetActivePanel.Title
		;App.LoadLayout(PanelTitle)
		ExitApp
	}
;MsgBox At least one Shift key is down.
} else {
	process, exist, logos.exe
	if errorlevel
	{
		WinGetTitle,layoutName,ahk_exe logos.exe
	} else {
		process, exist, verbum.exe
		if errorlevel
		{
			WinGetTitle,layoutName,ahk_exe verbum.exe
		} else {
			MsgBox, 4160,%ButtonName% Button, Sorry`, Please inform the developer that I don't recognize your Application!
			ExitApp
		}
	}
	IniRead,uri,%A_ScriptDir%\Button.ini,%ButtonName%,%layoutName%,None
	If !(uri == "None")
	{ 
		App.ExecuteUri(uri)
		;PanelTitle := App.GetActivePanel.Title
		;App.LoadLayout(PanelTitle)
		ExitApp
	} else {
		MsgBox, 4160,%ButtonName% Button, Open at least one Panel to associate with this layout.
	}	
	uri :=
	ExitApp 
}

CenterMsgBox:
IfWinActive,%ButtonName% Button
{
	process, exist, logos.exe
	if errorlevel
	{
		processName := "logos.exe"
	} else {
		process, exist, verbum.exe
		if errorlevel
		{
			processName := "verbum.exe"
		} 
	}
	for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process WHERE name like '"processName  "%' ") {   	
	    If (SetIcon == 1)
			hIcon := LoadPicture(process.ExecutablePath, "w16 h16", vType)
		else 
			hIcon := LoadPicture(A_ScriptFullPath, "w16 h16", vType)
	}
	vWinCriteria := "ahk_class #32770"
	WinWait, % vWinCriteria
	WinGet, hWnd, ID, % vWinCriteria
	;SendMessage, 0x80, 0, % hIcon,, % "ahk_id " hWnd ;WM_SETICON := 0x80 ;sets title bar icon + taskbar icon
	SendMessage, 0x80, 1, % hIcon,, % "ahk_id " hWnd
	WinGetPos, , , msg_W, msg_H,ahk_class #32770
	process, exist, logos.exe
	if errorlevel
	{
		SetTimer, CenterMsgBox, Off
		WinGetPos,x,y,w,h,ahk_exe logos.exe
		WinMove,%ButtonName% Button, ,x+(w/2)-(msg_W/2), y+(h/2)-(msg_H/2)
	} else {
		process, exist, verbum.exe
		if errorlevel
		{
			SetTimer, CenterMsgBox, Off
			WinGetPos,x,y,w,h,ahk_exe verbum.exe
			WinMove,%ButtonName% Button,,x+(w/2)-(msg_W/2), y+(h/2)-(msg_H/2)
		} 
	}
}
return 
Page 1 of 1 (4 items) | RSS