Need help merging 2 AHK scripts

Posted by Mikey on Super User See other posts from Super User or by Mikey
Published on 2012-03-24T11:24:55Z Indexed on 2012/03/24 11:32 UTC
Read the original article Hit count: 515

Filed under:

i have two functioning scripts that i want to merge into a single AHK File. My problem is that when i combine both scripts, the second script doesnt function or causes an error on script 1. Either way, script 2 ist not functioning at all.

Here are some facts: Script 1 = a simple menu script where i want to assign hotkeys to.

Script 2 = A small launcher script from a user named Tertius in autohotkey forum.

Can someone please look at both codes and help me merge this? The INI File for script 2 looks like this:

Keywords.ini npff|Firefox|Firefox gm|Gmail|http://gmail.google.com

;;;;;;;;;;;; BEGIN SCRIPT 2

DetectHiddenWindows, On SetWinDelay, -1 SetKeyDelay, -1 SetBatchLines, -1 GoSub Remin SetTimer, Remin, % 1000 * 60

Loop, read, %A_ScriptDir%\keywords.ini { LineNumber = %A_Index% Loop, parse, A_LoopReadLine, | { if (A_Index == 1) abbrevs%LineNumber% := A_LoopField else if (A_Index == 2) tips%LineNumber% := A_LoopField else if (A_Index == 3) programs%LineNumber% := A_LoopField else if (A_Index == 4) params%LineNumber% := A_LoopField } tosay := abbrevs%LineNumber% } cnt = %LineNumber%

Loop { Input, Key, L1 V, % "{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}" . "{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}" . "{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}{Escape}"

If( ( Asc(Key) >= 65 && Asc(Key) <= 90 ) || ( Asc(Key) >= 97 && Asc(Key) <= 122 ) ) Word .= Key Else { Word := "" Continue } tipup := false Loop %cnt% {

  if (Word == abbrevs%A_index%)
  {
     tip := tips%A_index%
     ToolTip %tip%
     tipup := true
      }
     else
      {
     if (tipup == false)
     ToolTip
  }

} }

$Tab:: Loop %cnt% { if (Word != "" && Word == abbrevs%A_index%) { Word := ""

     StringLen, len, abbrevs%A_index%
     Loop %len%
        Send {Shift Down}{Left}
     Send {Shift Up}{BS}

  ToolTip
  program := programs%A_index%
  param := params%A_index%
  run, %program% %param%
  return
  }

} Word := "" Send {Tab} Return

~LButton:: ~MButton:: ~RButton:: ~XButton1:: ~XButton2:: Word := "" Tooltip Return

Remin:

WinMinimize, %A_ScriptFullPath% - AutoHotkey v WinHide, %A_ScriptFullPath% - AutoHotkey v Return

;;;;;;;;;; END SCRIPT 2

;;;;;;;;;;;;;; BEGIN SCRIPT 1

;This is a working script that creates a popup menu.

; Create the popup menu by adding some items to it. Menu, MyMenu, Add, FIS 201, MenuHandler Menu, MyMenu, Add ; Add a separator line. Menu, MyMenu, Color, Lime, Single ;Define the Menu Color

; Create another menu destined to become a submenu of the above menu. Menu, Submenu1, Add, Item2, MenuHandler Menu, Submenu1, Add, Item3, MenuHandler Menu, Submenu1, Color, Yellow ;Define the Menu Color

; Create another menu destined to become a submenu of the above menu. Menu, Submenu2, Add, Item1a, MenuHandler Menu, Submenu2, Add, Item2a, MenuHandler Menu, Submenu2, Add, Item3a, MenuHandler Menu, Submenu2, Add, Item4a, MenuHandler Menu, Submenu2, Add, Item5a, MenuHandler Menu, Submenu2, Add, Item6a, MenuHandler Menu, Submenu2, Color, Aqua ;Define the Menu Color

; Create a submenu in the first menu (a right-arrow indicator). When the user selects it, the second menu is displayed. Menu, MyMenu, Add, BKRS 119, :Submenu1 Menu, MyMenu, Add ; Add a separator line below the submenu. Menu, MyMenu, Add, BKRS 201, :Submenu2 Menu, MyMenu, Add ; Add a separator line below the submenu.

Menu, MyMenu, Add ; Add a separator line below the submenu. Menu, MyMenu, Add, Google Search, Google ; Add another menu item beneath the submenu.

return ; End of script's auto-execute section.

Capslock & LButton::Menu, MyMenu, Show ; i.e. press the Win-Z hotkey to show the menu.

MenuHandler: MsgBox You selected %A_ThisMenuItem% from the menu %A_ThisMenu%. return

;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;; Google Search ;;; FORMAT InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default] Google: InputBox, SearchTerm, Google Search,,,350, 120 if SearchTerm <> "" Run http://www.google.de/search?sclient=psy-ab&hl=de&site=&source=hp&q=%SearchTerm%&btnG=Suche

return

; Make Window Transparent

Space::WinSet, Transparent, 125, A

^!Space UP::WinSet, Transparent, OFF, A return

;;;;;;;;;;; END SCRIPT 1

Help is appreciated.

Kind Regards,

Mikey

© Super User or respective owner

Related posts about autohotkey