/
AdbSMSSender.ahk
146 lines (130 loc) · 4.18 KB
/
AdbSMSSender.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance ignore
global DebugConsole := true
IniRead, LastIP, AdbSMSSender.ini, settings, IP
IniRead, LastIP, AdbSMSSender.ini, settings, IP
IniRead, LastAdbPath, AdbSMSSender.ini, settings, adbpath
IniRead, LastNumbers, AdbSMSSender.ini, settings, numbers
IniRead, LastSMS, AdbSMSSender.ini, settings, SMS
IniRead, connect, AdbSMSSender.ini, settings, connect
IniRead, disconnect, AdbSMSSender.ini, settings, disconnect
IniRead, command, AdbSMSSender.ini, settings, command
IniRead, wait, AdbSMSSender.ini, settings, wait
WSShell := ComObjCreate("WScript.Shell")
;ComObjError(false)
Gui, Font, , Tahoma
Gui, Add, Text, , IP Adress:
Gui, Add, Text, , Adb Path:
Gui, Add, Text, , Number`(s`):`n a,b,c
Gui, Add, Text, , Message:
Gui, Add, Edit, vIP ym
Gui, Add, Edit, vAdbPath w350
Gui, Add, Edit, vNumbers w350
Gui, Add, Edit, vSMS h200 w350
Gui, Add, Button, x5 y250 w65, Send
Gui, Add, Button, x210 y5 w100 gConnectDisconnect vButtonText, Connect
Gui, Show, x100 y100, AdbSMSSender
GuiControl, , IP, %LastIP%
GuiControl, , AdbPath, %LastAdbPath%
GuiControl, , Numbers, %LastNumbers%
GuiControl, , SMS, %LastSMS%
gosub, Test
Menu, TRAY, NoStandard
Menu, TRAY, add, Exit , GuiClose
return
GuiClose:
GuiControlGet, Numbers
GuiControlGet, SMS
GuiControlGet, IP
GuiControlGet, AdbPath
IniWrite, %IP%, AdbSMSSender.ini, settings, IP
IniWrite, %AdbPath%, AdbSMSSender.ini, settings, adbpath
IniWrite, %Numbers%, AdbSMSSender.ini, settings, numbers
IniWrite, %SMS%, AdbSMSSender.ini, settings, SMS
Gui, Destroy
COM_Release(WSShell)
ExitApp
ButtonSend:
GuiControlGet, Numbers
GuiControlGet, SMS
GuiControlGet, AdbPath
AdbShell := WSShell.Exec(AdbPath " shell" )
loop, Parse, command, |
{
StringReplace, temp, A_LoopField, $sms, %SMS%
StringReplace, temp, temp, $number, %Numbers%
if (A_Index > 1 )
Sleep, %wait%
AdbShell.StdIn.Write(temp . "`n")
}
AdbShell.StdIn.Write("exit`n")
ConsoleOutput := AdbShell.StdOut.ReadAll()
AdbShell.Terminate
DebugConsole(ConsoleOutput)
return
ConnectDisconnect:
GuiControlGet, IP
GuiControlGet, AdbPath
GuiControlGet, ButtonText
If ( ButtonText = "Connect" )
temp := adbpath " " connect
else
temp := adbpath " " disconnect
StringReplace, temp, temp, $IP, %IP%
DebugConsole(temp)
ConsoleOutput := WSShell.Exec(temp).StdOut.ReadAll()
DebugConsole(ConsoleOutput)
gosub, Test
return
Test:
DebugConsole("Starting test process..." )
GuiControlGet, IP
GuiControlGet, AdbPath
RunWait, % ComSpec " /c " """" AdbPath """" " devices"
ConsoleOutput := WSShell.Exec("""" AdbPath """" . " devices" ).StdOut.ReadAll()
DebugConsole(ConsoleOutput)
IPFoundAt := Instr(ConsoleOutput, LastIP)
if (IPFoundAt != 0 and (IP != "") ){
DebugConsole("Device is connected :)" )
GuiControl,, ButtonText, Disconnect
Gui, Font, cGreen Bold, Tahoma
}
else{
DebugConsole("Device " IP " has not been found!" )
GuiControl,, ButtonText, Connect
Gui, Font, cRed Bold, Tahoma
}
GuiControl, Font, IP
return
DebugConsole(Text) {
global
if !DebugConsole
return
if (ahk_id hDebugControl = "") {
Gui, DebugConsole:Font, , Tahoma
Gui, DebugConsole:Add, Edit, hwndhDebugControl vDebugControl w500 h200
y := A_ScreenHeight-250
x := A_ScreenWidth-550
Gui, DebugConsole:Show, x%x% y%y% , DebugConsole
Sleep, 200
}
Text .= "`n"
SendMessage, 0x000E, 0, 0,, ahk_id %hDebugControl% ;WM_GETTEXTLENGTH
SendMessage, 0x00B1, ErrorLevel, ErrorLevel,, ahk_id %hDebugControl% ;EM_SETSEL
SendMessage, 0x00C2, False, &Text,, ahk_id %hDebugControl% ;EM_REPLACESEL
return
}