Maffe811 Posted July 10, 2011 Share Posted July 10, 2011 Here is a macro program i made. It uses the numpad as macro hotkeys. You type what you want typed in when you press the hotkey.... And you can hide it! And no need to tell me it can all be done with arrays expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <Constants.au3> ;///Variables/// Global $ElementWidth = 150 Global $LabelHeight = 15 Global $InputHeight = 20 Global $Spacing1 = $ElementWidth + 20 Global $Spacing2 = ($ElementWidth * 2) + 30 Global $GuiWidth = ($ElementWidth * 3) + 40 Global $GuiHeight = (10 + $LabelHeight + $InputHeight) * 4 + 10 Global $ShowHide = False ;Naming Global $Name = "Numpad Macro" Global $Version = "0.9 Beta" Global $Title = $Name & " - " & $Version ;Ini file Global $FileName = @AppDataDir & "\Nupad Macro\Numpad Macro.ini" Global $FileDir = @AppDataDir & "\Nupad Macro" Global $FileSection = "Section" ;///Check for directory/// If not FileExists($FileName) Then DirCreate($FileDir) EndIf ;///Read ini values/// $Read0 = IniRead($FileName,$FileSection,"Input0","") $Read1 = IniRead($FileName,$FileSection,"Input1","") $Read2 = IniRead($FileName,$FileSection,"Input2","") $Read3 = IniRead($FileName,$FileSection,"Input3","") $Read4 = IniRead($FileName,$FileSection,"Input4","") $Read5 = IniRead($FileName,$FileSection,"Input5","") $Read6 = IniRead($FileName,$FileSection,"Input6","") $Read7 = IniRead($FileName,$FileSection,"Input7","") $Read8 = IniRead($FileName,$FileSection,"Input8","") $Read9 = IniRead($FileName,$FileSection,"Input9","") #region///Create Gui/// ;///Main Gui/// $Gui = GUICreate($Title, $GuiWidth, $GuiHeight, -1, -1) ;///Tray Menu/// Opt("TrayMenuMode", 1) TraySetState(2) TraySetIcon (@ScriptDir & "\Numpad Macro Icon.ico") ;///NUMPAD 0/// GUICtrlCreateLabel("Numpad 0", 10, 145, $ElementWidth, $LabelHeight, $SS_CENTER) $Input0 = GUICtrlCreateInput($Read0, 10, 160, $ElementWidth, $InputHeight) ;///NUMPAD 1/// GUICtrlCreateLabel("Numpad 1", 10, 100, $ElementWidth, $LabelHeight, $SS_CENTER) $Input1 = GUICtrlCreateInput($Read1, 10, 115, $ElementWidth, $InputHeight) ;///NUMPAD 2/// GUICtrlCreateLabel("Numpad 2", $Spacing1, 100, $ElementWidth, $LabelHeight, $SS_CENTER) $Input2 = GUICtrlCreateInput($Read2, $Spacing1, 115, $ElementWidth, $InputHeight) ;///NUMPAD 3/// GUICtrlCreateLabel("Numpad 3", $Spacing2, 100, $ElementWidth, $LabelHeight, $SS_CENTER) $Input3 = GUICtrlCreateInput($Read3, $Spacing2, 115, $ElementWidth, $InputHeight) ;///NUMPAD 4/// GUICtrlCreateLabel("Numpad 4", 10, 55, $ElementWidth, $LabelHeight, $SS_CENTER) $Input4 = GUICtrlCreateInput($Read4, 10, 70, $ElementWidth, $InputHeight) ;///NUMPAD 5/// GUICtrlCreateLabel("Numpad 5", $Spacing1, 55, $ElementWidth, $LabelHeight, $SS_CENTER) $Input5 = GUICtrlCreateInput($Read5, $Spacing1, 70, $ElementWidth, $InputHeight) ;///NUMPAD 6/// GUICtrlCreateLabel("Numpad 6", $Spacing2, 55, $ElementWidth, $LabelHeight, $SS_CENTER) $Input6 = GUICtrlCreateInput($Read6, $Spacing2, 70, $ElementWidth, $InputHeight) ;///NUMPAD 7/// GUICtrlCreateLabel("Numpad 7", 10, 10, $ElementWidth, $LabelHeight, $SS_CENTER) $Input7 = GUICtrlCreateInput($Read7, 10, 25, $ElementWidth, $InputHeight) ;///NUMPAD 8/// GUICtrlCreateLabel("Numpad 8", $Spacing1, 10, $ElementWidth, $LabelHeight, $SS_CENTER) $Input8 = GUICtrlCreateInput($Read8, $Spacing1, 25, $ElementWidth, $InputHeight) ;///NUMPAD 9/// GUICtrlCreateLabel("Numpad 9", $Spacing2, 10, $ElementWidth, $LabelHeight, $SS_CENTER) $Input9 = GUICtrlCreateInput($Read9, $Spacing2, 25, $ElementWidth, $InputHeight) ;///Show/Hide Button/// $ShowHideButton = GUICtrlCreateButton("Hide", $Spacing1, 150, $ElementWidth, 30) #endregion///Create Gui/// ;///Show gui/// GUISetState(@SW_SHOW) #region///Hotkeys/// HotKeySet("{Numpad0}", "_Numpad0") HotKeySet("{Numpad1}", "_Numpad1") HotKeySet("{Numpad2}", "_Numpad2") HotKeySet("{Numpad3}", "_Numpad3") HotKeySet("{Numpad4}", "_Numpad4") HotKeySet("{Numpad5}", "_Numpad5") HotKeySet("{Numpad6}", "_Numpad6") HotKeySet("{Numpad7}", "_Numpad7") HotKeySet("{Numpad8}", "_Numpad8") HotKeySet("{Numpad9}", "_Numpad9") #endregion///Hotkeys/// ;_ #region///Functions/// Func _Numpad0() Send(GUICtrlRead($Input0)) EndFunc ;==>_Numpad0 Func _Numpad1() Send(GUICtrlRead($Input1)) EndFunc ;==>_Numpad1 Func _Numpad2() Send(GUICtrlRead($Input2)) EndFunc ;==>_Numpad2 Func _Numpad3() Send(GUICtrlRead($Input3)) EndFunc ;==>_Numpad3 Func _Numpad4() Send(GUICtrlRead($Input4)) EndFunc ;==>_Numpad4 Func _Numpad5() Send(GUICtrlRead($Input5)) EndFunc ;==>_Numpad5 Func _Numpad6() Send(GUICtrlRead($Input6)) EndFunc ;==>_Numpad6 Func _Numpad7() Send(GUICtrlRead($Input7)) EndFunc ;==>_Numpad7 Func _Numpad8() Send(GUICtrlRead($Input8)) EndFunc ;==>_Numpad8 Func _Numpad9() Send(GUICtrlRead($Input9)) EndFunc ;==>_Numpad9 #endregion///Functions/// Func _ShowHide() If $ShowHide = False Then $ShowHide = True GUISetState(@SW_HIDE) TraySetState(1) TrayTip($Name, $Name & " is hidden in this icon" & @CRLF & "Click this icon to bring it back", 2000, 1) Else $ShowHide = False GUISetState(@SW_SHOW) TraySetState(2) EndIf EndFunc ;==>_ShowHide Func _Exit() IniWrite($FileName, $FileSection,"Input0" ,GUICtrlRead($Input0)) IniWrite($FileName, $FileSection,"Input1" ,GUICtrlRead($Input1)) IniWrite($FileName, $FileSection,"Input2" ,GUICtrlRead($Input2)) IniWrite($FileName, $FileSection,"Input3" ,GUICtrlRead($Input3)) IniWrite($FileName, $FileSection,"Input4" ,GUICtrlRead($Input4)) IniWrite($FileName, $FileSection,"Input5" ,GUICtrlRead($Input5)) IniWrite($FileName, $FileSection,"Input6" ,GUICtrlRead($Input6)) IniWrite($FileName, $FileSection,"Input7" ,GUICtrlRead($Input7)) IniWrite($FileName, $FileSection,"Input8" ,GUICtrlRead($Input8)) IniWrite($FileName, $FileSection,"Input9" ,GUICtrlRead($Input9)) Exit EndFunc While 1 $nMsg = GUIGetMsg() $TrayMsg = TrayGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE _Exit() Case $nMsg = $ShowHideButton Or $TrayMsg = $TRAY_EVENT_PRIMARYUP _ShowHide() Case $TrayMsg = $TRAY_EVENT_SECONDARYUP If $ShowHide = True Then MsgBox("", "Exit", "Closing " & $Title) _Exit() EndIf EndSelect WEnd [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] Link to comment Share on other sites More sharing options...
Thornhunt Posted July 10, 2011 Share Posted July 10, 2011 looks alright to me. however maybe if you made it so that when you run the program it doesnt show the gui straight away. instead it runs the previous macro's and set up a "shift + numpad" to open up a options screen, to then edit it. just saves messing around and un-needed viewing of the gui. other than that it looks ok Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D Link to comment Share on other sites More sharing options...
smartee Posted July 10, 2011 Share Posted July 10, 2011 And no need to tell me it can all be done with arrays Why not? I can almost see the arrays in my head while scrolling through your code Look at the _WinAPI_SetWindowsHookEx example in the help-file, maybe you can cleanup those HotKeySet's.Nice idea, one of my first ever AutoIt scripts waay back in the day was similar to this. Your code layout looks pretty, though its mostly repetitive, I enjoyed scrolling through the code. Link to comment Share on other sites More sharing options...
Maffe811 Posted July 11, 2011 Author Share Posted July 11, 2011 I looked at the _WinAPI_SetWindowsHookEx example, but how would you suggest i use it ? [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] Link to comment Share on other sites More sharing options...
smartee Posted July 11, 2011 Share Posted July 11, 2011 (edited) You can use it to replace hotkeyset altogether if you intend on having a large number of hotkeys But i guess if its just the numpad, a couple hotkeysets are neater EDIT: left out the "ets" before " are neater " Edited July 11, 2011 by smartee Link to comment Share on other sites More sharing options...
Maffe811 Posted July 16, 2011 Author Share Posted July 16, 2011 I just realised how i could use the WinApi function. I feel so stupid! Yes, it would be easier if a large ammount of hotkeys were needed, but if it was really big i could just make an array to go trough it! Might do that, just for the practice! [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] 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