FMS

autoit and using / connecting SQL DB

6 posts in this topic

Hello,

I've made a script where this is a piece of, this because it will be a lit easyer to read and use for others iff solved.
I am willing to learn the use of SQL / autoit connection but can't find anythin helpfull on the internet
Or iff I find something it is a little dated.
The following script is also build whit dated material.

What mine consernens are is SQL injection and all the other security isseu's.
I hope somebody can look at mine script and help me whit making this work.

- Is this a good way to make a connection and check it or is there a better way?

At this point I've an error :
 

"D:\map\file.au3" (72) : ==> The requested action with this object has failed.:
$adCN.Open ($constrim)
$adCN^ ERROR
>Exit code: 1    Time: 18.51
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

$Form1 = GUICreate("Form1", 480, 100, 190, 320)
$button1 = GUICtrlCreateButton("check and run", 128, 24, 113, 33)
$Input_ip = GUICtrlCreateInput("127.0.0.1", 8, 16, 113, 21)
$Input_usr = GUICtrlCreateInput("harry", 8, 40, 113, 21)
$connection_label = GUICtrlCreateLabel("connection = ", 248, 16, 52, 17)
$user_label = GUICtrlCreateLabel("username = ", 248, 40, 52, 17)
$connection_status_label = GUICtrlCreateLabel("connection not checked", 304, 16, 190, 70)
$user_status_label = GUICtrlCreateLabel("user not checked", 304, 40, 190, 17)

GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
   Case $GUI_EVENT_CLOSE
      Exit
   Case $button1
      $checked = check_connection_usr(GUICtrlRead($Input_ip),GUICtrlRead($Input_usr))
      if $checked Then
         ;MsgBox($MB_SYSTEMMODAL, "function","true")
         get_username(GUICtrlRead($Input_ip),GUICtrlRead($Input_usr))
      Else
         MsgBox($MB_SYSTEMMODAL, "function","an error occured")
      EndIf
   EndSwitch
WEnd

Func check_connection_usr($input_ip,$input_usr)
   GUICtrlSetData($connection_status_label, "checking")
   GUICtrlSetData($user_status_label, "checking")

   if $input_usr = "" then
      GUICtrlSetData($user_status_label, "no username!")
      Return False
   Else
      GUICtrlSetData($user_status_label, $input_usr & " will be checked")
      if $input_ip = "" then
         GUICtrlSetData($connection_status_label, "no IP or adres!")
         Return False
      else
         $check_ping = Ping($input_ip, 250)
         if not $check_ping Then
            GUICtrlSetData($connection_status_label, "error in ping")
            Return False
         Else
            GUICtrlSetData($connection_status_label, "ping = " & $check_ping & "ms.")
            return True
         EndIf
      EndIf
   EndIf
EndFunc

Func get_username($xIP,$usr)
   Local $ServerAddress = $xIP
   Local $ServerUserName = "root"
   Local $ServerPassword = ""
   Local $DatabaseName = ""

   $constrim="DRIVER={SQL Server};SERVER=" & $xIP & ";DATABASE=" & $DatabaseName & ";uid=" & $ServerUserName & ";pwd=" & $ServerPassword & ";"
   $adCN = ObjCreate ("ADODB.Connection") 
   $adCN.Open ($constrim) 
      MsgBox(0,"",$constrim )

      if @error Then
          MsgBox(0, "ERROR", "Failed to connect to the database")
          Exit
      Else
          MsgBox(0, "Success!", "Connection to database successful!")
      EndIf

      $sQuery = "select * from users where username=" & $usr

      $result = $adCN.Execute($sQuery)
      MsgBox(0, "", $result.username( " = username" ).Value) ;---------------------------is this ok ?
      GUICtrlSetData($user_status_label, $result.username & " username present");---------------------------is this ok ?
   $adCN.Close ; ==> Close the database
   
EndFunc

 

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you want to use ADO start here:

 

EDIT: btw.

but can't find anythin helpfull on the internet
Or iff I find something it is a little dated.

I see the internet is far far away from this forum ?

;)

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites
1 hour ago, FMS said:

$result = $adCN.Execute($sQuery)  
MsgBox(0, "", $result.username( " = username" ).Value) ;---------------------------is this ok ?

your $result is not special object, specialy prepared for your case.
This is Recordset. You can read about here: https://msdn.microsoft.com/en-us/library/ms681510(v=vs.85).aspx

You can use $oRecordset.GetRows() method to get your result as array.

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I tried this ADO.au3 :) it did give some error's in the examples....
I did entered these errors on the downloadpage for you to see @mLipok
Thanks for the reply anyway ;)

Also I need to say I'm willing to learn but don't know how to start.
This is also why i made this "example-script" so easy to learn so other people could have something of it.

I realy hope somebody could help me whit this and tell me how to get that name in the correct field :)

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

For futher references, I've got it working whit EzMySql :)

(iff somebody sees a flaw in this or does know a better/simpler way, I'm open for sugestions)
(I still have that injection-issue to work on :))

Here is the script working for me :

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
   #include "EzMySql.au3"
   #include <Array.au3>

$Form1 = GUICreate("Form1", 480, 100, 190, 320)
$button1 = GUICtrlCreateButton("check and run", 128, 24, 113, 33)
$Input_ip = GUICtrlCreateInput("127.0.0.1", 8, 16, 113, 21)
$Input_usr = GUICtrlCreateInput("harry", 8, 40, 113, 21)
$connection_label = GUICtrlCreateLabel("connection = ", 248, 16, 52, 17)
$user_label = GUICtrlCreateLabel("username = ", 248, 40, 52, 17)
$connection_status_label = GUICtrlCreateLabel("connection not checked", 304, 16, 190, 70)
$user_status_label = GUICtrlCreateLabel("user not checked", 304, 40, 190, 17)

GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
   Case $GUI_EVENT_CLOSE
      Exit
   Case $button1
      $checked = check_connection_usr(GUICtrlRead($Input_ip),GUICtrlRead($Input_usr))
      if $checked Then
         ;MsgBox($MB_SYSTEMMODAL, "function","true")
         get_username(GUICtrlRead($Input_ip),GUICtrlRead($Input_usr))
      Else
         MsgBox($MB_SYSTEMMODAL, "function","an error occured")
      EndIf
   EndSwitch
WEnd

Func check_connection_usr($input_ip,$input_usr)
   GUICtrlSetData($connection_status_label, "checking")
   GUICtrlSetData($user_status_label, "checking")

   if $input_usr = "" then
      GUICtrlSetData($user_status_label, "no username!")
      Return False
   Else
      GUICtrlSetData($user_status_label, $input_usr & " will be checked")
      if $input_ip = "" then
         GUICtrlSetData($connection_status_label, "no IP or adres!")
         Return False
      else
         $check_ping = Ping($input_ip, 250)
         if not $check_ping Then
            GUICtrlSetData($connection_status_label, "error in ping")
            Return False
         Else
            GUICtrlSetData($connection_status_label, "ping = " & $check_ping & "ms.")
            return True
         EndIf
      EndIf
   EndIf
EndFunc

Func get_username($xIP,$usr)


   If Not _EzMySql_Startup() Then
       MsgBox(0, "Error Starting MySql", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg())
       Exit
   EndIf

   Local $hostname = "127.0.0.1"
   Local $SQLport = "3306"
   Local $dbname = "DBname"
   Local $usrname = "username"
   Local $Pass = "pass"

   If Not _EzMySql_Open($hostname, $usrname, $Pass, $dbname, $SQLport) Then
       MsgBox(0, "Error opening Database", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg())
       Exit
   EndIf

   If Not _EzMySql_SelectDB($dbname) Then
       MsgBox(0, "Error setting Database to use", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg())
       Exit
   EndIf

   $aOk = _EzMySql_GetTable2d("SELECT username FROM users WHERE username = '"& $usr & "';")
   $error = @error
   If Not IsArray($aOk) Then MsgBox(0, $sMySqlStatement & " error", $error)

   if _EzMySql_Rows() = 0 then
       MsgBox(0, "check", "nothing found ; rows = " & _EzMySql_Rows()& " colums = " & _EzMySql_Columns())
       GUICtrlSetData($user_status_label, "no " & $usr & " found")
   Else
      MsgBox(0, "check", "array [1][0] = " & $aOk[1][0] & " rows = " & _EzMySql_Rows()& " colums = " & _EzMySql_Columns())
      GUICtrlSetData($user_status_label, $aOk[1][0] & " found!")
   EndIf

   _EzMySql_Close()
   _EzMySql_ShutDown()
EndFunc

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@FMS

as to your question:

21 hours ago, FMS said:

###############################
ADO.au3 v.2.1.13 BETA (970) : ==> COM Error intercepted !
$oADO_Error.description is:     [Microsoft][ODBC-stuurprogrammabeheer] De naam van de gegevensbron is niet gevonden en er is geen standaardstuurprogramma opgegeven
$oADO_Error.windescription:     Er is een uitzondering opgetreden.

$oADO_Error.number is:  80020009
$oADO_Error.lastdllerror is:    0
$oADO_Error.scriptline is:  970
$oADO_Error.source is:  Microsoft OLE DB Provider for ODBC Drivers
$oADO_Error.helpfile is:    
$oADO_Error.helpcontext is:     0
###############################
###############################

 

tried your MySQL example in de zip.
But did give me this error.

Did i something wrong?
I only chaged the DB name ,username and pw, and ofcourse the query to something simple.

 

In opening post your example uses SQLite udf

and MS SQL

   $constrim="DRIVER={SQL Server};SERVER=" & $xIP & ";DATABASE=" & $DatabaseName & ";uid=" & $ServerUserName & ";pwd=" & $ServerPassword & ";"
   $adCN = ObjCreate ("ADODB.Connection")

 

 

Then you comment about using MySQL example , now you are using EzMySQL

If you finally want to use  MySQL with ADO first you must to install ODBC Driver for MySQL
https://dev.mysql.com/downloads/connector/odbc/

The error description: 

[Microsoft][ODBC-stuurprogrammabeheer] De naam van de gegevensbron is niet gevonden en er is geen standaardstuurprogramma opgegeven
[Microsoft] [ODBC Driver Manager] The data source name is not found and no default driver specified

Cleary states that you have not installed this driver yet.

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Miliardsto
      By Miliardsto
      Hello.
      Drag option works only on parent window but as we can see on the parent gui is showed up child gui (on the right side with the color).
      Desired action is when we want to drag whole program we can also drag child gui and child gui will drag with parent gui.
      How to do this?
       
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> GUIRegisterMsg($WM_NCHITTEST, "_NCHITTEST") $hGUI = GUICreate("Test", 500, 500, -1, -1) $cButton_0 = GUICtrlCreateButton("Child 0", 10, 10, 80, 30) $cButton_1 = GUICtrlCreateButton("Child 1", 10, 50, 80, 30) $cButton_2 = GUICtrlCreateButton("Child 2", 10, 90, 80, 30) GUISetState(@SW_SHOW, $hGUI) ; guis Global $hChild_[3] Global $countGUI = UBound($hChild_) - 1 ;MsgBox("","",$countGUI) ; licznik dla GUI Global $gui = 0 $hChild_[0] = GUICreate("Child 0", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFF0000) GUISetState(@SW_SHOW, $hChild_[0]) $hChild_[1] = GUICreate("Child 1", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x00FF00) GUISetState(@SW_HIDE, $hChild_[1]) $hChild_[2] = GUICreate("Child 2", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x0000FF) GUISetState(@SW_HIDE, $hChild_[2]) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_0 _All_Hide() GUISetState(@SW_SHOW, $hChild_[0]) $gui = 0 Case $cButton_1 _All_Hide() GUISetState(@SW_SHOW, $hChild_[1]) $gui = 1 Case $cButton_2 _All_Hide() GUISetState(@SW_SHOW, $hChild_[2]) $gui = 2 EndSwitch WEnd Func _All_Hide() GUISetState(@SW_HIDE, $hChild_[0]) GUISetState(@SW_HIDE, $hChild_[1]) GUISetState(@SW_HIDE, $hChild_[2]) EndFunc Func _NCHITTEST($hWnd, $uMsg, $wParam, $lParam) If $hWnd = $hGUI Then Local $aPos = WinGetPos($hWnd) If Abs(BitAND(BitShift($lParam, 16),0xFFFF)- $aPos[1]) < 500 Then Return $HTCAPTION EndIf Return $GUI_RUNDEFMSG EndFunc  
    • IAMK
      By IAMK
      Hello,
       
      I have a script which uses a GUI with two buttons. It gets shown and hidden., and pressing the buttons (including their hotkeys) highlights the button, making you able to press enter the next time.
      However, I don't want that.
       
      I've tried using WinActivate() to make enter do things on another program, but the enter is still tied to the AutoIT GUI (which still has the button highlighted).
       
      Here's the important part of my code:
      $MY_GUI = GUICreate("Check.exe", 400, 300, ((@DesktopWidth / 2) - 200), -500) WinSetOnTop($MY_GUI, "", 1) ;Keeps the window on the top. $Button1 = GUICtrlCreateButton("Pass (Ctrl+P)", 40, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Fail (Ctrl+F)", 240, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $GUIText = GUICtrlCreateLabel("", 20, 10, 360, 230) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") GUICtrlSetData($GUIText, Execute($stepMessage[$step])) $showGUI = "True" GUISetState(@SW_SHOW) While($showGUI = "True") $buttonPressed = GUIGetMsg() Switch $buttonPressed Case $Button1 ;Pass $pass = "True" $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) Case $Button2 ;Fail $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) While($message = "") $message = InputBox("Check.exe", "Please enter the reason the step failed." & @CRLF, "", "", 300, 200, ((@DesktopWidth / 2) - 150), -400) WEnd Return $message EndSwitch WEnd Local $pass = "False" ;Whether "Pass" or "Fail" was pressed. Local $failLog = xxxfunc($pass) ;Returns a message to log if the step failed. ##THIS CALLS THE CODE SNIPPET ABOVE## FileWrite($file, _Now() & ": Step " & $step & getStatus($pass) & "and took " & Ceiling(TimerDiff($timer) / 1000) & " seconds." & @CRLF) If($failLog <> "") Then FileWrite($file, "Logged comment: " & $failLog & @CRLF) EndIf WinActivate("[TITLE:ProgramName]") ;Hotkeys: HotKeySet("^{p}", "pressPass") HotKeySet("^{f}", "pressFail") Func pressPass() $buttonPressed = $Button1 EndFunc Func pressFail() $buttonPressed = $Button2 EndFunc  
      The GUI's button/hotkey pressing works correctly.
      The same WinActivate code works in another script of mine.
      Together, WinActivate is not take "Active" away from the GUI's last-pressed button. How do I fix this?
       
      Thank you in advance.
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3

    • Neonovaz
      By Neonovaz
      Hello
       
      Is there anyway to store word documents in Autoit GUI? For example I have a instruction sheet that I want to bundle up with the exe.

      So a user simply clicks the icon and the stored document will launch  (Something like how you can add objects like excel sheets in word documents )

      (I Know we can launch word files from script directory)