XIM Community

[XIM2] A Script for Toggling XIM Files; XIMSwitcher  (Read 13614 times)

Offline mtgtopdeck

  • Member
  • *
  • Posts: 127
  • ELITE
    • View Profile
I've been working on creating a script in AutoHotkey that allows you to toggle between your .xim files. Just wanted to make a thread where I could update people on my progress with it.
Im just about to the point were the hotkeys will work when you select them. What I want to do is be able to save your drop down menu selections so that each time you open the program you wont have to reset them. here's a screen shot of the gui.




(UPDATE 4/10/09 6:46pm GMT-8)

I got almost everything working the way I want it.
Right now it will save the hotkeys you want and remember them.
I have yet to add code so that the next time you open the program, all the drop down lists default to the choices you have saved. For now, when you open the program, just close the save dialog and the last saved hotkeys will be active.


Requirements:
- AutoHotkey Program (http://www.autohotkey.com/)
- 12 or less .xim configuration files.
- XIMSwitcher.ahk located in your XIM360 Directory


I encourage you to post any ideas you have for this script.
As well please post any problems you come across with the script


(UPDATE 4/13/09 6:54pm GMT-8)

Changelog:
- Added hotkey; Control + Numpad Enter will now close the script
- Added Edit button
- F1 no longer opens windows help
- XIM software no longer returns an error when you move your mouse while using a hotkey
- your last saved hotkey choices are displayed when you re-open the script

I still have not coded it so that when you hit edit all the drop down list choices default to your saved choices. so if you hit edit, everything will be reset to the default xim file in alphabetical order. I'm working on that.

(UPDATE 4/19/09 2:23am GMT-8)
Changelog:
- Added Tooltips that will display the file name of the current opened .xim file

------------------------------------------------------------------------------------------------------------------


MOST UP TO DATE SCRIPT (4/19/09):
Code: (XIMSwitcher.ahk) [Select]
#NoEnv
#SingleInstance force
#NoTrayIcon
SendMode Input
SetTitleMatchMode 3
SetWorkingDir %A_ScriptDir%

XIMFiles = 
Loop, *.xim
    XIMFiles = %XIMFiles%%A_LoopFileName%`n
Loop, parse, XIMFiles, `n
{
    if A_LoopField = 
        continue
FileDelete, XIMFileList.txt
FileAppend, %XIMFiles%, XIMFilelist.txt
}
FileReadLine, XIMFile1, XIMFileList.txt, 1
FileReadLine, XIMFile2, XIMFileList.txt, 2
FileReadLine, XIMFile3, XIMFileList.txt, 3
FileReadLine, XIMFile4, XIMFileList.txt, 4
FileReadLine, XIMFile5, XIMFileList.txt, 5
FileReadLine, XIMFile6, XIMFileList.txt, 6
FileReadLine, XIMFile7, XIMFileList.txt, 7
FileReadLine, XIMFile8, XIMFileList.txt, 8
FileReadLine, XIMFile9, XIMFileList.txt, 9
FileReadLine, XIMFile10, XIMFileList.txt, 10
FileReadLine, XIMFile11, XIMFileList.txt, 11
FileReadLine, XIMFile12, XIMFileList.txt, 12

If FileExist("XIMSwitcherSave.txt")
{
FileReadLine, save1, XIMSwitcherSave.txt, 1
FileReadLine, save2, XIMSwitcherSave.txt, 2
FileReadLine, save3, XIMSwitcherSave.txt, 3
FileReadLine, save4, XIMSwitcherSave.txt, 4
FileReadLine, save5, XIMSwitcherSave.txt, 5
FileReadLine, save6, XIMSwitcherSave.txt, 6
FileReadLine, save7, XIMSwitcherSave.txt, 7
FileReadLine, save8, XIMSwitcherSave.txt, 8
FileReadLine, save9, XIMSwitcherSave.txt, 9
FileReadLine, save10, XIMSwitcherSave.txt, 10
FileReadLine, save11, XIMSwitcherSave.txt, 11
FileReadLine, save12, XIMSwitcherSave.txt, 12
}
Else
{
FileAppend, `n `n `n `n `n `n `n `n `n `n `n `n, XIMSwitcherSave.txt
FileReadLine, save1, XIMSwitcherSave.txt, 1
FileReadLine, save2, XIMSwitcherSave.txt, 2
FileReadLine, save3, XIMSwitcherSave.txt, 3
FileReadLine, save4, XIMSwitcherSave.txt, 4
FileReadLine, save5, XIMSwitcherSave.txt, 5
FileReadLine, save6, XIMSwitcherSave.txt, 6
FileReadLine, save7, XIMSwitcherSave.txt, 7
FileReadLine, save8, XIMSwitcherSave.txt, 8
FileReadLine, save9, XIMSwitcherSave.txt, 9
FileReadLine, save10, XIMSwitcherSave.txt, 10
FileReadLine, save11, XIMSwitcherSave.txt, 11
FileReadLine, save12, XIMSwitcherSave.txt, 12
}
Gui, Add, DropDownList, x36 y10 w130 h20 vDDL1 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y30 w130 h10 vDDL2 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y50 w130 h21 vDDL3 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y70 w130 h21 vDDL4 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y90 w130 h20 vDDL5 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y110 w130 h21 vDDL6 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y130 w130 h21 vDDL7 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y150 w130 h21 vDDL8 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y170 w130 h21 vDDL9 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y190 w130 h21 vDDL10 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y210 w130 h21 vDDL11 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y230 w130 h21 vDDL12 R12 +hidden, %XIMFile1%|%XIMFile2%|%XIMFile3%|%XIMFile4%|%XIMFile5%|%XIMFile6%|%XIMFile7%|%XIMFile8%|%XIMFile9%|%XIMFile10%|%XIMFile11%|%XIMFile12%
Gui, Add, DropDownList, x36 y10 w130 h20 vGrayddl1 +Disabled, %save1%||
Gui, Add, DropDownList, x36 y30 w130 h10 vGrayddl2 +Disabled, %save2%||
Gui, Add, DropDownList, x36 y50 w130 h21 vGrayddl3 +Disabled, %save3%||
Gui, Add, DropDownList, x36 y70 w130 h21 vGrayddl4 +Disabled, %save4%||
Gui, Add, DropDownList, x36 y90 w130 h20 vGrayddl5 +Disabled, %save5%||
Gui, Add, DropDownList, x36 y110 w130 h21 vGrayddl6 +Disabled, %save6%||
Gui, Add, DropDownList, x36 y130 w130 h21 vGrayddl7 +Disabled, %save7%||
Gui, Add, DropDownList, x36 y150 w130 h21 vGrayddl8 +Disabled, %save8%||
Gui, Add, DropDownList, x36 y170 w130 h21 vGrayddl9 +Disabled, %save9%||
Gui, Add, DropDownList, x36 y190 w130 h21 vGrayddl10 +Disabled, %save10%||
Gui, Add, DropDownList, x36 y210 w130 h21 vGrayddl11 +Disabled, %save11%||
Gui, Add, DropDownList, x36 y230 w130 h21 vGrayddl12 +Disabled, %save12%||
Gui, Add, Text, x6 y12 w25 h15 , F1:
Gui, Add, Text, x6 y32 w25 h15 , F2:
Gui, Add, Text, x6 y52 w25 h15 , F3:
Gui, Add, Text, x6 y72 w25 h15 , F4:
Gui, Add, Text, x6 y92 w25 h15 , F5:
Gui, Add, Text, x6 y112 w25 h15 , F6:
Gui, Add, Text, x6 y132 w25 h15 , F7:
Gui, Add, Text, x6 y152 w25 h15 , F8:
Gui, Add, Text, x6 y172 w25 h15 , F9:
Gui, Add, Text, x6 y192 w25 h15 , F10:
Gui, Add, Text, x6 y212 w25 h15 , F11:
Gui, Add, Text, x6 y232 w25 h15 , F12:
Gui, Add, Button, x6 y260 w80 h20 vbutton1 +disabled, Save
Gui, Add, Button, x86 y260 w80 h20 vbutton2, Edit
Gui, Show, w176 h288, XIM Switcher
Return

ButtonEdit:
{
GuiControl, Hide, Grayddl1
GuiControl, Hide, Grayddl2
GuiControl, Hide, Grayddl3
GuiControl, Hide, Grayddl4
GuiControl, Hide, Grayddl5
GuiControl, Hide, Grayddl6
GuiControl, Hide, Grayddl7
GuiControl, Hide, Grayddl8
GuiControl, Hide, Grayddl9
GuiControl, Hide, Grayddl10
GuiControl, Hide, Grayddl11
GuiControl, Hide, Grayddl12
GuiControl, Show, DDL1
GuiControl, Show, DDL2
GuiControl, Show, DDL3
GuiControl, Show, DDL4
GuiControl, Show, DDL5
GuiControl, Show, DDL6
GuiControl, Show, DDL7
GuiControl, Show, DDL8
GuiControl, Show, DDL9
GuiControl, Show, DDL10
GuiControl, Show, DDL11
GuiControl, Show, DDL12
GuiControl, Disable, button2
GuiControl, Enable, button1
}
Return

ButtonSave:
{
GuiControlGet, g1,, DDL1
GuiControlGet, g2,, DDL2
GuiControlGet, g3,, DDL3
GuiControlGet, g4,, DDL4
GuiControlGet, g5,, DDL5
GuiControlGet, g6,, DDL6
GuiControlGet, g7,, DDL7
GuiControlGet, g8,, DDL8
GuiControlGet, g9,, DDL9
GuiControlGet, g10,, DDL10
GuiControlGet, g11,, DDL11
GuiControlGet, g12,, DDL12
FileDelete, XIMSwitcherSave.txt
FileAppend, %g1%`n%g2%`n%g3%`n%g4%`n%g5%`n%g6%`n%g7%`n%g8%`n%g9%`n%g10%`n%g11%`n%g12%, XIMSwitcherSave.txt
Gui, 2:Add, Button, x46 y40 w60 h20 v2button1, OK
Gui, 2:Add, text, x6 y10 w140 h20 , XIM Switcher Hotkeys Saved
Gui, 2:Show, w152 h70, Saved
}
Return

2buttonOK:
{
WinClose, XIM Switcher
WinClose, Saved
}
Return


#IfWinNotExist, XIM Switcher
{
F1::
FileReadLine, save1, XIMSwitcherSave.txt, 1
If save1 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save1%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save1%, 65, 6
}
Return
F2::
FileReadLine, save2, XIMSwitcherSave.txt, 2
If save2 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save2%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save2%, 65, 6
}
Return
F3::
FileReadLine, save3, XIMSwitcherSave.txt, 3
If save3 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save3%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save3%, 65, 6
}
Return
F4::
FileReadLine, save4, XIMSwitcherSave.txt, 4
If save4 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save4%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save4%, 65, 6
}
Return
F5::
FileReadLine, save5, XIMSwitcherSave.txt, 5
If save5 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save5%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save5%, 65, 6
}
Return
F6::
FileReadLine, save6, XIMSwitcherSave.txt, 6
If save6 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save6%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save6%, 65, 6
}
Return
F7::
FileReadLine, save7, XIMSwitcherSave.txt, 7
If save7 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save7%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save7%, 65, 6
}
Return
F8::
FileReadLine, save8, XIMSwitcherSave.txt, 8
If save8 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save8%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save8%, 65, 6
}
Return
F9::
FileReadLine, save9, XIMSwitcherSave.txt, 9
If save9 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save9%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save9%, 65, 6
}
Return
F10::
FileReadLine, save10, XIMSwitcherSave.txt, 10
If save10 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save10%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save10%, 65, 6
}
Return
F11::
FileReadLine, save11, XIMSwitcherSave.txt, 11
If save11 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save11%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save11%, 65, 6
}
Return
F12::
FileReadLine, save12, XIMSwitcherSave.txt, 12
If save12 Contains .xim
{
ToolTip
WinKill, XIM
BlockInput On
Run, %save12%
WinWaitActive, XIM
BlockInput Off
ToolTip, %save12%, 65, 6
}
Return
}

~*^Esc::ToolTip

^NumpadEnter::ExitApp
« Last Edit: 09:39 PM - 06/07/11 by mist4fun »

Offline NxtGenCowboy

  • Member
  • *
  • Posts: 42
    • View Profile
Re: Toggling XIM Files
« Reply #1 on: 03:57 PM - 04/10/09 »
That could really come in handy!  Cant wait to see this!
If its too loud, your too old.

Offline DarkShroom

  • Member
  • *
  • Posts: 82
    • View Profile
Re: Toggling XIM Files
« Reply #2 on: 05:47 PM - 04/10/09 »
that would be awesome :)

Offline mtgtopdeck

  • Member
  • *
  • Posts: 127
  • ELITE
    • View Profile
Re: Toggling XIM Files
« Reply #3 on: 07:43 PM - 04/10/09 »
I got almost everything working the way I want it.
Right now it will save the hotkeys you want and remember them.
I have yet to add code so that the next time you open the program, all the drop down lists default to the choices you have saved. For now, when you open the program, just close the save dialog and the last saved hotkeys will be active.


Requirements:
- AutoHotkey Program (http://www.autohotkey.com/)
- 12 or less .xim configuration files.
- XIMSwitcher.ahk located in your XIM360 Directory


I encourage you to post any ideas you have for this script.
As well please post and problems you come across with the script

The script code has been edited into the first post~
« Last Edit: 07:48 PM - 04/10/09 by mtgtopdeck »

Offline xavier_s37

  • MVP
  • *
  • Posts: 802
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #4 on: 08:12 PM - 04/10/09 »
F'IN BEAUTIFUL

but when i hit the F keys that already have things tied to them (ie: F1 is bound to bring up help in explorer) some of the programs they bring up cause the xim app to crash.

but hey, i found the ones that work, this in conjunction with the G13 is AWESOME!!!!
« Last Edit: 08:37 PM - 04/10/09 by xavier_s37 »

Offline Voli

  • MVP
  • *
  • Posts: 1119
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #5 on: 11:55 PM - 04/10/09 »
I was just thinking about something like this the other day. Very excited..

Offline XImember

  • Member
  • *
  • Posts: 214
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #6 on: 01:51 AM - 04/11/09 »
Wow? sounds like what im looking for but

what needs to be worked on?

If you toggle with say f1 to f2 is it instant?

Offline mtgtopdeck

  • Member
  • *
  • Posts: 127
  • ELITE
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #7 on: 02:43 AM - 04/11/09 »
Wow? sounds like what im looking for but

what needs to be worked on?

If you toggle with say f1 to f2 is it instant?


its almost instant. takes about .5 seconds to switch.
all that needs to be added is some code so that the next time you open the program, all the drop down lists default to the choices you have saved. Other than that it's essentially done.
Though I'm still open to user input right now and I want to see if I can fix any problems that people find. :)
« Last Edit: 06:47 AM - 04/11/09 by mtgtopdeck »

Offline PhilAshio

  • MVP
  • *
  • Posts: 1922
  • Troll in the Mist, 4fun
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #8 on: 10:04 AM - 04/11/09 »
That is really awesome and I'm extremely appreciative but I was wondering if autohotkey has code that lets you toggle configs with the same key? For example, you press one key to enter a warthog and it switches to that config and you press the same key to exit and it switches back to on foot controls.

Offline mtgtopdeck

  • Member
  • *
  • Posts: 127
  • ELITE
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #9 on: 03:09 PM - 04/11/09 »
That is really awesome and I'm extremely appreciative but I was wondering if autohotkey has code that lets you toggle configs with the same key? For example, you press one key to enter a warthog and it switches to that config and you press the same key to exit and it switches back to on foot controls.
It's possible to do and I have tried it a few different ways. The only problem is the script doesn't know if you are in the car or out of it. so it's left to you to switch to the correct settings if you get it wrong. If you really want to, its pretty simple, create the hotkey then create a IfWinExist statement that sees if xim config A is the right one. Else close current xim window then open xim config B.

Offline mtgtopdeck

  • Member
  • *
  • Posts: 127
  • ELITE
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #10 on: 08:03 PM - 04/13/09 »
(UPDATE 4/13/09 6:54pm GMT-8)

Changelog:
- Added hotkey; Control + Numpad Enter will now close the script
- Added Edit button
- F1 no longer opens windows help
- XIM software no longer returns an error when you move your mouse while using a hotkey
- your last saved hotkey choices are displayed when you re-open the script

I still have not coded it so that when you hit edit all the drop down list choices default to your saved choices. so if you hit edit, everything will be reset to the default xim file in alphabetical order. I'm working on that.

The first time you launch the script it will take longer than each time after that. this is because the script needs to create two text files in the xim360 directory where it saves your xim file information

Updated script has been edited into the first post.
« Last Edit: 12:46 PM - 04/14/09 by mtgtopdeck »

Offline XImember

  • Member
  • *
  • Posts: 214
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #11 on: 06:00 PM - 04/14/09 »
dude, your genious.

Im going to have to mess with this later.
Keep up the good work and thanks.

Offline mtgtopdeck

  • Member
  • *
  • Posts: 127
  • ELITE
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #12 on: 04:11 PM - 04/15/09 »
dude, your genious.

Im going to have to mess with this later.
Keep up the good work and thanks.

thanks  :)

let me know if you think of anything you want to see changed/added

Offline PhilAshio

  • MVP
  • *
  • Posts: 1922
  • Troll in the Mist, 4fun
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #13 on: 06:37 PM - 04/15/09 »
Hey, did you get my PM?

Offline mtgtopdeck

  • Member
  • *
  • Posts: 127
  • ELITE
    • View Profile
Re: A Script for Toggling XIM Files; XIMSwitcher
« Reply #14 on: 08:56 PM - 04/15/09 »
Hey, did you get my PM?

yeah, i hope that will fix the problem