Jump to content
Sign in to follow this  
ReMoTe04

Infinite varriable create, without pre-defining?

Recommended Posts

ReMoTe04

Hello!
I have a code, what if press X save the ClipBoard's text in variable, but..
if 2times press the X then the variable is lose the last save..

I want a code, what save the ClipBoard's text in a variable, but first "$text1" if that already in use, then "$text2"

Exaple, at the script's start need to define "$texts" .. if the "$texts" is 4, then save 4 times the clipboard, next abort it!

I tryed it, but it is finite.. if the text1 and text2 in use, then it wont be save.
I want THIS infinite.. if possible :D

Global $text1inuse = 0
Global $text2inuse = 0

Global $text1
Global $text2
 
    if $text1inuse = 0 Then
       $text1 = ClipGet()
       $text1inuse = 1
      TrayTip(Clipboard Saved!", "The clipboard's text saved!", 0, $TIP_ICONASTERISK)
 
    ElseIf $text2inuse = 0 Then
       $text2 = ClipGet()
       $text2inuse = 1
     TrayTip(Clipboard Saved!", "The clipboard's text saved!", 0, $TIP_ICONASTERISK)
    Else
       TrayTip("Clipboard in use!", The cipboards are full!", 0,  $TIP_ICONHAND)
    EndIf
Edited by ReMoTe04

Share this post


Link to post
Share on other sites
PainTain

That's what array's for.

Just look for it at the helpfile :)

Share this post


Link to post
Share on other sites
computergroove

There is no way that you can have an infinite anything. There are limitations to your computers Ram and hard drive space and autoit has limitations in large numbers as well. I think you need to do something with the data instead of just keep storing it in memory. You can write it to a file and read it later in the code. What do you want to do with the data?


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
ReMoTe04

That's what array's for.

Just look for it at the helpfile :)

Thanks, and how can i put these in a Combo?!

 

Func Function()
   For $x = 0 to $iMax - 1
      GUICtrlSetData(-1, $arr[$x] & "|")
   Next
EndFunc

If i use the " $arr[1]" or "$arr[0]" or anything, it return empty field..

Edited by ReMoTe04

Share this post


Link to post
Share on other sites
ReMoTe04

There is no way that you can have an infinite anything. There are limitations to your computers Ram and hard drive space and autoit has limitations in large numbers as well. I think you need to do something with the data instead of just keep storing it in memory. You can write it to a file and read it later in the code. What do you want to do with the data?

Just save it, and later use a selectable "Send" function

CHOOSE A DATA:

[saved data 1]

[saved data 2]

[saved data...]

 

Send($selected data)

Share this post


Link to post
Share on other sites
computergroove

As your array is being built you are going to need to catalog the data in it if you only want to send selected data instead of returning the entire array. What defines what is sent back?

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
computergroove

You need to understand what an array is to know what this code is supposed to do and more importantly how to send specific data back.

#include <Array.au3>

Global $aArray[16000000];maximum possible size of an array - consider changing this

HotKeySet("x","SaveClip")

While 1
     sleep(100)
WEnd

Func SaveClip()
     Send("{CTRLDOWN}" & "c" & "{CTRLUP}");copy selected data to clipboard
     $aData = ClipGet();copy the data from the Windows clipboard into $aData
     If @error then;if there is no error then the data in $aData is text
          return;leave the SaveClip function without doing anything else
     else _ArrayAdd($aArray,$aData);Add clipboard text to the array
EndFunc

I wish I could point you to a good youtube video that describes this. If you cant get it then ask and Ill try to help.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
ReMoTe04

You need to understand what an array is to know what this code is supposed to do and more importantly how to send specific data back.

#include <Array.au3>

Global $aArray[16000000];maximum possible size of an array - consider changing this

HotKeySet("x","SaveClip")

While 1
     sleep(100)
WEnd

Func SaveClip()
     Send("{CTRLDOWN}" & "c" & "{CTRLUP}");copy selected data to clipboard
     $aData = ClipGet();copy the data from the Windows clipboard into $aData
     If @error then;if there is no error then the data in $aData is text
          return;leave the SaveClip function without doing anything else
     else _ArrayAdd($aArray,$aData);Add clipboard text to the array
EndFunc

I wish I could point you to a good youtube video that describes this. If you cant get it then ask and Ill try to help.

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Teszt\teszt.au3"    
"D:\Teszt\teszt.au3" (16) : ==> Illegal text at the end of statement (one statement per line).:
else _ArrayAdd($aArray,$aData)
else ^ ERROR
>Exit code: 1    Time: 0.07156

defined the array.au3 :)

Share this post


Link to post
Share on other sites
computergroove

If @error then;if there is no error then the data in $aData is text
          return;leave the SaveClip function without doing anything else
     else _ArrayAdd($aArray,$aData);Add clipboard text to the array

There is something wrong with this portion of the code. Give me a bit. Im working on it.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
computergroove

To start off I was wrong about the maximum number of lines in an array. The max is 65524 + the 0.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
computergroove

This works but it wont erase the windows clipboard data after it writes to the array. According to the online documentation this should work ->  http://www.autoitscript.com/autoit3/docs/functions/ClipPut.htm

#include <Array.au3>
#include <MsgBoxConstants.au3>


Global $aArray[0];Will start an array with 1 line. When you use _ArrayAdd the script will add a new

HotKeySet("x","SaveClip")

While 1
     sleep(100)
WEnd

Func SaveClip()
     Send("{CTRLDOWN}" & "c" & "{CTRLUP}");copy selected data to clipboard
     $aData = ClipGet();copy the data from the Windows clipboard into $aData
     If @error == 0 Then
      _ArrayAdd($aArray,$aData);Add clipboard text to the array
      _ArrayDisplay($aArray)
      ClipPut("");supposed to erase the content of the clipboard but it doesn't
     EndIf
 EndFunc

After I get the data you will see that it appends the clipboard to the end of the array with arrayDisplay's output. I tried to use ClipPut("") to erase the contents of the clipboard but it isnt working. Will the contents of the selected text ever be the same 2 or more times in a row? If not then I can write a logic statement that compares the value of the last clipboard input and if its the same then it wont write it to the array.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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  

×