Jump to content
Sign in to follow this  
jermz27

AutoIt Program Edit/Debug help needed

Recommended Posts

jermz27

I am looking for some help editing and debugging a few AutoIt programs. I can setup a GoToMeeting so that we can work on it together. If you are interested please let me know ASAP. Time is an issue so I would need some real time collaboration.

Thanks in advance,

jeremy

Share this post


Link to post
Share on other sites
stormbreaker

And what would those programs be? I know about the following tools:

SIDENOTE: Paid support is not offered here. We just support because we are willing to.


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites
Melba23

jermz27,

Welcome to the AutoIt forum. :)

Just post the scripts here (but not all at once!) and explain the problems you are having - I am sure someone will be able to help you. If the scripts are very large then posting a short reproducer script which shows the specific difficulty is a better idea as it saves us wading through masses of irrelavant code - and doing this often helps you solve your own problem as well. ;)

So over to you. :)

M23

P.S. One thing to keep in mind:

Time is an issue so I would need some real time collaboration

The sense of urgency is entirely on your side - just remember that we are all volunteers here (as MKISH has already pointed out). ;)

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
jermz27

Thanks for the responses, I appreciate it. Let me start by saying that I am not a programmer and very new to AutoIt so I will apologize upfront if any of this should be basic or common knowledge. I was handed some code that previous employees wrote and asked to "make it work". I think that the easiest thing to do is to explain what needs to be done and then show the code that is supposed to be doing this. We have a computer connected to a device that takes measurements from a laser micrometer. The AutoIt file is supposed to take 98-100 measurements, and put them into an access database and excel file. The lasermic has a display on it that is running real time measurements. If I open a hyperterminal session to the micrometer I am able to capture the current measurement by pressing SHIFT-A. Once you press shift+a the measurement is put into the hyperterminal window as A02338 which is really equal to 233.8. Every couple seconds a new measurement is taken and that needs to be captured. Once all 98-100 measurements are taken it then needs to be put into excel and access. If there is a way to add the measurements into access or excel real time that would work too.

Here is the code:

#include <GUIConstantsEx.au3>
#include <File.au3>
#include <File.au3>



$i=0
$q=0
If WinActive("MMI emulator")= False Then
$oMMI = ObjCreate("MMI emulator")

ElseIf WinActive("laser mic - HyperTerminal") = False Then

$oHyp = ObjCreate("laser mic - HyperTerminal")
EndIf

WinActivate ( "MMI emulator")
Sleep (1000)
WinMove ( "MMI emulator", "", 0, 0)
Sleep (1000)
MouseClick("left", 45, 178)
Sleep (1000)
MouseClick("left", 222, 287)
sleep(1500)
WinActivate ("laser mic - HyperTerminal")
Sleep (1000)
Send ("+a")
Sleep (10)
Winactivate ("MMI emulator")
Sleep (2000)
MouseClick("left", 222, 287)
Sleep (10)
Winactivate ("laser mic - HyperTerminal")
Sleep (1000)
Send ("+a")

WinMove ( "laser mic - HyperTerminal", "", 0, 0, 500, 500)
MouseClick("left", 15, 431)
Do
Sleep (10)
Send ("+{UP}")
Sleep (1)
$q=$q + 1
Until $q = 41
Sleep (10)
send("^c")





WinActivate("Microsoft Access - Database_2003version")

WinSetState ( "Microsoft Access - Database_2003version", "", @SW_MAXIMIZE)
MouseClick("Left",385,314)
$clip= ClipGet()
$clip2 = StringStripCR ($clip & chr(13)&chr(10))

$value = StringSplit($clip2,"A")
;$value2 = StringTrimLeft($value,1)

$l= 1
$t = 2

Do
$value2 = stringtrimleft($value[$t],1)
$value2 = Number($value2)
$value2 = $value2/10
Send($value2,1)
Send("{Enter}")
$t=$t+1
Until $t=100
Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

jermz27,

And what is wrong with the code you posted? Why do you need help with it? :huh:

M23

P.S. When you next post code please use Code tags. Just put [autoit] before and [/autoit] after your posted code - then you get the scrolling syntax-coloured box as you see above. ;)


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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
jermz27

Sorry about the AutoIt tags... I will make sure to do that in the future. I am not sure why but the code above has the 3 include statements and then there should be a $length=0 below those. Then on the next like $i=0. Not sure why that is missing.

The first issue is: I was told that when you click on the .exe it is supposed to open the hyperterminal window for you. It is also supposed to open the MMI Emulator window. It doesn't do either of those things. If you open each of the windows manually AutoIt will pull the MMI window to the front, and click on the correct buttons to start the measurements. Manually opening the windows isn't a big deal but I would like to make it as easy as possible for the users.

Lines 17-26 appear to be working correctly (if the MMI window is already open). It will pull the MMI to the front, put it at 0,0 and then click in the correct locations. Starting at line 27, the hyperterminal window should be active and it should send a SHIFT A (like pressing the shift key and then the a key). That should paste the current reading on the micrometer into the hyperterminal window. The hyperterminal window is correctly moved and resized but instead of doing a shift a it starts to highlight and scroll up in the window. I am then presented with "Line -1; Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded" error. Once that reading is recorded by the shift a, another shift a should be simulated ever 2 seconds 97 times. In all there will be 97 numbers listed in the hyperterminal window. If I can get that far I will be pretty happy (not done but happy)! Thanks for your help.

Share this post


Link to post
Share on other sites
Melba23

jermz27,

Sorry for the delay - we are digging out an old rockery and my better half takes priority over you! :D

Let us do this in small steps. Firstly how to get the 2 apps runnign if they are not already:

; Is the MMI simulator active
If Not WinActive("MMI emulator") Then
    ; If not then start it
    Run("path to your MMI emulator")
    ; And wait for it to begin
    WinWaitActive("MMI emulator")
EndIf

; And now the laser mic
If Not WinActive("laser mic - HyperTerminal") Then
    ; If not then start it
    Run("path to your laser mic app")
    ; And wait for it to begin
    WinWaitActive("laser mic - HyperTerminal")
EndIf

That should do the trick. :)

The next thing I would like you to do is to examine these apps with the Window Info tool (it is at "Your_AutoIt_PathAu3Info.exe"). Make sure the "Control" tab is selected and then drag the little "gunsight" icon over the app window. If it highlights the different parts of the GUI as you go - in particular any of the elements you later need to click or read - we might be able to get rid of all those "MouseClick"s. Just let us know all the values you see in the "Control" tab when it is over one of these GUI elements - we will then let you know if you are lucky. ;)

M23

Edited by Melba23
Added " - see below

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
guinness

Melba23,

You're missing a quote in that code, should be WinActive("laser mic - HyperTerminal") if jermz27 is interested.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
jermz27

I can only make 2 more posts before 4:32AM so I will try to make the best of it (is this because my account is new or are all accounts limited to 5 posts per day)?

No worries on the reply, I can't even explain how much I appreciate your help as it is!

Ok, I created a brand new .au3 file to start rewriting this all in hoping to clean it up a bit in the process. I am able to open the hyperterminal (hypertrm.exe but not able to get it to open the test.ht file that has all the settings in it. Not by using the path to the .ht file directly anyway c:\test.ht). I will keep looking into this unless you know of an easy way to do that.

It looks like most if not all of the MouseClick items show as independent GUI elements. Here is an example of one button that needs to be clicked (hopefully this is the correct way to post this :sweating: )

  • Class: Button
  • Instance: 6
  • ClassnameNN: Button6
  • Advanced (Class): [CLASS:Button; INSTANCE:6]
  • ID:
  • Text: Execute
  • Position: 176, 118
  • Size: 93, 25
  • ControlClick Coords: 27, 13
  • Style: 0x5600000B
  • ExStyle: 0x00000000
  • Handle: 0x000A02FA
Most of the MouseClicks are buttons but there is a drop down that I will try to figure out on my own (after I see how you can do it with the button of course).

Share this post


Link to post
Share on other sites
Melba23

jermz27,

I have removed the "New User" limitation of 5 posts. We have it to stop new members going rogue straight away - but you seem a serious enough guy. ;)

It might be that you need to pass the name of the specific "test.ht" file to the hyperterminal executable - try this:

Run("Pathhypertrm.exe Pathtest.ht")

If you click on the "test.ht" file, does it open automatically in the correct app? If so then you could try:

ShellExecute("Pathtest.ht")

Let us know how it goes. :)

Good news about the controls. Now we know it could work we also need the data from the "Window" tab - then we can try to use the Control* functions to operate them. Take a look in the Help file yourself - the syntax is not too difficult - but if you run into trouble just give us the Window data and we will see what we can do. You will see that those functions can control combos as well as buttons. ;)

Speak to you tomorrow - unless anyone else drops in first. :)

M23


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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
MvGulik

Note: If jermz27 is up to it (motivational and kill wise). It might not be a bad idea to get him up to speed with basic functions use.


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
jermz27

M23, thanks for removing the limitation. Also, the ShellExecute worked for running the hyperterminal connection. My two biggest goals are to now figure out the buttons and getting the data into access. The syntax is killing me. I have googled a ton trying to find all these answers but for one reason or another I am unable to make everything work together. Sorry for being a pain!

MvGulik, I am stuck in a position where I have to get this working in the next 2 days. I have tried recruiting help from people that have far more experience than I do and outside of this forum have gotten no help or even replies. I have offered to pay as well as join up on-line to make it easier and that still wasn't enough to motivate them. I have never programmed before so this is all new to me. I want to learn and try to figure this out on my own but unfortunately time is my enemy so I have to mix figuring it out on my own with asking you all for help. In the end I am learning a bit this way (obviously not ideal) as well as getting this done so that I can finally go home. I will however promise to return the favor for any help that I do get (volunteer, donations, what ever it takes). Any help is appreciated beyond belief.

Share this post


Link to post
Share on other sites
MvGulik

Roger. Deadlines and learning new stuff generally don't mix that well either.

Same for deadlines and fora, but your in good hands with Melba.

GL


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
Melba23

jermz27,

Expecting you to get this running in 2 days is ludicrous. Would your employers expect you to be able to write fluently in a foreign language which you did not previously speak after a mere 2 days? Of course not - and this situation is identical. Please tell them from a coder of 40+ years experience that their attitude is quite simply ridiculous - show them this post if you wish! ;)

Now to the code. I am delighted that ShellExecute worked. Now as to the controls - buttons first. As you can identify the separate controls we should be able use the Control* commands like this:

ControlClick("GUI_Title", "", "[CLASS:Button;INSTANCE:6]")

That should click the button whose details you showed above.

You mentioned a combo - for that you would use the ControlCommand function with first "FindString" and then "SetCurrentSelection". See how you get on with that.

Unfortunately without having the same apps as you to test our suggestions we are reliant on your reports to determine where to go next - so over to you. :)

MvGulik,

your in good hands with Melba

Thank you. :>

M23


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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
Sign in to follow this  

×