Cactuscat222 Posted January 13, 2008 Share Posted January 13, 2008 (edited) Okay, say I have a program with the variable $Variable, where upon executing the script:$Variable = 0Within this script, the user can modify $Variable to a different value, lets say the user makes:$Variable = 1Then "saves" and quits. How would I make it, so upon load up, $Variable still = 1? So that it doesn't change back to 0. Do I just set $Variable as a global variable? I searched around the site, but couldn't find anything on saving variable values.ThanksEDIT: Check last post please! Edited January 14, 2008 by Cactuscat222 Link to comment Share on other sites More sharing options...
Nahuel Posted January 13, 2008 Share Posted January 13, 2008 IniWrite() comes handy in these situations. Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 So it would be something along the lines of Iniwrite("C:\Blahblah\myfile.ini, "Settings", "Hotkey1", $Variable) ? Iniread(balbalbhahlabhlahbalhb) Also, how can you make the .ini file write to the same folder as your .exe? Link to comment Share on other sites More sharing options...
Nahuel Posted January 13, 2008 Share Posted January 13, 2008 (edited) Yeah. Use IniRead() to read the previous value of your $variable, this function has a parameter for setting default values in case no ini is found. To make it save at the same directory as your exe, simply use the name of the file as a path. Like this: IniWrite("my ini.ini",---) or use the @ScriptDir macro: Iniwrite(@ScriptDir & "\my ini.ini") Remember that IniRead() returns a string (as far as I know) so if it's a number, it's better to use Number() so you don't get in trouble comparing. Edited January 13, 2008 by Nahuel Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 Thank you very much! Really helps with the fast replies! Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 Okay, Now I am having a major INI problem: Here is the main part of my script, I omitted many of the repeated Functions: expandcollapse popup#include <GUIConstants.au3> Global $Paused ; GUI Set-up GUICreate("Stick Online Hotkeyz",300,225) $btn1 = GuiCtrlCreateButton("Save", 65, 200, 75, 20) $btn2 = GuiCtrlCreateButton("Load", 155, 200, 75, 20) $hotkey1 = GuiCtrlCreateInput( "1", 59, 25, 13, 20) $hotkey2 = GuiCtrlCreateInput( "2", 59, 75) $hotkey3 = GuiCtrlCreateInput( "3", 59, 125) $hotkey4 = GuiCtrlCreateInput( "4", 59, 175) $hotkey5 = GuiCtrlCreateInput( "5", 204, 25) $hotkey6 = GuiCtrlCreateInput( "6", 204, 75) $hotkey7 = GuiCtrlCreateInput( "7", 204, 125) $hotkey8 = GuiCtrlCreateInput( "8", 204, 175) $InvSec1 = GuiCtrlCreateCombo( "Slot1", 79, 25, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec2 = GuiCtrlCreateCombo( "Slot1", 79, 75, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec3 = GuiCtrlCreateCombo( "Slot1", 79, 125, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec4 = GuiCtrlCreateCombo( "Slot1", 79, 175, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec5 = GuiCtrlCreateCombo( "Slot1", 224, 25, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec6 = GuiCtrlCreateCombo( "Slot1", 224, 75, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec7 = GuiCtrlCreateCombo( "Slot1", 224, 125, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec8 = GuiCtrlCreateCombo( "Slot1", 224, 175, 55) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") GuiCtrlCreateLabel("Hotkey 1:", 5, 27) GuiCtrlCreateLabel("Hotkey 2:", 5, 77) GuiCtrlCreateLabel("Hotkey 3:", 5, 127) GuiCtrlCreateLabel("Hotkey 4:", 5, 177) GuiCtrlCreateLabel("Hotkey 5:", 150, 27) GuiCtrlCreateLabel("Hotkey 6:", 150, 77) GuiCtrlCreateLabel("Hotkey 7:", 150, 127) GuiCtrlCreateLabel("Hotkey 8:", 150, 177) Guisetstate(@SW_show) While 1 ;Hotkey Set-up Traysetstate(1) HotKeySet(GuiCtrlRead($hotkey1), GuiCtrlRead($InvSec1)) HotKeySet(GuiCtrlRead($hotkey2), GuiCtrlRead($InvSec2)) HotKeySet(GuiCtrlRead($hotkey3), GuiCtrlRead($InvSec3)) HotKeySet(GuiCtrlRead($hotkey4), GuiCtrlRead($InvSec4)) HotKeySet(GuiCtrlRead($hotkey5), GuiCtrlRead($InvSec5)) HotKeySet(GuiCtrlRead($hotkey6), GuiCtrlRead($InvSec6)) HotKeySet(GuiCtrlRead($hotkey7), GuiCtrlRead($InvSec7)) HotKeySet(GuiCtrlRead($hotkey8), GuiCtrlRead($InvSec8)) HotKeySet("{F1}", "Pause") HotKeySet("{ESC}", "Terminate") $msg = GuiGetMsg() Select Case $msg = $btn1 ;Saves to INI File - For later accsessing If FileExists( "HKSettings.ini") Then FileDelete( "HKSettings.ini") Iniwrite( "HKSettings.ini", "HotKeys", "HotKey1", $hotkey1) Iniwrite( "HKSettings.ini", "HotKeys", "HotKey2", $hotkey2) Iniwrite( "HKSettings.ini", "HotKeys", "HotKey3", $hotkey3) Iniwrite( "HKSettings.ini", "HotKeys", "HotKey4", $hotkey4) Iniwrite( "HKSettings.ini", "HotKeys", "HotKey5", $hotkey5) Iniwrite( "HKSettings.ini", "HotKeys", "HotKey6", $hotkey6) Iniwrite( "HKSettings.ini", "HotKeys", "HotKey7", $hotkey7) Iniwrite( "HKSettings.ini", "HotKeys", "HotKey8", $hotkey8) Iniwrite( "HKSettings.ini", "Slots", "HotKey1 Equips", $InvSec1) Iniwrite( "HKSettings.ini", "Slots", "HotKey2 Equips", $InvSec2) Iniwrite( "HKSettings.ini", "Slots", "HotKey3 Equips", $InvSec3) Iniwrite( "HKSettings.ini", "Slots", "HotKey4 Equips", $InvSec4) Iniwrite( "HKSettings.ini", "Slots", "HotKey5 Equips", $InvSec5) Iniwrite( "HKSettings.ini", "Slots", "HotKey6 Equips", $InvSec6) Iniwrite( "HKSettings.ini", "Slots", "HotKey7 Equips", $InvSec7) Iniwrite( "HKSettings.ini", "Slots", "HotKey8 Equips", $InvSec8) Case $msg = $btn2 ;Loads INI File - For quick setup GUICtrlSetData( $hotkey1, Iniread( "HKSettings.ini", "HotKeys", "HotKey1", "default")) GUICtrlSetData( $hotkey2, Iniread( "HKSettings.ini", "HotKeys", "HotKey2", "default")) GUICtrlSetData( $hotkey3, Iniread( "HKSettings.ini", "HotKeys", "HotKey3", "default")) GUICtrlSetData( $hotkey4, Iniread( "HKSettings.ini", "HotKeys", "HotKey4", "default")) GUICtrlSetData( $hotkey5, Iniread( "HKSettings.ini", "HotKeys", "HotKey5", "default")) GUICtrlSetData( $hotkey6, Iniread( "HKSettings.ini", "HotKeys", "HotKey6", "default")) GUICtrlSetData( $hotkey7, Iniread( "HKSettings.ini", "HotKeys", "HotKey7", "default")) GUICtrlSetData( $hotkey8, Iniread( "HKSettings.ini", "HotKeys", "HotKey8", "default")) GUICtrlSetData( $InvSec1, Iniread( "HKSettings.ini", "Slots", "HotKey1 Equips", "default")) GUICtrlSetData( $InvSec2, Iniread( "HKSettings.ini", "Slots", "HotKey2 Equips", "default")) GUICtrlSetData( $InvSec3, Iniread( "HKSettings.ini", "Slots", "HotKey3 Equips", "default")) GUICtrlSetData( $InvSec4, Iniread( "HKSettings.ini", "Slots", "HotKey4 Equips", "default")) GUICtrlSetData( $InvSec5, Iniread( "HKSettings.ini", "Slots", "HotKey5 Equips", "default")) GUICtrlSetData( $InvSec6, Iniread( "HKSettings.ini", "Slots", "HotKey6 Equips", "default")) GUICtrlSetData( $InvSec7, Iniread( "HKSettings.ini", "Slots", "HotKey7 Equips", "default")) GUICtrlSetData( $InvSec8, Iniread( "HKSettings.ini", "Slots", "HotKey8 Equips", "default")) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEND ;Pause Hotkeyz Func Pause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Hotkeyz is "Paused"',450,29) HotkeySet("1") HotkeySet("2") HotkeySet("3") HotkeySet("4") HotkeySet("5") HotkeySet("6") HotkeySet("7") HotkeySet("8") WEnd HotKeySet(GuiCtrlRead($hotkey1), GuiCtrlRead($InvSec1)) HotKeySet(GuiCtrlRead($hotkey2), GuiCtrlRead($InvSec2)) HotKeySet(GuiCtrlRead($hotkey3), GuiCtrlRead($InvSec3)) HotKeySet(GuiCtrlRead($hotkey4), GuiCtrlRead($InvSec4)) HotKeySet(GuiCtrlRead($hotkey5), GuiCtrlRead($InvSec5)) HotKeySet(GuiCtrlRead($hotkey6), GuiCtrlRead($InvSec6)) HotKeySet(GuiCtrlRead($hotkey7), GuiCtrlRead($InvSec7)) HotKeySet(GuiCtrlRead($hotkey8), GuiCtrlRead($InvSec8)) ToolTip("") EndFunc ;Inventory Slot Functions Func Slot1() Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("classname=TRunnerForm","") If Not WinActive("classname=TRunnerForm","") Then WinActivate("classname=TRunnerForm","") WinWaitActive("classname=TRunnerForm","") MouseClick("left", 545, 63, 1, 0) sleep(20) MouseClick("left", 420, 162, 1, 0) sleep(20) MouseClick("left", 545, 63, 1, 0) sleep(20) EndFunc Here is my problem. Whenever I click Save, (I haven't changed anything from the default settings I have them at) it saves fine(lags a bit though). Then when I go into the actual INI file, it comes out like this, no matter what: [HotKeys] HotKey1=5 HotKey2=6 HotKey3=7 HotKey4=8 HotKey5=9 HotKey6=10 HotKey7=11 HotKey8=12 [Slots] HotKey1 Equips=13 HotKey2 Equips=14 HotKey3 Equips=15 HotKey4 Equips=16 HotKey5 Equips=17 HotKey6 Equips=18 HotKey7 Equips=19 HotKey8 Equips=20 I really need them to come out right... It needs to save how everything is inputted! IE for the HotKeys, they need to be able to be letters or numbers, and the HotKey Equips need to be Slot#! Any help please! Link to comment Share on other sites More sharing options...
FreeFry Posted January 13, 2008 Share Posted January 13, 2008 (edited) The error is that you're reading the gui control id when you're using $hotkeyX directly, you have to do this: Iniwrite( "HKSettings.ini", "HotKeys", "HotKey6", GuiCtrlRead($hotkey6)) Edited January 13, 2008 by FreeFry Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 Wow, I can't believed I missed that. Thanks Free Fry, really appreciate your time. Link to comment Share on other sites More sharing options...
FreeFry Posted January 13, 2008 Share Posted January 13, 2008 No problemo! on a sidenote: wtf's up with editing posts in the forum :S comes out all garbled out... Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 Okay, so this is becoming my help thread, haha: Heres the code(or whats important of it): expandcollapse popup#include <GUIConstants.au3> Global $Paused ; GUI Set-up GUICreate("Stick Online Hotkeyz", 300, 225) $btn1 = GUICtrlCreateButton("Save", 65, 200, 75, 20) $btn2 = GUICtrlCreateButton("Load", 155, 200, 75, 20) $btn3 = GUICtrlCreateButton("Refresh", 110, 3, 75, 20) $hotkey1 = GUICtrlCreateInput("", 59, 25, 14, 20) GUICtrlSetLimit(-1, 1) $hotkey2 = GUICtrlCreateInput("", 59, 75) GUICtrlSetLimit(-1, 1) $hotkey3 = GUICtrlCreateInput("", 59, 125) GUICtrlSetLimit(-1, 1) $hotkey4 = GUICtrlCreateInput("", 59, 175) GUICtrlSetLimit(-1, 1) $hotkey5 = GUICtrlCreateInput("", 204, 25) GUICtrlSetLimit(-1, 1) $hotkey6 = GUICtrlCreateInput("", 204, 75) GUICtrlSetLimit(-1, 1) $hotkey7 = GUICtrlCreateInput("", 204, 125) GUICtrlSetLimit(-1, 1) $hotkey8 = GUICtrlCreateInput("", 204, 175) GUICtrlSetLimit(-1, 1) $InvSec1 = GUICtrlCreateCombo("Slot1", 79, 25, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec2 = GUICtrlCreateCombo("Slot1", 79, 75, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec3 = GUICtrlCreateCombo("Slot1", 79, 125, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec4 = GUICtrlCreateCombo("Slot1", 79, 175, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec5 = GUICtrlCreateCombo("Slot1", 224, 25, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec6 = GUICtrlCreateCombo("Slot1", 224, 75, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec7 = GUICtrlCreateCombo("Slot1", 224, 125, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec8 = GUICtrlCreateCombo("Slot1", 224, 175, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") GUICtrlCreateLabel("Hotkey 1:", 5, 27) GUICtrlCreateLabel("Hotkey 2:", 5, 77) GUICtrlCreateLabel("Hotkey 3:", 5, 127) GUICtrlCreateLabel("Hotkey 4:", 5, 177) GUICtrlCreateLabel("Hotkey 5:", 150, 27) GUICtrlCreateLabel("Hotkey 6:", 150, 77) GUICtrlCreateLabel("Hotkey 7:", 150, 127) GUICtrlCreateLabel("Hotkey 8:", 150, 177) GUISetState(@SW_SHOW) While 1 TraySetState(1) HotKeySet("{F1}", "Pause") HotKeySet("{ESC}", "Terminate") $msg = GUIGetMsg() Select Case $msg = $btn1 ;Saves to INI File - For later accsessing If FileExists("HKSettings.ini") Then FileDelete("HKSettings.ini") IniWrite("HKSettings.ini", "HotKeys", "HotKey1", GUICtrlRead($hotkey1)) IniWrite("HKSettings.ini", "HotKeys", "HotKey2", GUICtrlRead($hotkey2)) IniWrite("HKSettings.ini", "HotKeys", "HotKey3", GUICtrlRead($hotkey3)) IniWrite("HKSettings.ini", "HotKeys", "HotKey4", GUICtrlRead($hotkey4)) IniWrite("HKSettings.ini", "HotKeys", "HotKey5", GUICtrlRead($hotkey5)) IniWrite("HKSettings.ini", "HotKeys", "HotKey6", GUICtrlRead($hotkey6)) IniWrite("HKSettings.ini", "HotKeys", "HotKey7", GUICtrlRead($hotkey7)) IniWrite("HKSettings.ini", "HotKeys", "HotKey8", GUICtrlRead($hotkey8)) IniWrite("HKSettings.ini", "Slots", "HotKey1 Equips", GUICtrlRead($InvSec1)) IniWrite("HKSettings.ini", "Slots", "HotKey2 Equips", GUICtrlRead($InvSec2)) IniWrite("HKSettings.ini", "Slots", "HotKey3 Equips", GUICtrlRead($InvSec3)) IniWrite("HKSettings.ini", "Slots", "HotKey4 Equips", GUICtrlRead($InvSec4)) IniWrite("HKSettings.ini", "Slots", "HotKey5 Equips", GUICtrlRead($InvSec5)) IniWrite("HKSettings.ini", "Slots", "HotKey6 Equips", GUICtrlRead($InvSec6)) IniWrite("HKSettings.ini", "Slots", "HotKey7 Equips", GUICtrlRead($InvSec7)) IniWrite("HKSettings.ini", "Slots", "HotKey8 Equips", GUICtrlRead($InvSec8)) Case $msg = $btn2 ;Loads INI File - For quick setup GUICtrlSetData($hotkey1, IniRead("HKSettings.ini", "HotKeys", "HotKey1", "default")) GUICtrlSetData($hotkey2, IniRead("HKSettings.ini", "HotKeys", "HotKey2", "default")) GUICtrlSetData($hotkey3, IniRead("HKSettings.ini", "HotKeys", "HotKey3", "default")) GUICtrlSetData($hotkey4, IniRead("HKSettings.ini", "HotKeys", "HotKey4", "default")) GUICtrlSetData($hotkey5, IniRead("HKSettings.ini", "HotKeys", "HotKey5", "default")) GUICtrlSetData($hotkey6, IniRead("HKSettings.ini", "HotKeys", "HotKey6", "default")) GUICtrlSetData($hotkey7, IniRead("HKSettings.ini", "HotKeys", "HotKey7", "default")) GUICtrlSetData($hotkey8, IniRead("HKSettings.ini", "HotKeys", "HotKey8", "default")) GUICtrlSetData($InvSec1, IniRead("HKSettings.ini", "Slots", "HotKey1 Equips", "default")) GUICtrlSetData($InvSec2, IniRead("HKSettings.ini", "Slots", "HotKey2 Equips", "default")) GUICtrlSetData($InvSec3, IniRead("HKSettings.ini", "Slots", "HotKey3 Equips", "default")) GUICtrlSetData($InvSec4, IniRead("HKSettings.ini", "Slots", "HotKey4 Equips", "default")) GUICtrlSetData($InvSec5, IniRead("HKSettings.ini", "Slots", "HotKey5 Equips", "default")) GUICtrlSetData($InvSec6, IniRead("HKSettings.ini", "Slots", "HotKey6 Equips", "default")) GUICtrlSetData($InvSec7, IniRead("HKSettings.ini", "Slots", "HotKey7 Equips", "default")) GUICtrlSetData($InvSec8, IniRead("HKSettings.ini", "Slots", "HotKey8 Equips", "default")) Case $msg = $btn3 HotKeySet(GUICtrlRead($hotkey1), GUICtrlRead($InvSec1)) HotKeySet(GUICtrlRead($hotkey2), GUICtrlRead($InvSec2)) HotKeySet(GUICtrlRead($hotkey3), GUICtrlRead($InvSec3)) HotKeySet(GUICtrlRead($hotkey4), GUICtrlRead($InvSec4)) HotKeySet(GUICtrlRead($hotkey5), GUICtrlRead($InvSec5)) HotKeySet(GUICtrlRead($hotkey6), GUICtrlRead($InvSec6)) HotKeySet(GUICtrlRead($hotkey7), GUICtrlRead($InvSec7)) HotKeySet(GUICtrlRead($hotkey8), GUICtrlRead($InvSec8)) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ;Pause Hotkeyz Func Pause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Hotkeyz is "Paused"', 450, 29) HotKeySet($hotkey1) HotKeySet($hotkey2) HotKeySet($hotkey3) HotKeySet($hotkey4) HotKeySet($hotkey5) HotKeySet($hotkey6) HotKeySet($hotkey7) HotKeySet($hotkey8) WEnd HotKeySet(GUICtrlRead($hotkey1), GUICtrlRead($InvSec1)) HotKeySet(GUICtrlRead($hotkey2), GUICtrlRead($InvSec2)) HotKeySet(GUICtrlRead($hotkey3), GUICtrlRead($InvSec3)) HotKeySet(GUICtrlRead($hotkey4), GUICtrlRead($InvSec4)) HotKeySet(GUICtrlRead($hotkey5), GUICtrlRead($InvSec5)) HotKeySet(GUICtrlRead($hotkey6), GUICtrlRead($InvSec6)) HotKeySet(GUICtrlRead($hotkey7), GUICtrlRead($InvSec7)) HotKeySet(GUICtrlRead($hotkey8), GUICtrlRead($InvSec8)) ToolTip("") EndFunc ;==>Pause .... Func Slot1() Opt("WinWaitDelay", 100) Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 0) WinWait("classname=TRunnerForm", "") If Not WinActive("classname=TRunnerForm", "") Then WinActivate("classname=TRunnerForm", "") WinWaitActive("classname=TRunnerForm", "") MouseClick("left", 545, 63, 1, 0) Sleep(20) MouseClick("left", 420, 162, 1, 0) Sleep(20) MouseClick("left", 545, 63, 1, 0) Sleep(20) EndFunc ;==>Slot1 Okay, here is how it works. Essentially, you input one letter or number into the input box, click refresh, and it should set that key as a Hot key. It does this very well... However! If I say have Hotkey1 set to use the key "1", but during the time the program is running, I change it to "2", and click refresh, "2" will work as the hot key, but so will "1" as well! I've tried multiple things to make sure it only uses the latest key you put in, but to no avail. Any help would be appreciated! P.S. Yes, I know... Arrays would make the script that much effecient, but I like it this way so I can learn better Link to comment Share on other sites More sharing options...
martin Posted January 13, 2008 Share Posted January 13, 2008 (edited) Okay, so this is becoming my help thread, haha: Heres the code(or whats important of it): expandcollapse popup#include <GUIConstants.au3> Global $Paused ; GUI Set-up GUICreate("Stick Online Hotkeyz", 300, 225) $btn1 = GUICtrlCreateButton("Save", 65, 200, 75, 20) $btn2 = GUICtrlCreateButton("Load", 155, 200, 75, 20) $btn3 = GUICtrlCreateButton("Refresh", 110, 3, 75, 20) $hotkey1 = GUICtrlCreateInput("", 59, 25, 14, 20) GUICtrlSetLimit(-1, 1) $hotkey2 = GUICtrlCreateInput("", 59, 75) GUICtrlSetLimit(-1, 1) $hotkey3 = GUICtrlCreateInput("", 59, 125) GUICtrlSetLimit(-1, 1) $hotkey4 = GUICtrlCreateInput("", 59, 175) GUICtrlSetLimit(-1, 1) $hotkey5 = GUICtrlCreateInput("", 204, 25) GUICtrlSetLimit(-1, 1) $hotkey6 = GUICtrlCreateInput("", 204, 75) GUICtrlSetLimit(-1, 1) $hotkey7 = GUICtrlCreateInput("", 204, 125) GUICtrlSetLimit(-1, 1) $hotkey8 = GUICtrlCreateInput("", 204, 175) GUICtrlSetLimit(-1, 1) $InvSec1 = GUICtrlCreateCombo("Slot1", 79, 25, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec2 = GUICtrlCreateCombo("Slot1", 79, 75, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec3 = GUICtrlCreateCombo("Slot1", 79, 125, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec4 = GUICtrlCreateCombo("Slot1", 79, 175, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec5 = GUICtrlCreateCombo("Slot1", 224, 25, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec6 = GUICtrlCreateCombo("Slot1", 224, 75, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec7 = GUICtrlCreateCombo("Slot1", 224, 125, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") $InvSec8 = GUICtrlCreateCombo("Slot1", 224, 175, 55) GUICtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16 |Slot17|Slot18|Slot19|Slot20|") GUICtrlCreateLabel("Hotkey 1:", 5, 27) GUICtrlCreateLabel("Hotkey 2:", 5, 77) GUICtrlCreateLabel("Hotkey 3:", 5, 127) GUICtrlCreateLabel("Hotkey 4:", 5, 177) GUICtrlCreateLabel("Hotkey 5:", 150, 27) GUICtrlCreateLabel("Hotkey 6:", 150, 77) GUICtrlCreateLabel("Hotkey 7:", 150, 127) GUICtrlCreateLabel("Hotkey 8:", 150, 177) GUISetState(@SW_SHOW) While 1 TraySetState(1) HotKeySet("{F1}", "Pause") HotKeySet("{ESC}", "Terminate") $msg = GUIGetMsg() Select Case $msg = $btn1 ;Saves to INI File - For later accsessing If FileExists("HKSettings.ini") Then FileDelete("HKSettings.ini") IniWrite("HKSettings.ini", "HotKeys", "HotKey1", GUICtrlRead($hotkey1)) IniWrite("HKSettings.ini", "HotKeys", "HotKey2", GUICtrlRead($hotkey2)) IniWrite("HKSettings.ini", "HotKeys", "HotKey3", GUICtrlRead($hotkey3)) IniWrite("HKSettings.ini", "HotKeys", "HotKey4", GUICtrlRead($hotkey4)) IniWrite("HKSettings.ini", "HotKeys", "HotKey5", GUICtrlRead($hotkey5)) IniWrite("HKSettings.ini", "HotKeys", "HotKey6", GUICtrlRead($hotkey6)) IniWrite("HKSettings.ini", "HotKeys", "HotKey7", GUICtrlRead($hotkey7)) IniWrite("HKSettings.ini", "HotKeys", "HotKey8", GUICtrlRead($hotkey8)) IniWrite("HKSettings.ini", "Slots", "HotKey1 Equips", GUICtrlRead($InvSec1)) IniWrite("HKSettings.ini", "Slots", "HotKey2 Equips", GUICtrlRead($InvSec2)) IniWrite("HKSettings.ini", "Slots", "HotKey3 Equips", GUICtrlRead($InvSec3)) IniWrite("HKSettings.ini", "Slots", "HotKey4 Equips", GUICtrlRead($InvSec4)) IniWrite("HKSettings.ini", "Slots", "HotKey5 Equips", GUICtrlRead($InvSec5)) IniWrite("HKSettings.ini", "Slots", "HotKey6 Equips", GUICtrlRead($InvSec6)) IniWrite("HKSettings.ini", "Slots", "HotKey7 Equips", GUICtrlRead($InvSec7)) IniWrite("HKSettings.ini", "Slots", "HotKey8 Equips", GUICtrlRead($InvSec8)) Case $msg = $btn2 ;Loads INI File - For quick setup GUICtrlSetData($hotkey1, IniRead("HKSettings.ini", "HotKeys", "HotKey1", "default")) GUICtrlSetData($hotkey2, IniRead("HKSettings.ini", "HotKeys", "HotKey2", "default")) GUICtrlSetData($hotkey3, IniRead("HKSettings.ini", "HotKeys", "HotKey3", "default")) GUICtrlSetData($hotkey4, IniRead("HKSettings.ini", "HotKeys", "HotKey4", "default")) GUICtrlSetData($hotkey5, IniRead("HKSettings.ini", "HotKeys", "HotKey5", "default")) GUICtrlSetData($hotkey6, IniRead("HKSettings.ini", "HotKeys", "HotKey6", "default")) GUICtrlSetData($hotkey7, IniRead("HKSettings.ini", "HotKeys", "HotKey7", "default")) GUICtrlSetData($hotkey8, IniRead("HKSettings.ini", "HotKeys", "HotKey8", "default")) GUICtrlSetData($InvSec1, IniRead("HKSettings.ini", "Slots", "HotKey1 Equips", "default")) GUICtrlSetData($InvSec2, IniRead("HKSettings.ini", "Slots", "HotKey2 Equips", "default")) GUICtrlSetData($InvSec3, IniRead("HKSettings.ini", "Slots", "HotKey3 Equips", "default")) GUICtrlSetData($InvSec4, IniRead("HKSettings.ini", "Slots", "HotKey4 Equips", "default")) GUICtrlSetData($InvSec5, IniRead("HKSettings.ini", "Slots", "HotKey5 Equips", "default")) GUICtrlSetData($InvSec6, IniRead("HKSettings.ini", "Slots", "HotKey6 Equips", "default")) GUICtrlSetData($InvSec7, IniRead("HKSettings.ini", "Slots", "HotKey7 Equips", "default")) GUICtrlSetData($InvSec8, IniRead("HKSettings.ini", "Slots", "HotKey8 Equips", "default")) Case $msg = $btn3 HotKeySet(GUICtrlRead($hotkey1), GUICtrlRead($InvSec1)) HotKeySet(GUICtrlRead($hotkey2), GUICtrlRead($InvSec2)) HotKeySet(GUICtrlRead($hotkey3), GUICtrlRead($InvSec3)) HotKeySet(GUICtrlRead($hotkey4), GUICtrlRead($InvSec4)) HotKeySet(GUICtrlRead($hotkey5), GUICtrlRead($InvSec5)) HotKeySet(GUICtrlRead($hotkey6), GUICtrlRead($InvSec6)) HotKeySet(GUICtrlRead($hotkey7), GUICtrlRead($InvSec7)) HotKeySet(GUICtrlRead($hotkey8), GUICtrlRead($InvSec8)) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ;Pause Hotkeyz Func Pause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Hotkeyz is "Paused"', 450, 29) HotKeySet($hotkey1) HotKeySet($hotkey2) HotKeySet($hotkey3) HotKeySet($hotkey4) HotKeySet($hotkey5) HotKeySet($hotkey6) HotKeySet($hotkey7) HotKeySet($hotkey8) WEnd HotKeySet(GUICtrlRead($hotkey1), GUICtrlRead($InvSec1)) HotKeySet(GUICtrlRead($hotkey2), GUICtrlRead($InvSec2)) HotKeySet(GUICtrlRead($hotkey3), GUICtrlRead($InvSec3)) HotKeySet(GUICtrlRead($hotkey4), GUICtrlRead($InvSec4)) HotKeySet(GUICtrlRead($hotkey5), GUICtrlRead($InvSec5)) HotKeySet(GUICtrlRead($hotkey6), GUICtrlRead($InvSec6)) HotKeySet(GUICtrlRead($hotkey7), GUICtrlRead($InvSec7)) HotKeySet(GUICtrlRead($hotkey8), GUICtrlRead($InvSec8)) ToolTip("") EndFunc;==>Pause .... Func Slot1() Opt("WinWaitDelay", 100) Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 0) WinWait("classname=TRunnerForm", "") If Not WinActive("classname=TRunnerForm", "") Then WinActivate("classname=TRunnerForm", "") WinWaitActive("classname=TRunnerForm", "") MouseClick("left", 545, 63, 1, 0) Sleep(20) MouseClick("left", 420, 162, 1, 0) Sleep(20) MouseClick("left", 545, 63, 1, 0) Sleep(20) EndFunc;==>Slot1 Okay, here is how it works. Essentially, you input one letter or number into the input box, click refresh, and it should set that key as a Hot key. It does this very well... However! If I say have Hotkey1 set to use the key "1", but during the time the program is running, I change it to "2", and click refresh, "2" will work as the hot key, but so will "1" as well! I've tried multiple things to make sure it only uses the latest key you put in, but to no avail. Any help would be appreciated! P.S. Yes, I know... Arrays would make the script that much effecient, but I like it this way so I can learn better If you set a hot key, HotKeySet($hky,$function) then that key will call $function until it is told to stop like this HotKeySet($hky);no function So if the user is going to be allowed to change a hot key for a function you will have to keep track of what the last set key was. This might do it but I haven't tested it!! ;add the next line Dim $RecordHK[2][8];2 sets of data for each of the 8 hot keys. . . Case $msg = $btn3 My_HotKeySet(1, GUICtrlRead($hotkey1), GUICtrlRead($InvSec1), $RecordHK) My_HotKeySet(2, GUICtrlRead($hotkey2), GUICtrlRead($InvSec2), $RecordHK) . .. ;Add the next function ;returns 1 on success, 0 on failure ;hot key ref is $num from 1 to .. Func My_HotKeySet($num, $hkey, $HkFunc, ByRef $LastHK) Local $changed = False $num -= 1;set to zero based if $num < 0 then return 0;failed ;see if the key used for a hotkey has changed If $LastHK[0][$num] <> $hkey Then;EDIT added missing [0] If $LastHK[0][$num] <> '' then HotKeySet($LastHK[0][$num]);stop the last key $LastHK[0][$num] = $hkey;save the new key $changed = True EndIf ;see if function for a Hotkey has changed If $LastHK[1][$num] <> $HkFunc Then $LastHK[1][$num] = $HkFunc;save the new function $changed = True EndIf If $changed Then Return HotKeySet($hkey, $HkFunc) Return 1 EndFunc EDIT: Corrected error Edited January 14, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 Okay, thanks, that looks right... But for: Func My_HotKeySet($num, $hkey, $HkFunc, ByRef $LastHK) Do I set $hkey to one of my hot key variables, ie $hotkey1? And $HkFunc to $InvSec1? If so, I would have to have multiple or only one of these functions? Thanks for your help, I am kinda new as you can see... Realized now I should have done arrays for easier management Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 Well I have tried a bunch of edits on that script(I hope I put it in right) but I always get this ERROR: If $LastHK[$num] <> $hkey Then If ^ERROR Error: Array variable has incorrect number of subscripts... etc. I have tried replacing $num with 1 through 8, nothing. Changed $hkey (Which I am supposed to? To $hotkey1, 2 ,3 etc?) Thanks in advance. Really need this helped out with Link to comment Share on other sites More sharing options...
GEOSoft Posted January 13, 2008 Share Posted January 13, 2008 Well I have tried a bunch of edits on that script(I hope I put it in right) but I always get this ERROR: If $LastHK[$num] <> $hkey Then If ^ERROR Error: Array variable has incorrect number of subscripts... etc. I have tried replacing $num with 1 through 8, nothing. Changed $hkey (Which I am supposed to? To $hotkey1, 2 ,3 etc?) Thanks in advance. Really need this helped out withTry replacing all occurences of $LastHK[0][WithUbound($LastHK) -1 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 Like this? ;Add the next function ;returns 1 on success, 0 on failure ;hot key ref is $num from 1 to .. Func My_HotKeySet($num, $hkey, $HkFunc, ByRef $LastHK) Local $changed = False $num -= 1;set to zero based if $num < 0 then return 0;failed ;see if the key used for a hotkey has changed If Ubound($LastHK) -1 <> $hkey Then If Ubound($LastHK) -1 <> '' then HotKeySet(Ubound($LastHK) -1);stop the last key $LastHK[0][$num] = $hkey;save the new key $changed = True EndIf ;see if function for a Hotkey has changed If Ubound($LastHK) -1 <> $HkFunc Then $LastHK[1][$num] = $HkFunc;save the new function $changed = True EndIf If $changed Then Return HotKeySet($hkey, $HkFunc) Return 1 EndFunc Link to comment Share on other sites More sharing options...
GEOSoft Posted January 13, 2008 Share Posted January 13, 2008 Like this? ;Add the next function ;returns 1 on success, 0 on failure ;hot key ref is $num from 1 to .. Func My_HotKeySet($num, $hkey, $HkFunc, ByRef $LastHK) Local $changed = False $num -= 1;set to zero based if $num < 0 then return 0;failed ;see if the key used for a hotkey has changed If Ubound($LastHK) -1 <> $hkey Then If Ubound($LastHK) -1 <> '' then HotKeySet(Ubound($LastHK) -1);stop the last key $LastHK[0][$num] = $hkey;save the new key $changed = True EndIf ;see if function for a Hotkey has changed If Ubound($LastHK) -1 <> $HkFunc Then $LastHK[1][$num] = $HkFunc;save the new function $changed = True EndIf If $changed Then Return HotKeySet($hkey, $HkFunc) Return 1 EndFuncThat's the general idea. This line also bothers me but I'll have to take a closer look at it later. It doesn't seem right. $LastHK[0][$num] = $hkey The idea behind using Ubound($LastKH) -1 is that array[0] does not always contain a count of the array elements. It may actually contain data instead. NOTE: I have not yet looked at how you built the array so this could be off base. Using Ubound has solved numerous array problems in the past George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 13, 2008 Author Share Posted January 13, 2008 (edited) Well, technically, I don't have any arrays Edited January 14, 2008 by Cactuscat222 Link to comment Share on other sites More sharing options...
Cactuscat222 Posted January 14, 2008 Author Share Posted January 14, 2008 Sorry for double post: But I finally did it... The answer was so obvious. All I did was create another variable($HotKeyPrev) that = $Hotkey1(The input). Then, when I refresh(Click $btn3), It sets $HotKeyPrev to do nothing, then redefines $hotkey1 and $HotKeyPrev with the new values. Heres the basic code: ;Upon Start up, set current values to Prev variable $HKPrev1 = GUICTRLREAD($hotkey1) $HKPrev2 = GUICTRLREAD($hotkey2) $HKPrev3 = GUICTRLREAD($hotkey3) $HKPrev4 = GUICTRLREAD($hotkey4) $HKPrev5 = GUICTRLREAD($hotkey5) $HKPrev6 = GUICTRLREAD($hotkey6) $HKPrev7 = GUICTRLREAD($hotkey7) $HKPrev8 = GUICTRLREAD($hotkey8) .... Case $msg = $btn3 HotKeySet($HKPrev1) HotKeySet($HKPrev2) HotKeySet($HKPrev3) HotKeySet($HKPrev4) HotKeySet($HKPrev5) HotKeySet($HKPrev6) HotKeySet($HKPrev7) HotKeySet($HKPrev8) $HKPrev1 = GUICTRLREAD($hotkey1) $HKPrev2 = GUICTRLREAD($hotkey2) $HKPrev3 = GUICTRLREAD($hotkey3) $HKPrev4 = GUICTRLREAD($hotkey4) $HKPrev5 = GUICTRLREAD($hotkey5) $HKPrev6 = GUICTRLREAD($hotkey6) $HKPrev7 = GUICTRLREAD($hotkey7) $HKPrev8 = GUICTRLREAD($hotkey8) HotKeySet(GUICtrlRead($hotkey1), GUICtrlRead($InvSec1)) HotKeySet(GUICtrlRead($hotkey2), GUICtrlRead($InvSec2)) HotKeySet(GUICtrlRead($hotkey3), GUICtrlRead($InvSec3)) HotKeySet(GUICtrlRead($hotkey4), GUICtrlRead($InvSec4)) HotKeySet(GUICtrlRead($hotkey5), GUICtrlRead($InvSec5)) HotKeySet(GUICtrlRead($hotkey6), GUICtrlRead($InvSec6)) HotKeySet(GUICtrlRead($hotkey7), GUICtrlRead($InvSec7)) HotKeySet(GUICtrlRead($hotkey8), GUICtrlRead($InvSec8)) Link to comment Share on other sites More sharing options...
GEOSoft Posted January 14, 2008 Share Posted January 14, 2008 Sorry for double post: But I finally did it... The answer was so obvious. All I did was create another variable($HotKeyPrev) that = $Hotkey1(The input). Then, when I refresh(Click $btn3), It sets $HotKeyPrev to do nothing, then redefines $hotkey1 and $HotKeyPrev with the new values. Heres the basic code: ;Upon Start up, set current values to Prev variable $HKPrev1 = GUICTRLREAD($hotkey1) $HKPrev2 = GUICTRLREAD($hotkey2) $HKPrev3 = GUICTRLREAD($hotkey3) $HKPrev4 = GUICTRLREAD($hotkey4) $HKPrev5 = GUICTRLREAD($hotkey5) $HKPrev6 = GUICTRLREAD($hotkey6) $HKPrev7 = GUICTRLREAD($hotkey7) $HKPrev8 = GUICTRLREAD($hotkey8) .... Case $msg = $btn3 HotKeySet($HKPrev1) HotKeySet($HKPrev2) HotKeySet($HKPrev3) HotKeySet($HKPrev4) HotKeySet($HKPrev5) HotKeySet($HKPrev6) HotKeySet($HKPrev7) HotKeySet($HKPrev8) $HKPrev1 = GUICTRLREAD($hotkey1) $HKPrev2 = GUICTRLREAD($hotkey2) $HKPrev3 = GUICTRLREAD($hotkey3) $HKPrev4 = GUICTRLREAD($hotkey4) $HKPrev5 = GUICTRLREAD($hotkey5) $HKPrev6 = GUICTRLREAD($hotkey6) $HKPrev7 = GUICTRLREAD($hotkey7) $HKPrev8 = GUICTRLREAD($hotkey8) HotKeySet(GUICtrlRead($hotkey1), GUICtrlRead($InvSec1)) HotKeySet(GUICtrlRead($hotkey2), GUICtrlRead($InvSec2)) HotKeySet(GUICtrlRead($hotkey3), GUICtrlRead($InvSec3)) HotKeySet(GUICtrlRead($hotkey4), GUICtrlRead($InvSec4)) HotKeySet(GUICtrlRead($hotkey5), GUICtrlRead($InvSec5)) HotKeySet(GUICtrlRead($hotkey6), GUICtrlRead($InvSec6)) HotKeySet(GUICtrlRead($hotkey7), GUICtrlRead($InvSec7)) HotKeySet(GUICtrlRead($hotkey8), GUICtrlRead($InvSec8))Well done! Now back to my Arabic studies. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
FreeFry Posted January 14, 2008 Share Posted January 14, 2008 (edited) Glad to see that you fixed it! I was looking into it, and I "accidently" remade the code a little bit.. I hope you don't mind. :| It has full saving and loading support. There's just one tiny little bug.. when it tries to update(on loading) the Combo boxes, if one is to be set to Slot1, it for some weird reason becomes Slot10 :S expandcollapse popup#include <GUIConstants.au3> Dim $SettingsFile = @ScriptDir & "\HKSettings.ini" Dim $a_HKeys[8][4] ;$a_HKeys[x][0] = Hotkey Character ;$a_HKeys[x][1] = Hotkey Function(SlotX) ;$a_HKeys[x][0] = Input CtrlID(used in loading and applying settings) ;$a_HKeys[x][0] = Combo CtrlID(used in loading and applying settings) ; GUI Set-up $GuiHandle = GUICreate("Stick Online Hotkeyz",300,225) ; better save the gui handle, useful later on $btn1 = GuiCtrlCreateButton("Save", 65, 200, 75, 20) $btn2 = GuiCtrlCreateButton("Load", 155, 200, 75, 20) $a_HKeys[0][2] = GuiCtrlCreateInput( "1", 59, 25, 13, 20) $a_HKeys[1][2] = GuiCtrlCreateInput( "2", 59, 75) $a_HKeys[2][2] = GuiCtrlCreateInput( "3", 59, 125) $a_HKeys[3][2] = GuiCtrlCreateInput( "4", 59, 175) $a_HKeys[4][2] = GuiCtrlCreateInput( "5", 204, 25) $a_HKeys[5][2] = GuiCtrlCreateInput( "6", 204, 75) $a_HKeys[6][2] = GuiCtrlCreateInput( "7", 204, 125) $a_HKeys[7][2] = GuiCtrlCreateInput( "8", 204, 175) $a_HKeys[0][3] = GuiCtrlCreateCombo( "Slot1", 79, 25, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") $a_HKeys[1][3] = GuiCtrlCreateCombo( "Slot1", 79, 75, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") $a_HKeys[2][3] = GuiCtrlCreateCombo( "Slot1", 79, 125, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") $a_HKeys[3][3] = GuiCtrlCreateCombo( "Slot1", 79, 175, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") $a_HKeys[4][3] = GuiCtrlCreateCombo( "Slot1", 224, 25, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") $a_HKeys[5][3] = GuiCtrlCreateCombo( "Slot1", 224, 75, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") $a_HKeys[6][3] = GuiCtrlCreateCombo( "Slot1", 224, 125, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") $a_HKeys[7][3] = GuiCtrlCreateCombo( "Slot1", 224, 175, 55, Default, $CBS_DROPDOWNLIST) GuiCtrlSetData(-1, "Slot2|Slot3|Slot4|Slot5|Slot6|Slot7|Slot8|Slot9|Slot10|Slot11|Slot12|Slot13|Slot14|Slot15|Slot16|Slot17|Slot18|Slot19|Slot20|") GuiCtrlCreateLabel("Hotkey 1:", 5, 27) GuiCtrlCreateLabel("Hotkey 2:", 5, 77) GuiCtrlCreateLabel("Hotkey 3:", 5, 127) GuiCtrlCreateLabel("Hotkey 4:", 5, 177) GuiCtrlCreateLabel("Hotkey 5:", 150, 27) GuiCtrlCreateLabel("Hotkey 6:", 150, 77) GuiCtrlCreateLabel("Hotkey 7:", 150, 127) GuiCtrlCreateLabel("Hotkey 8:", 150, 177) ;Load(and apply) hotkeys _LoadSettings() ;Hotkey Set-up HotKeySet("{ESC}", "_Exit") ;~ Traysetstate(1) ; no need for this, 1 is default Guisetstate(@SW_show) ; show gui window AFTER settings is loaded While 1 $msg = GuiGetMsg() Select Case $msg = $btn1 ;Saves to INI File - For later accsessing ;If FileExists( "HKSettings.ini") Then FileDelete( "HKSettings.ini") ; no need for this, the value in the ini get's replaced by the new one... _SaveSettings(); better keep the main loop small - Saves and applies new binds Case $msg = $btn2 ;Loads INI File - For quick setup _LoadSettings() ; keep it small :P - loads and applies hotkeys Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEND Func _SaveSettings() For $i = 0 To UBound($a_HKeys)-1 IniWrite($SettingsFile, "HotKeys", "Hotkey" & $i+1, $a_HKeys[$i][0]) IniWrite($SettingsFile, "Equips", "Equip" & $i+1, $a_HKeys[$i][1]) Next _ApplySettings() EndFunc Func _LoadSettings() Local $HotKey, $Equip For $i = 0 To UBound($a_HKeys)-1 $HotKey = IniRead($SettingsFile, "HotKeys", "Hotkey" & $i+1, String($i+1)) $Equip = IniRead($SettingsFile, "Equips", "Equip" & $i+1, "Slot1") $a_HKeys[$i][0] = $HotKey $a_HKeys[$i][1] = $Equip GUICtrlSetData($a_HKeys[$i][2], $HotKey) ControlCommand($GuiHandle, "", $a_HKeys[$i][3], "SelectString", $Equip); Seems to be a bug here, when it tries to select "Slot1", it actually selects "Slot10" Next _ApplySettings() EndFunc Func _ApplySettings() For $i = 0 To UBound($a_HKeys)-1 HotKeySet($a_HKeys[$i][0]) ; unbinds old keys Next For $i = 0 To UBound($a_HKeys)-1 $a_HKeys[$i][0] = GUICtrlRead($a_HKeys[$i][2]) ; retrieves new bind(s) $a_HKeys[$i][1] = GuiCtrlRead($a_HKeys[$i][3]) ; retrieves new bind(s) Next For $i = 0 To UBound($a_HKeys)-1 HotKeySet($a_HKeys[$i][0], "_HandleKeys") ; rebinds new keys Next EndFunc Func _HandleKeys() Local $s_Equip For $i = 0 To UBound($a_HKeys)-1 If @HotKeyPressed = $a_HKeys[$i][0] Then $s_Equip = $a_HKeys[$i][1] ExitLoop EndIf Next If Not WinActive("classname=TRunnerForm") Then HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "_HandleKeys") Return EndIf Switch $s_Equip Case "Slot1" ; your code here. (you could just copy paste the Slot1 function in here if you want to, OR just create a function for each hotkey(like Slot1() and call them), ex: ;~ Call("Slot1") Case "Slot2" ;code here Case "Slot3" ;code here Case "Slot4" ;code here Case "Slot5" ;code here Case "Slot6" ;code here Case "Slot7" ;code here Case "Slot8" ;code here EndSwitch EndFunc Func _Exit() If WinActive($GuiHandle) Then Exit EndFunc #region Slot functions Func Slot1() Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) MouseClick("left", 545, 63, 1, 0) sleep(20) MouseClick("left", 420, 162, 1, 0) sleep(20) MouseClick("left", 545, 63, 1, 0) sleep(20) EndFunc #endregion Slot functions Edited January 14, 2008 by FreeFry Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now