Jump to content

Array with decimal help!


SimpleC
 Share

Recommended Posts

I honestly have no idea why this isn't working. It should be simple!

This is just a brief example of what I'm trying to do.

#include <array.au3>

dim $test[5]
$test[0]  = 55
$test[1] = 59.25
$test[3] = 65
$test[4] = 65.45

mouseclick("left", 410, 203, 1)
sleep(100)

for $i = 0 to 3
    send($test[$i])
    sleep(50)
    send("{enter}")
    sleep(50)
next

The problem is the the loop doesn't get past the decimal. Any help would be awesome. All its trying to do is write that array to an open notepad

Link to comment
Share on other sites

  • Moderators

Hi, SimpleC. To begin with, can you explain why you declare your array with 5 elements, and then skip [2]? Is this just a type, or is this how it is in your actual script? Beyond adding the missing element, it all worked just fine for me.

Edit: Notice too that you have 5 elements in your array, but only loop through 4 of them, so you'll only get 4 outputs.

This works fine and prints out [0], [1], [2], and [3]

#include <array.au3>
dim $test[5]
   $test[0] = 55
   $test[1] = 59.25
   $test[2] = 60.31
   $test[3] = 65
   $test[4] = 65.45
 
mouseclick("left", 410, 203, 1)
   sleep(100)
 
for $i = 0 to 3
   send($test[$i])
      sleep(50)
   send("{enter}")
      sleep(50)
next
Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

local $testmax= 5, $test[$testmax]

You have 4 elements, but you skip index [2] when you define them.

If the don't skip 2 you might have 5 elements

I would loop through the array like this to simplify things for myself.

for $i= 0 to $testmax-1;

Your example prints decimals just fine.

Edited by Xandy
Link to comment
Share on other sites

As JLogan3o13 said you made some strange things, commented below.

#include <array.au3>

dim $test[5]
$test[0]  = 55
$test[1] = 59.25
                    ;<<--- Skipped ??
$test[3] = 65
$test[4] = 65.45

mouseclick("left", 410, 203, 1)
sleep(100)

for $i = 0 to 3        ;<<--- maybe to 4?
    send($test[$i])
    sleep(50)
    send("{enter}")
    sleep(50)
next

When the words fail... music speaks.

Link to comment
Share on other sites

Just a typo here on the forums. It's right in the script.

There's no error message either.

You say it works for you? Hmm. Maybe I should go try it on another computer.

Here's the actual code

dim $test[5]
$test[0] = 59
$test[1] = 59.55
$test[2] = 59
$test[3] = 59
click(410, 203)
for $i = 0 to 4
  send($test[$i])
  sleep(100)
  send("{enter}")
Next

if I take out the 59.55 and just put 59 without the decimal it works fine.

Edited by SimpleC
Link to comment
Share on other sites

You say it works for you? Hmm. Maybe I should go try it on another computer.

Na, when was your last reformat?

​It's probably the code dude, do an exact copy, somebody will solve this for you.

edit: I mis-read you. I thought you said maybe you should buy another computer. Oops, yeah try it on another machine.

Edited by Xandy
Link to comment
Share on other sites

  • Moderators

Just a typo here on the forums. It's right in the script.

There's no error message either.

You say it works for you? Hmm. Maybe I should go try it on another computer.

Here's the actual code

dim $test[5]
$test[0] = 59
$test[1] = 59.55
$test[2] = 59
$test[3] = 59
click(410, 203)
for $i = 0 to 4
send($test[$i])
sleep(100)
send("{enter}")
Next

if I take out the 59.55 and just put 59 without the decimal it works fine.

That cannot be the "actual code" as click is not a function. When I change it back to Mouseclick, it prints out the 4 numbers, with decimals, just fine. However, as you are declaring 5 elements, and looping 5 times, but only have 0-3 defined, there will be a couple of blank lines.

Edit: I am going to hazard a wild and crazy guess that you're not actually trying to print this stuff into Notepad. Why not fill us in on the name of the application you're trying to work with? There are probably ways of accomplishing what you want that are 10x easier than using MouseClick and Send.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I've been using autoit for years. I've coded literally thousands of lines of code in it. I use it everyday at work. It has to be something other then the script.

Ok.. just tested it on another computer and it works fine. So yeah, I'm not sure why it wouldn't be working on this machine.

Link to comment
Share on other sites

That cannot be the "actual code" as click is not a function. When I change it back to Mouseclick, it prints out the 4 numbers, with decimals, just fine. However, as you are declaring 5 elements, and looping 5 times, but only have 0-3 defined, there will be a couple of blank lines.

Most of my scripts have a custom function to shorten mouseclick ;)

func click($x, $y, $clicks = 1)

mouseclick("left", $x, $y, $clicks)

endfunc

Also this is just a test to figure out why my actual code isn't working. A quick throw together array to see where the problem is.

Thanks for the help though guys. I might try a complete uninstall and reinstall and see what happens. If I can't get it I'll just switch to one of my other computers.

Edited by SimpleC
Link to comment
Share on other sites

  • Moderators

That may be, but when you use MouseClick in the first post, and then your custom click function in another, without letting us in on the secret, you make it difficult to assist you ;)

Edit: Not to mention skipping or omitting elements in your array, and changing the number of elements you loop through ;)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Can you please explain what you try to achieve? Do you try to solve a real problem or do you just "play" with AutoIt?

If we know what you try to do we might provide a much simpler solution.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

What I mean is: Which application do you try to automate?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This might be caused by different screen resolutions so notepad might be on different screen coordinates or many other reasons.

But again: Is this a real task you need to solve or do you just play (means: is it worth the effort)?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Nope, this is actually something for work. I'll keep at it and report back when I figure out what's actually going on.

Solved!

I'm a noob

Haha... Ok. I had my terminate hotkey set to period.

HotKeySet(".", "terminate")

func terminate()

exit 0

EndFunc

So yeah... thanks for the help though everyone.

Edited by SimpleC
Link to comment
Share on other sites

I suggest to use something like this to send data to notepad:

Global $test[5] = [59, 59.55, 59, 59]
WinActivate("Unbenannt - Editor") ; <== Replace with the window title of your notepad
for $i = 0 to 4
  send($test[$i])
  send("{enter}")
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Solved!

I'm a noob

Haha... Ok. I had my terminate hotkey set to period.

Please, if you post a problem the next time add the complete script!

Without a complete script it is impossible to help you. And - more important - wastes our and your time!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...