psychopyro212
Active Members-
Posts
26 -
Joined
-
Last visited
Recent Profile Visitors
psychopyro212's Achievements
Seeker (1/7)
0
Reputation
-
Progandy MYSQL udf help
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
Bump -
Progandy MYSQL udf help
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
Just to test this a little further I ran this in MySQL and used its credentials, Same results. CREATE USER 'TESTACC'@'%' IDENTIFIED BY 'TESTPASS'; GRANT ALL PRIVILEGES ON *.* TO 'TESTACC'@'%'; CREATE USER 'TESTACC'@'localhost' IDENTIFIED BY 'TESTPASS'; GRANT ALL PRIVILEGES ON *.* TO 'TESTACC'@'localhost'; -
Progandy MYSQL udf help
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
Here is my script with your included code: #include <array.au3> #include "mysql.au3" $objErr = ObjEvent("AutoIt.Error","MyErrFunc") $SQLAddress = "127.0.0.1" $SQLUserName = "root" $SQLPassword = "" $SQLDatabase = "Testing" _MySQL_InitLibrary() $MysqlConn = _MySQL_Init() _MySQL_Real_Connect($MysqlConn,$SQLAddress,$SQLUserName,$SQLPassword,$SQLDatabase) If @error Then MsgBox("", "", "Error Connecting") $query = "CREATE TABLE ErrorLog(ErrorNO Int Auto_Increment, Time TIMESTAMP,Error VARCHAR(100) NOT NULL,Sevarity Int(1) NOT NULL, Primary Key(ErrorNO))" ;$query = "INSERT INTO errorlog(Error,Sevarity) VALUES ('Test Error',0)" $result = _MySQL_Real_Query($MysqlConn, $query) ConsoleWrite("Return code = " & $result & @crlf & @MON & "/" & @MDAY & "/" & @YEAR & "-" & @hour & ":" & @MIN & ":" & @sec &@CRLF) _MySQL_Close($MysqlConn) _MySQL_EndLibrary() Func MyErrFunc() $hexnum=hex($objErr.number,8) Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $objErr.description & @CRLF & _ "err.windescription is: " & $objErr.windescription & @CRLF & _ "err.lastdllerror is: " & $objErr.lastdllerror & @CRLF & _ "err.scriptline is: " & $objErr.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $objErr.source & @CRLF & _ "err.helpfile is: " & $objErr.helpfile & @CRLF & _ "err.helpcontext is: " & $objErr.helpcontext _ ) exit EndFunc Here is the _MySQL_Real_Query function Func _MySQL_Real_Query($MySQL_ptr, $querystring, $querystringlength = Default) If Not $MySQL_ptr Then Return SetError(3, 0, $CR_NULL_POINTER) If $querystringlength <= 0 Or $querystringlength = Default Then $querystringlength = StringLen($querystring) Local $query = DllCall($ghMYSQL_LIBMYSQL, "int", "mysql_real_query", "ptr", $MySQL_ptr, "str", $querystring, "ulong", $querystringlength) If @error Then Return SetError(1, 0, 1) Return $query[0] EndFunc ;==>_MySQL_Real_Query Getting this output from the script: Return code = 0 01/22/2014-21:03:40 Here is the timestamp from the last entry into the database: '25', '2014-01-19 20:37:23', 'Test Error', '0' I can run this command in mysql workbench with no issues: INSERT INTO errorlog(Error,Sevarity) VALUES ('Test Error',0) This is functioning properly in my script and having no issues generating the table in mysql: $query = "CREATE TABLE ErrorLog(ErrorNO Int Auto_Increment, Time TIMESTAMP,Error VARCHAR(100) NOT NULL,Sevarity Int(1) NOT NULL, Primary Key(ErrorNO))" As I showed in the script I revised I tried this and got no errors. Root has all privileges. Thank you for your prompt reply! -
Progandy MYSQL udf help
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
Just to clarify this a little the code commented out to create a table worked just fine so it is interfacing with mysql to some extent. -
I'm playing with Progandy's MYSQL udf and I'm having issues writing to the database. Example Code: #include <array.au3> #include "mysql.au3" $SQLAddress = "127.0.0.1" $SQLUserName = "root" $SQLPassword = "" $SQLDatabase = "Testing" _MySQL_InitLibrary() $MysqlConn = _MySQL_Init() _MySQL_Real_Connect($MysqlConn,$SQLAddress,$SQLUserName,$SQLPassword,$SQLDatabase) If @error Then MsgBox("", "", "Error Connecting") Else ;MsgBox("","","Success") EndIf ;$query = "CREATE TABLE ErrorLog(ErrorNO Int Auto_Increment, Time TIMESTAMP,Error VARCHAR(100) NOT NULL,Sevarity Int(1) NOT NULL, Primary Key(ErrorNO))" $query = "INSERT INTO errorlog(Error,Sevarity) VALUES ('Test Error',0)" $result = _MySQL_Query($MysqlConn, $query) ConsoleWrite($result & @CRLF) _MySQL_Close($MysqlConn) _MySQL_EndLibrary() I'm attempting to use the MYSQL command: "INSERT INTO errorlog(Error,Sevarity) VALUES ('Test Error',0)" Reading through the udf a return from the _Mysql_Query function of 0 (which is what im getting) means success. I then go to check the table in MYSQL workbench and it never wrote to the table. I ran the same command in workbench and it wrote to the table any ideas?
-
_ChangeScreenRes UDF issue
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
Bump I simply dont understand why this does not work... all its doing is changing the width.... it has no problem setting to 1024x768 -
Im Currently using this udf: ;=============================================================================== ; ; Function Name: _ChangeScreenRes() ; Description: Changes the current screen geometry, colour and refresh rate. ; Version: 1.0.0.1 ; Parameter(s): $i_Width - Width of the desktop screen in pixels. (horizontal resolution) ; $i_Height - Height of the desktop screen in pixels. (vertical resolution) ; $i_BitsPP - Depth of the desktop screen in bits per pixel. ; $i_RefreshRate - Refresh rate of the desktop screen in hertz. ; Requirement(s): AutoIt Beta > 3.1 ; Return Value(s): On Success - Screen is adjusted, @ERROR = 0 ; On Failure - sets @ERROR = 1 ; Forum(s): http://www.autoitscript.com/forum/index.php?showtopic=20121 ; Author(s): Original code - psandu.ro ; Modifications - PartyPooper ; ;=============================================================================== Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh) Local Const $DM_PELSWIDTH = 0x00080000 Local Const $DM_PELSHEIGHT = 0x00100000 Local Const $DM_BITSPERPEL = 0x00040000 Local Const $DM_DISPLAYFREQUENCY = 0x00400000 Local Const $CDS_TEST = 0x00000002 Local Const $CDS_UPDATEREGISTRY = 0x00000001 Local Const $DISP_CHANGE_RESTART = 1 Local Const $DISP_CHANGE_SUCCESSFUL = 0 Local Const $HWND_BROADCAST = 0xffff Local Const $WM_DISPLAYCHANGE = 0x007E If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]") Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE)) If @error Then $B = 0 SetError(1) Return $B Else $B = $B[0] EndIf If $B <> 0 Then DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5) DllStructSetData($DEVMODE, 4, $i_Width, 2) DllStructSetData($DEVMODE, 4, $i_Height, 3) DllStructSetData($DEVMODE, 4, $i_BitsPP, 1) DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5) $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) If @error Then $B = -1 Else $B = $B[0] EndIf Select Case $B = $DISP_CHANGE_RESTART $DEVMODE = "" Return 2 Case $B = $DISP_CHANGE_SUCCESSFUL DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width) $DEVMODE = "" Return 1 Case Else $DEVMODE = "" SetError(1) Return $B EndSelect EndIf EndFunc ;==>_ChangeScreenRes This works great when changing my resolution to 1024 X 768 but it will not change my resolution to 1366 x 768 anyone care to take a stab at this? Im using windows 7 home premium X64
-
TCP send / receive
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
Local $ip = @IPAddress1 Local $port = 33891 Local $message, $tcpconnect, $message1 Global $Socket[1] Sendtcp() Func Sendtcp() TCPStartup() $tcponnect = TCPConnect($ip, $port) $message = "test" TCPSend($tcponnect,$message) While 1 For $i = 1 To UBound($Socket) - 1 $message1 = TCPRecv($Socket[$i], 100000) If $message1 <> "" Then _ MsgBox("", "", $message1) Next WEnd EndFunc ;==>Sendtcp Ok using what youve shown me ive come up with this for the client im still scratching my head.... Edit : forgot _ArrayAdd($Socket, $tcponnect) -
TCP send / receive
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
ERROR: syntax error TCPSend(Socket[$i], $Approve) had a moment ignore me lol thank you -
TCP send / receive
psychopyro212 replied to psychopyro212's topic in AutoIt General Help and Support
#include <array.au3> Local $ip = @IPAddress1 Local $port = 33891 Local $TCPListen, $TCPAccept, $Approve Global $Socket[1] starttcp() Func starttcp() TCPShutdown() TCPStartup() $TCPListen = TCPListen($ip, $port) While 1 $TCPAccept = TCPAccept($TCPListen) If $TCPAccept <> -1 Then _ArrayAdd($Socket, $TCPAccept) receivetcp() EndIf WEnd EndFunc ;==>starttcp Func receivetcp() While 1 For $i = 1 To UBound($Socket) - 1 $Message = TCPRecv($Socket[$i], 100000) If $Message <> "" Then _ MsgBox("", "", $Message) sendtcp() Next WEnd EndFunc ;==>receivetcp Func sendtcp() $Approve = "HEARD YOU!" TCPSend($TCPAccept, $Approve) receivetcp() EndFunc ;==>sendtcp The problem im running into is turning around and talking back to the client i appreciate the help you have both given me its helped tidy my code up quite a bit. The question i have is will the code i posted above be capable or turning around and sending a msg back to the client? -
I've been screwing around with tcp functions for a few days just trying to expand my knowledge of autoit a little and I've hit a brick wall with this one its a login server/client its being used to send login to server server verifies the login and sends the client a accepted or denied I'm running into the issue where the client/server stop communicating AND where rather the server isn't sending the client the verified/denied or the client isn't receiving it so i wrote in some error reporting to a text file which I've pasted here :http://pastebin.com/GLfaZkt3 any help would be great I've hit a brick wall. P.S. Yes i know i use retarded variable names and yes i know its very crude code I'm still learning. Server #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=server.exe #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> Local $szIPADDRESS = @IPAddress1 Local $nPORT = 33891 Local $nport1 = 33892 Local $MainSocket, $edit, $ConnectedSocket, $szIP_Accepted, $sendverf, $enroleeip, $sendver Local $msg, $recv, $login, $password, $recvd, $error1 GUICreate("My Server (IP: " & $szIPADDRESS & ")", 300, 200, 100, 100) $edit = GUICtrlCreateEdit("", 10, 10, 280, 180) GUISetState() Server() Func Server() TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT) If $MainSocket = -1 Then Exit $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 $szIP_Accepted = SocketToIP($ConnectedSocket) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop $recv = TCPRecv($ConnectedSocket, 2048) If @error Then restart() $recv = BinaryToString($recv, 4) If $recv <> "" Then GUICtrlSetData($edit, _ @HOUR & ":" & @MIN & ":" & @SEC & " " & $szIP_Accepted & " > Login : " & $recv & @CRLF & GUICtrlRead($edit)) verify() WEnd EndFunc ;==>Server Func verify() Local $ConnectedSocket1, $szData1 Local $CLIENTIP = $szIP_Accepted Local $nport1 = 33892 $ConnectedSocket1 = -1 $ConnectedSocket1 = TCPConnect($CLIENTIP, $nport1) If @error Then FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " & "Failed to connect to client---$ConnectedSocket1 = TCPConnect($CLIENTIP, $nport1 line 40 server") If $recv <> "" Then $recvd = StringSplit($recv, "\", 1) $login = $recvd[1] $password = $recvd[2] $login = IniRead("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\Data.ini", "Users", $login, "error") EndIf If @error Then $sendverf = 0 EndIf If $login = $password Then $sendverf = "Accepted" GUICtrlSetData($edit, _ @HOUR & ":" & @MIN & ":" & @SEC & " " & $szIP_Accepted & " > Login Accepted! " & @CRLF & GUICtrlRead($edit)) FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " & $szIP_Accepted & " > Login Accepted! ") $sendver = StringToBinary($sendverf, 4) Else $sendverf = "Denied" GUICtrlSetData($edit, _ @HOUR & ":" & @MIN & ":" & @SEC & " " & $szIP_Accepted & " > Login Denied! " & @CRLF & GUICtrlRead($edit)) FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " & $szIP_Accepted & " > Login Denied! ") $sendver = StringToBinary($sendverf, 4) EndIf TCPSend($ConnectedSocket1, $sendverf) If @error Then FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " & "Failed to send string to client---TCPSend($ConnectedSocket1, $sendverf) line 62 server") restart() EndFunc ;==>verify Func restart() TCPShutdown() server() EndFunc ;==>restart Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP Client #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=client.exe #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 252, 52, 192, 124) $Input1 = GUICtrlCreateInput("account", 0, 0, 177, 21) $Input2 = GUICtrlCreateInput("password", 0, 24, 177, 21) $Button1 = GUICtrlCreateButton("Login", 184, 8, 57, 33) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### Global $login, $pass, $send, $string, $verf, $recver, $reccon, $error1 Global $ConnectedSocket, $szData, $ConnectedSocket1, $MainSocket1 Global $szIPADDRESS = @IPAddress1 Global $nPORT = 33891 Local $nport1 = 33892 Global $ConnectedSocket = -1 $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) main() Func main() ;While 1 ; $nMsg = GUIGetMsg() ;Switch $nMsg ; Case $GUI_EVENT_CLOSE ; Exit ;Case $Button1 $login = GUICtrlRead($Input1) $pass = GUICtrlRead($Input2) Sleep(1000) Sendlogin() ;EndSwitch ;WEnd EndFunc ;==>main Func Sendlogin() $send = String($login & "\" & $pass) TCPStartup() $ConnectedSocket = -1 $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) If @error Then FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " &"Failed to connect to server --- $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) line 40 client") TCPSend($ConnectedSocket, StringToBinary($send, 4)) If @error Then FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " & "Failed to send string to server --- TCPSend($ConnectedSocket, StringToBinary($send, 4)) line 45 client") receiveverf() EndFunc ;==>Sendlogin Func receiveverf() $MainSocket1 = TCPListen($szIPADDRESS, $nPORT1) If $MainSocket1= -1 Then FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " &"client or server dropped connection --- $MainSocket1 = TCPListen($szIPADDRESS, $nPORT1) _ If $MainSocket1= -1 line 56 client") $ConnectedSocket1 = -1 Do $ConnectedSocket1 = TCPAccept($MainSocket1) Until $ConnectedSocket1 <> -1 $szIP_Accepted = SocketToIP($ConnectedSocket1) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop $recv = TCPRecv($ConnectedSocket1, 2048) $recv = BinaryToString($recv, 4) If $recv <> "" Then FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " &"Client Received Response from Server!");MsgBox("","",$recv) restart() WEnd EndFunc ;==>receiveverf Func restart() $recv = "" TCPShutdown() main() EndFunc ;==>restart Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP Func errorwrite() FileWrite("C:\Documents and Settings\Administrator\Desktop\Projects\Login\Secure\log.txt", @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " & $error1) main() EndFunc
-
And looking at your code i noticed $iY -= 1 which i assume is the same as $y=Int($y- 1)? and i found a pic of what im trying to use this code to draw the horizontal and vertical lines on this
-
Understood and thank you for your time!
-
basically what im trying to do is use this array to draw lines on a graph the third deminsion represents the coordinates on the graph so lets say that $x = 4 $y = 53 $coords = "800,900" ;----(ill string split this later) $array[$x][$y][$coords] so that array[$x][$y][$coords] is = $array [4][53]["800,900"] so i can plot on my graph but what im asking is you used $aBoard[$iY][$iX] i want to add [$coords] how would i use $aBoard[$iY][$iX] = "o" without destroying whats in $coords
-
heres a question for you if i were to turn the array into a 3 dimensional array like so adpos[$x][$y][$value] how would i modify just x and y without changeing $value? if i can do this i can just store the coord's directly into the array.