Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

variables and math


  • Please log in to reply
4 replies to this topic
  • Guests
  • Last active:
  • Joined: --
a script that will create a popup box in respose to a buttoncontrol with field to input two numbers representing minutes with a OK label button for when the user inputs these numbers to select

this will trigger a script to take a time/date (0000\00\00 00:00:00 format) from the clip and give me two date/time however many minutes before and after the given time date as inputed by the user

then send this information from the clipboard into fields (0000\00\00 00:00:00 format) that cant be pasted into, or selected all at once (send clip command will work, but only to send to either the year month day hour min sec) thus based on the copied 0000\00\00 00:00:00 into clip, i need to send the year moveright month moveright day moveright hour moveright minute moveright second for each of these two fields based on however many minutes before and after what the user has inputed depending on what date/time was in the clip




this one is giving me a headache but im guessing its easy for some of you here. Any help is appreciated

  • Guests
  • Last active:
  • Joined: --
sorry i meant you can only paste the day month year hour min sec one field at a time. so either the month from the clip, day, ect. I may be wording this odd sorry for that. I dont have a partial script because i am so bad with variables and math functions i never bothered to try it.

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
sorry, I didn't understood everything, but perhaps this script helps a little bit to point you to the right direction.

(Please use a name when posting....)


clipboard = 2006\08\07 06:05:04

Gui, Add, Edit, x6 y10 w180 h30 number, 
Gui, Add, Button, x6 y50 w360 h30 gok, Ok 

Gui, add, text, , DateFromClip + minutes
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 

Gui, add, text, , DateFromClip - minutes
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 
Gui, Add, Edit, , RESULT....after pressing OK 

Gui, Show, x612 y457 h550 w397, Enter a minute-value

Return

ok:
;Get time from clipboard
Clp = %clipboard%
;Replace all blank, : \ with nothing
StringReplace, Clp, Clp, \, , All
StringReplace, Clp, Clp, :, , All
StringReplace, Clp, Clp, %a_space%, , All

;Retrieve the entered minute from the dialog
ControlGetText, Number1, Edit1, Enter a minute-value

;Initialize the new variables, which holds the values - the minutes and + the minutes
TimeBefore := Clp
TimeAfter := Clp
;MsgBox, %clp% %Number1% - %TimeBefore% - %TimeAfter%
;Add the first entered minutes to the value
EnvAdd, TimeBefore, Number1, minutes
;MsgBox, %clp% %Number1% - %TimeBefore% - %TimeAfter%
;To subtract, we add with a negative number (see help)
Number1 := 0 - Number1
EnvAdd, TimeAfter, Number1, minutes
;MsgBox, %clp% %Number1% - %TimeBefore% - %TimeAfter%

;Now focus the target-window

;Send the new value with added minutes
StringLeft, Year2Send, TimeBefore, 4
StringMid, Month2Send, TimeBefore, 5, 2
StringMid, Day2Send, TimeBefore, 7, 2
StringMid, Hour2Send, TimeBefore, 9, 2
StringMid, Minute2Send, TimeBefore, 11, 2
StringMid, Second2Send, TimeBefore, 13, 2
;Send, %Year2Send%{right}%Month2Send%{right}%Day2Send%{right}%Hour2Send%{right}%Minute2Send%{right}%Second2Send%
;For my test I use TABS. You wrote you need RIGHT. Therefore use the line above
ControlSetText, Edit2, 
ControlFocus, Edit2, Enter a minute-value
Send, %Year2Send%{tab}%Month2Send%{tab}%Day2Send%{tab}%Hour2Send%{tab}%Minute2Send%{tab}%Second2Send%

;Send the new value with subtracted minutes
StringLeft, Year2Send, TimeAfter, 4
StringMid, Month2Send, TimeAfter, 5, 2
StringMid, Day2Send, TimeAfter, 7, 2
StringMid, Hour2Send, TimeAfter, 9, 2
StringMid, Minute2Send, TimeAfter, 11, 2
StringMid, Second2Send, TimeAfter, 13, 2
;Send, %Year2Send%{right}%Month2Send%{right}%Day2Send%{right}%Hour2Send%{right}%Minute2Send%{right}%Second2Send%
;For my test I use TABS. You wrote you need RIGHT. Therefore use the line above
ControlSetText, Edit8, 
ControlFocus, Edit8, Enter a minute-value
Send, %Year2Send%{tab}%Month2Send%{tab}%Day2Send%{tab}%Hour2Send%{tab}%Minute2Send%{tab}%Second2Send%

return



Manchestertaco
  • Guests
  • Last active:
  • Joined: --
Close, i think it has pointed it me in the right direction. Allow me to better explain though.

You got the send from clip part correct, however the output was not as intended, im not sure if its returning the correct number though, let me explain further

In the clipboard, a number is held - 0000\00\00 00:00:00
Imagine a editbox and a button, this edit box a user inputs numbers
a number is entered representing minutes
When button is pressed, it will tell the script to take the number from the user, and subtract and add the amount of minutes. It then sends these numbers in
%Year2Send%{right}%Month2Send%{right}%Day2Send%{right}%Hour2Send%{right}%Minute2Send%{right}%Second2Send%
format to two target windows. one being the subtracted amount, one being the added amount.

Example, User inputs the number 15

2006\20\20 20:22:20(number user had copied to the clipboard) would result in 2006\20\20 20:7:20 (Before ), and send it as yyyy\mm\dd hh\mm\ss, it would THEN send 2006\20\20 20:37:20 (This is after)


I may be able to get it off of what you gave me, I thank you for that. gota work on it a bit i suppose

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
I've updated my first post with new code
Ciao
Micha