11using System ;
2- using System . Collections . Generic ;
3- using System . ComponentModel ;
4- using System . Data ;
52using System . Drawing ;
63using System . IO ;
7- using System . Linq ;
84using System . Text ;
95using System . Threading ;
10- using System . Threading . Tasks ;
116using System . Windows . Forms ;
127
138namespace AHKMaker
149{
1510 public partial class Form1 : Form
1611 {
12+ bool clickOpen = false ;
1713 bool typeOpen = false ;
1814 bool popupOpen = false ;
1915 bool addWait = false ;
16+ bool loopOpen = false ;
17+ bool indent = false ;
2018
21- private void Visibility ( Control [ ] CurrentControl , bool visibility )
19+ private void IsIndented ( )
20+ {
21+ if ( indent )
22+ {
23+ MainCode . AppendText ( " " ) ;
24+ }
25+ }
26+
27+ private bool Visibility ( Control [ ] CurrentControl , bool visibility )
2228 {
2329 foreach ( Control control in CurrentControl )
2430 {
2531 control . Visible = visibility ;
2632 }
33+
34+ return visibility ;
2735 }
2836
2937 private bool IsBlank ( TextBox CurrentTextBox )
@@ -86,59 +94,95 @@ private void MousePositionButton_Click(object sender, EventArgs e)
8694
8795 private void ClickAction_Click ( object sender , EventArgs e )
8896 {
89- String XLocation = "X" ;
90- String YLocation = "Y" ;
97+ Control [ ] activeControls = { XYCheckBox , MouseButtonLabel , MouseCombo , NumClickLabel , NumClickInput , ClickSend } ;
98+
99+ if ( clickOpen )
100+ {
101+ clickOpen = Visibility ( activeControls , false ) ;
102+ return ;
103+ }
104+
105+ clickOpen = Visibility ( activeControls , true ) ;
106+
107+ }
108+
109+ private void ClickSend_Click ( object sender , EventArgs e )
110+ {
111+ Control [ ] activeControls = { XYCheckBox , MouseButtonLabel , MouseCombo , NumClickLabel , NumClickInput , ClickSend } ;
112+ String XLocation = "" ;
113+ String YLocation = "" ;
114+ String MouseButton = MouseCombo . Text ;
115+ int numOfClicks = Convert . ToInt32 ( NumClickInput . Value ) ;
116+ bool click = false ;
117+
118+
91119
92120 if ( XYCheckBox . Checked )
93121 {
94122 XLocation = MousePosXTextBox . Text ;
95123 YLocation = MousePosYTextBox . Text ;
96124 }
97125
98- MainCode . AppendText ( String . Format ( "MouseMove, {0}, {1}\r \n Click\r \n " , XLocation , YLocation ) ) ;
126+ if ( ClickOption . Checked )
127+ {
128+ click = true ;
129+ }
130+
131+ if ( click )
132+ {
133+ MainCode . AppendText ( String . Format ( "MouseClick, {0}, {1}, {2}, {3} \r \n " , MouseButton , XLocation , YLocation , numOfClicks ) ) ;
134+ }
135+ else
136+ {
137+ MainCode . AppendText ( String . Format ( "MouseMove, {0}, {1} \r \n " , XLocation , YLocation ) ) ;
138+ }
139+
140+ clickOpen = Visibility ( activeControls , false ) ;
141+ IsIndented ( ) ;
99142 }
100143
101144 private void AddType_Click ( object sender , EventArgs e )
102145 {
103146 Control [ ] activeControls = { TypeTextLabel , TypeTextInput , TypeTextConfirm , InsertModKey , InsertModKeyLabel } ;
104147
105- if ( typeOpen == true )
148+ if ( typeOpen )
106149 {
107150 typeOpen = false ;
108151 Visibility ( activeControls , false ) ;
109152 return ;
110153 }
111154
112- Visibility ( activeControls , true ) ;
113- typeOpen = true ;
155+ typeOpen = Visibility ( activeControls , true ) ;
156+
114157
115158 activeControls [ 1 ] . Focus ( ) ;
116159
117160 }
118161
162+
119163 private void TypeTextConfirm_Click ( object sender , EventArgs e )
120164 {
121165 Control [ ] activeControls = { TypeTextLabel , TypeTextInput , TypeTextConfirm , InsertModKey , InsertModKeyLabel } ;
122166
123167 MainCode . AppendText ( String . Format ( "Send, {0}\r \n " , TypeTextInput . Text ) ) ;
124168
125- Visibility ( activeControls , false ) ;
126- typeOpen = false ;
169+ typeOpen = Visibility ( activeControls , false ) ;
170+ IsIndented ( ) ;
127171 }
128172
129173 private void AddPopup_Click ( object sender , EventArgs e )
130174 {
131175 Control [ ] activeControls = { PopupTextLabel , PopupTextInput , PopupTitleInput , PopupTitleLabel , PopupConfirm } ;
132176
133- if ( popupOpen == true )
177+ if ( popupOpen )
134178 {
135- popupOpen = false ;
136- Visibility ( activeControls , false ) ;
179+
180+ popupOpen = Visibility ( activeControls , false ) ;
137181 return ;
138182 }
139183
140- Visibility ( activeControls , true ) ;
141- popupOpen = true ;
184+ popupOpen = Visibility ( activeControls , true ) ;
185+
142186
143187 activeControls [ 1 ] . Focus ( ) ;
144188 }
@@ -149,33 +193,32 @@ private void PopupConfirm_Click(object sender, EventArgs e)
149193
150194 MainCode . AppendText ( String . Format ( "MsgBox, ,{0}, {1}\r \n " , PopupTitleInput . Text , PopupTextInput . Text ) ) ;
151195
152- Visibility ( activeControls , false ) ;
153- popupOpen = false ;
196+ popupOpen = Visibility ( activeControls , false ) ;
197+ IsIndented ( ) ;
154198 }
155199
156200 private void AddWait_Click ( object sender , EventArgs e )
157201 {
158202 Control [ ] activeControls = { WaitLabel , WaitInput , WaitConfirm } ;
159203
160- if ( addWait == true )
204+ if ( addWait )
161205 {
162- addWait = false ;
163- Visibility ( activeControls , false ) ;
206+ addWait = Visibility ( activeControls , false ) ;
164207 return ;
165208 }
166209
167- Visibility ( activeControls , true ) ;
168- addWait = true ;
210+ addWait = Visibility ( activeControls , true ) ;
169211 }
170212
171213 private void WaitConfirm_Click ( object sender , EventArgs e )
172214 {
173215 Control [ ] activeControls = { WaitLabel , WaitInput , WaitConfirm } ;
174216
175- Visibility ( activeControls , false ) ;
176- addWait = false ;
217+ addWait = Visibility ( activeControls , false ) ;
177218
178219 MainCode . AppendText ( String . Format ( "Sleep, {0}\r \n " , WaitInput . Text ) ) ;
220+
221+ IsIndented ( ) ;
179222 }
180223
181224 private void AddCustomMod_Click ( object sender , EventArgs e )
@@ -206,6 +249,7 @@ private void AddCustomMod_Click(object sender, EventArgs e)
206249 }
207250
208251 StoredMod . Text = String . Format ( "{0}{1}" , modifier , ModKeyInput . Text ) ;
252+ IsIndented ( ) ;
209253 }
210254
211255 private void HotKey_Click ( object sender , EventArgs e )
@@ -223,5 +267,37 @@ private void button3_Click(object sender, EventArgs e)
223267 {
224268 CreateFile ( Environment . CurrentDirectory + "\\ " + FileNameInput . Text + ".ahk" , MainCode . Text ) ;
225269 }
270+
271+ private void AddLoop_Click ( object sender , EventArgs e )
272+ {
273+ Control [ ] activeControls = { LoopAmountLabel , NumOfLoops , LoopAdd } ;
274+
275+ if ( loopOpen )
276+ {
277+ loopOpen = Visibility ( activeControls , false ) ;
278+ return ;
279+ }
280+
281+ loopOpen = Visibility ( activeControls , true ) ;
282+
283+ }
284+
285+ private void LoopAdd_Click ( object sender , EventArgs e )
286+ {
287+ int numOfLoops = Convert . ToInt32 ( NumOfLoops . Value ) ;
288+
289+ EndLoop . Visible = true ;
290+ indent = true ;
291+
292+ MainCode . AppendText ( "Loop, " + numOfLoops + " { \r \n " ) ;
293+ }
294+
295+ private void EndLoop_Click ( object sender , EventArgs e )
296+ {
297+ EndLoop . Visible = false ;
298+ indent = false ;
299+
300+ MainCode . AppendText ( "}\r \n " ) ;
301+ }
226302 }
227303}
0 commit comments